/** * Register a single {@link ItemStream} for callbacks to the stream * interface. * * @param stream instance of {@link ItemStream} */ public void registerStream(ItemStream stream) { this.stream.register(stream); }
@Override @SuppressWarnings("unchecked") public O process(I item) throws Exception { Object result = item; for (ItemProcessor<?, ?> delegate : delegates) { if (result == null) { return null; } result = processItem(delegate, result); } return (O) result; }
@Override protected void close(ExecutionContext ctx) throws Exception { stream.close(); }
public void testRegisterAndOpen() { ItemStreamSupport stream = new ItemStreamSupport() { @Override public void open(ExecutionContext executionContext) { super.open(executionContext); list.add("bar"); } }; manager.register(stream); manager.open(null); assertEquals(1, list.size()); }
public void testCloseDoesNotUnregister() { manager.setStreams(new ItemStream[] { new ItemStreamSupport() { @Override public void open(ExecutionContext executionContext) { super.open(executionContext); list.add("bar"); } } }); manager.open(null); manager.close(); manager.open(null); assertEquals(2, list.size()); }
public void testMark() { manager.register(new ItemStreamSupport() { @Override public void update(ExecutionContext executionContext) { super.update(executionContext); list.add("bar"); } }); manager.update(null); assertEquals(1, list.size()); }
public void testClose() { manager.register(new ItemStreamSupport() { @Override public void close() { super.close(); list.add("bar"); } }); manager.close(); assertEquals(1, list.size()); }
/** * Initialize the reader. This method may be called multiple times before * close is called. * * @see ItemStream#open(ExecutionContext) */ @Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); Assert.notNull(resource, "The resource must be set"); if (!getOutputState().isInitialized()) { doOpen(executionContext); } }
@Override protected void open(ExecutionContext ctx) throws Exception { stream.open(ctx); }
public void testIterable() throws Exception { IteratorItemReader<String> reader = new IteratorItemReader<>(Arrays.asList(new String[]{"a", "b", "c"})); assertEquals("a", reader.read()); assertEquals("b", reader.read()); assertEquals("c", reader.read()); assertEquals(null, reader.read()); }
@Override public void open(ExecutionContext executionContext) { super.open(executionContext); opened = true; }
/** * Move to the given item index. Subclasses should override this method if * there is a more efficient way of moving to given index than re-reading * the input using {@link #doRead()}. * * @param itemIndex index of item (0 based) to jump to. * @throws Exception Allows subclasses to throw checked exceptions for interpretation by the framework */ protected void jumpToItem(int itemIndex) throws Exception { for (int i = 0; i < itemIndex; i++) { read(); } }
public void testNext() throws Exception { assertEquals("a", reader.read()); assertEquals("b", reader.read()); assertEquals("c", reader.read()); assertEquals(null, reader.read()); }
public void testNext() throws Exception { assertEquals("a", reader.read()); assertEquals("b", reader.read()); assertEquals("c", reader.read()); assertEquals(null, reader.read()); }
@Override public void close() { super.close(); closed = true; }
/** * Creates a {@link PassThroughItemProcessor} and uses it to create an * instance of {@link Tasklet}. */ public TestingChunkOrientedTasklet(ItemReader<T> itemReader, ItemWriter<T> itemWriter, RepeatOperations repeatOperations) { this(itemReader, new PassThroughItemProcessor<>(), itemWriter, repeatOperations); }
public CountingListItemReader(List<T> list) { this.list = list; setName("foo"); }
public void testRegisterTwice() { ItemStreamSupport stream = new ItemStreamSupport() { @Override public void open(ExecutionContext executionContext) { super.open(executionContext); list.add("bar"); } }; manager.register(stream); manager.register(stream); manager.open(null); assertEquals(1, list.size()); }
/** * @param stream the stream to set */ public void registerItemStream(ItemStream stream) { streamsRegistered = true; this.stream.register(stream); }