001/*
002 * Copyright 2006-2007 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.batch.item;
018
019import java.util.List;
020
021/**
022 * <p>
023 * Basic interface for generic output operations. Class implementing this
024 * interface will be responsible for serializing objects as necessary.
025 * Generally, it is responsibility of implementing class to decide which
026 * technology to use for mapping and how it should be configured.
027 * </p>
028 * 
029 * <p>
030 * The write method is responsible for making sure that any internal buffers are
031 * flushed. If a transaction is active it will also usually be necessary to
032 * discard the output on a subsequent rollback. The resource to which the writer
033 * is sending data should normally be able to handle this itself.
034 * </p>
035 * 
036 * @author Dave Syer
037 * @author Lucas Ward
038 */
039public interface ItemWriter<T> {
040
041        /**
042         * Process the supplied data element. Will not be called with any null items
043         * in normal operation.
044         *
045         * @param items items to be written
046         * @throws Exception if there are errors. The framework will catch the
047         * exception and convert or rethrow it as appropriate.
048         */
049        void write(List<? extends T> items) throws Exception;
050
051}