List of usage examples for org.springframework.batch.item ExecutionContext putLong
public void putLong(String key, long value)
From source file:org.springframework.batch.core.partition.ExampleItemReader.java
@Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); executionContext.putLong(getExecutionContextKey("POSITION"), index); }
From source file:org.springframework.batch.core.partition.support.FlatFilePartitioner.java
/** * Creates a standard {@link ExecutionContext} with the specified parameters. * @param partitionName the name of the partition * @param startAt the number of bytes for a partition thread to skip before starting reading * @param itemsCount the number of items to read * @return the execution context (output) *///from w w w . j a v a 2s .c om protected ExecutionContext createExecutionContext(String partitionName, long startAt, long itemsCount, long previousItemsCount) { final ExecutionContext executionContext = new ExecutionContext(); executionContext.putLong(startAtKeyName, startAt); executionContext.putLong(itemsCountKeyName, itemsCount); executionContext.putLong(previousItemsCountKeyName, previousItemsCount); try { executionContext.putString(resourceKeyName, "file:" + resource.getFile().getPath()); } catch (IOException e) { throw new IllegalArgumentException("File could not be located for: " + resource, e); } if (logger.isDebugEnabled()) { logger.debug("Added partition [" + partitionName + "] with [" + executionContext + "]"); } return executionContext; }
From source file:org.springframework.batch.item.file.FlatFileItemWriter.java
/** * @see ItemStream#update(ExecutionContext) *///from w w w.jav a 2 s . co m @Override public void update(ExecutionContext executionContext) { super.update(executionContext); if (state == null) { throw new ItemStreamException("ItemStream not open or already closed."); } Assert.notNull(executionContext, "ExecutionContext must not be null"); if (saveState) { try { executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), state.position()); } catch (IOException e) { throw new ItemStreamException("ItemStream does not return current position properly", e); } executionContext.putLong(getExecutionContextKey(WRITTEN_STATISTICS_NAME), state.linesWritten); } }
From source file:org.springframework.batch.item.xml.StaxEventItemWriter.java
/** * Get the restart data.// w ww.ja va2s .co m * * @see org.springframework.batch.item.ItemStream#update(ExecutionContext) */ @Override public void update(ExecutionContext executionContext) { super.update(executionContext); if (saveState) { Assert.notNull(executionContext, "ExecutionContext must not be null"); executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), getPosition()); executionContext.putLong(getExecutionContextKey(WRITE_STATISTICS_NAME), currentRecordCount); if (!unclosedHeaderCallbackElements.isEmpty()) { executionContext.put(getExecutionContextKey(UNCLOSED_HEADER_CALLBACK_ELEMENTS_NAME), unclosedHeaderCallbackElements); } } }