Purge StreamContext
This commit is contained in:
@@ -174,7 +174,7 @@ public class HibernateCursorItemReader extends AbstractItemStreamItemReader impl
|
||||
/**
|
||||
* @return the current row number wrapped as <code>StreamContext</code>
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
Properties props = new Properties();
|
||||
props.setProperty(RESTART_DATA_ROW_NUMBER_KEY, "" + currentProcessedRow);
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen
|
||||
*
|
||||
* @see org.springframework.batch.restart.Restartable#getStreamContext()
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
String skipped = skippedRows.toString();
|
||||
ExecutionAttributes context = new ExecutionAttributes();
|
||||
context.putString(SKIPPED_ROWS, skipped.substring(1, skipped.length() - 1));
|
||||
|
||||
@@ -189,7 +189,7 @@ public class DrivingQueryItemReader extends AbstractTransactionalIoSource
|
||||
}
|
||||
}
|
||||
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return keyGenerator.getKeyAsStreamContext(getCurrentKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implemen
|
||||
* current Line Count which can be used to re initialise the batch job in
|
||||
* case of restart.
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
if (reader == null) {
|
||||
throw new StreamException("ItemStream not open or already closed.");
|
||||
}
|
||||
|
||||
@@ -244,9 +244,9 @@ public class FlatFileItemWriter extends AbstractTransactionalIoSource implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ItemStream#getStreamContext()
|
||||
* @see ItemStream#getExecutionAttributes()
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
if (state == null) {
|
||||
throw new StreamException("ItemStream not open or already closed.");
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ public class StaxEventItemReader extends AbstractItemReader implements ItemReade
|
||||
|
||||
/**
|
||||
* @return wrapped count of records read so far.
|
||||
* @see ItemStream#getStreamContext()
|
||||
* @see ItemStream#getExecutionAttributes()
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
ExecutionAttributes restartData = new ExecutionAttributes();
|
||||
restartData.putLong(READ_COUNT_STATISTICS_NAME, currentRecordCount);
|
||||
return restartData;
|
||||
|
||||
@@ -361,9 +361,9 @@ public class StaxEventItemWriter implements ItemWriter, ItemStream, Initializing
|
||||
/**
|
||||
* Get the restart data.
|
||||
* @return the restart data
|
||||
* @see org.springframework.batch.item.ItemStream#getStreamContext()
|
||||
* @see org.springframework.batch.item.ItemStream#getExecutionAttributes()
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
if (!initialized) {
|
||||
throw new StreamException("ItemStream is not open, or may have been closed. Cannot access context.");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ package org.springframework.batch.item;
|
||||
* The state that is stored is represented as {@link ExecutionAttributes} which
|
||||
* enforces a requirement that any restart data can be represented by a
|
||||
* Properties object. In general, the contract is that {@link ExecutionAttributes}
|
||||
* that is returned via the {@link #getStreamContext()} method will be given
|
||||
* that is returned via the {@link #getExecutionAttributes()} method will be given
|
||||
* back to the {@link #restoreFrom(ExecutionAttributes)} method, exactly as it was
|
||||
* provided.
|
||||
* </p>
|
||||
@@ -34,7 +34,7 @@ package org.springframework.batch.item;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface ItemStream extends StreamContextProvider {
|
||||
public interface ItemStream extends ExecutionAttributesProvider {
|
||||
|
||||
/**
|
||||
* Restart state given the provided {@link ExecutionAttributes}.
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.item;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface StreamContextProvider {
|
||||
|
||||
/**
|
||||
* Get {@link ExecutionAttributes} representing this object's current state.
|
||||
* Should not return null even if there is no state.
|
||||
*
|
||||
* @return {@link ExecutionAttributes} representing current state.
|
||||
*/
|
||||
ExecutionAttributes getStreamContext();
|
||||
|
||||
}
|
||||
@@ -48,14 +48,14 @@ public class DelegatingItemReader extends AbstractItemReader implements Skippabl
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ItemStream#getStreamContext()
|
||||
* @see ItemStream#getExecutionAttributes()
|
||||
* @throws IllegalStateException if the parent template is not itself
|
||||
* {@link ItemStream}.
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
// TODO: this is not necessary...
|
||||
Assert.state(inputSource instanceof ItemStream, "Input source is not ItemStream");
|
||||
return ((ItemStream) inputSource).getStreamContext();
|
||||
return ((ItemStream) inputSource).getExecutionAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,9 +48,9 @@ public class ItemStreamAdapter implements ItemStream {
|
||||
|
||||
/**
|
||||
* Return empty {@link ExecutionAttributes}.
|
||||
* @see org.springframework.batch.item.StreamContextProvider#getStreamContext()
|
||||
* @see org.springframework.batch.item.ExecutionAttributesProvider#getExecutionAttributes()
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return new ExecutionAttributes();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SimpleStreamManager implements StreamManager {
|
||||
/**
|
||||
* Public setter for the flag. If this is true then the class name of the
|
||||
* streams will be used as a prefix in the {@link StreamContext} in
|
||||
* {@link #getStreamContext(Object)}. The default value is true, which
|
||||
* {@link #getExecutionAttributes(Object)}. The default value is true, which
|
||||
* gives the best chance of unique key names in the context.
|
||||
*
|
||||
* @param useClassNameAsPrefix the flag to set (default true).
|
||||
@@ -88,13 +88,13 @@ public class SimpleStreamManager implements StreamManager {
|
||||
* Simple aggregate {@link StreamContext} provider for the contributions
|
||||
* registered under the given key.
|
||||
*
|
||||
* @see org.springframework.batch.item.stream.StreamManager#getStreamContext(java.lang.Object)
|
||||
* @see org.springframework.batch.item.stream.StreamManager#getExecutionAttributes(java.lang.Object)
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext(Object key) {
|
||||
public ExecutionAttributes getExecutionAttributes(Object key) {
|
||||
final ExecutionAttributes result = new ExecutionAttributes();
|
||||
iterate(key, new Callback() {
|
||||
public void execute(ItemStream stream) {
|
||||
ExecutionAttributes context = stream.getStreamContext();
|
||||
ExecutionAttributes context = stream.getExecutionAttributes();
|
||||
String prefix = ClassUtils.getQualifiedName(stream.getClass()) + ".";
|
||||
if (!useClassNameAsPrefix) {
|
||||
prefix = "";
|
||||
@@ -179,7 +179,7 @@ public class SimpleStreamManager implements StreamManager {
|
||||
iterate(key, new Callback() {
|
||||
public void execute(ItemStream stream) {
|
||||
if (stream.isMarkSupported()) {
|
||||
stream.mark(stream.getStreamContext());
|
||||
stream.mark(stream.getExecutionAttributes());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -188,7 +188,7 @@ public class SimpleStreamManager implements StreamManager {
|
||||
iterate(key, new Callback() {
|
||||
public void execute(ItemStream stream) {
|
||||
if (stream.isMarkSupported()) {
|
||||
stream.reset(stream.getStreamContext());
|
||||
stream.reset(stream.getExecutionAttributes());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface StreamManager {
|
||||
* @return {@link ExecutionAttributes} aggregating the contexts of all providers
|
||||
* registered under this key, or empty otherwise.
|
||||
*/
|
||||
ExecutionAttributes getStreamContext(Object key);
|
||||
ExecutionAttributes getExecutionAttributes(Object key);
|
||||
|
||||
/**
|
||||
* If any resources are needed for the stream to operate they need to be
|
||||
|
||||
@@ -47,14 +47,14 @@ public class DelegatingItemWriter implements ItemWriter, Skippable, Initializing
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ItemStream#getStreamContext()
|
||||
* @see ItemStream#getExecutionAttributes()
|
||||
*/
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
|
||||
Assert.state(writer != null, "Source must not be null.");
|
||||
|
||||
if (writer instanceof ItemStream) {
|
||||
return ((ItemStream) writer).getStreamContext();
|
||||
return ((ItemStream) writer).getExecutionAttributes();
|
||||
}
|
||||
else {
|
||||
return new ExecutionAttributes();
|
||||
|
||||
Reference in New Issue
Block a user