View Javadoc

1   /*
2    * Copyright 2006-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.batch.item;
18  
19  import java.util.List;
20  
21  /**
22   * <p>
23   * Basic interface for generic output operations. Class implementing this
24   * interface will be responsible for serializing objects as necessary.
25   * Generally, it is responsibility of implementing class to decide which
26   * technology to use for mapping and how it should be configured.
27   * </p>
28   * 
29   * <p>
30   * The write method is responsible for making sure that any internal buffers are
31   * flushed. If a transaction is active it will also usually be necessary to
32   * discard the output on a subsequent rollback. The resource to which the writer
33   * is sending data should normally be able to handle this itself.
34   * </p>
35   * 
36   * @author Dave Syer
37   * @author Lucas Ward
38   */
39  public interface ItemWriter<T> {
40  
41  	/**
42  	 * Process the supplied data element. Will not be called with any null items
43  	 * in normal operation.
44  	 * 
45  	 * @throws Exception if there are errors. The framework will catch the
46  	 * exception and convert or rethrow it as appropriate.
47  	 */
48  	void write(List<? extends T> items) throws Exception;
49  
50  }