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 019/** 020 * <p> 021 * Marker interface defining a contract for periodically storing state and restoring from that state should an error 022 * occur. 023 * <p> 024 * 025 * @author Dave Syer 026 * @author Lucas Ward 027 * 028 */ 029public interface ItemStream { 030 031 /** 032 * Open the stream for the provided {@link ExecutionContext}. 033 * 034 * @param executionContext current step's {@link org.springframework.batch.item.ExecutionContext}. Will be the 035 * executionContext from the last run of the step on a restart. 036 * @throws IllegalArgumentException if context is null 037 */ 038 void open(ExecutionContext executionContext) throws ItemStreamException; 039 040 /** 041 * Indicates that the execution context provided during open is about to be saved. If any state is remaining, but 042 * has not been put in the context, it should be added here. 043 * 044 * @param executionContext to be updated 045 * @throws IllegalArgumentException if executionContext is null. 046 */ 047 void update(ExecutionContext executionContext) throws ItemStreamException; 048 049 /** 050 * If any resources are needed for the stream to operate they need to be destroyed here. Once this method has been 051 * called all other methods (except open) may throw an exception. 052 */ 053 void close() throws ItemStreamException; 054}