BATCH-2086: default writer implementations need public setter for name

This commit is contained in:
jpraet
2013-08-28 17:49:43 +02:00
committed by Michael Minella
parent 7c9396da18
commit ca91bbb375
4 changed files with 24 additions and 21 deletions

View File

@@ -51,6 +51,17 @@ public abstract class ItemStreamSupport implements ItemStream {
@Override
public void update(ExecutionContext executionContext) {
}
/**
* The name of the component which will be used as a stem for keys in the
* {@link ExecutionContext}. Subclasses should provide a default value, e.g.
* the short form of the class name.
*
* @param name the name for the component
*/
public void setName(String name) {
this.setExecutionContextName(name);
}
protected void setExecutionContextName(String name) {
executionContextUserSupport.setName(name);

View File

@@ -392,17 +392,6 @@ InitializingBean {
return state;
}
/**
* The name of the component which will be used as a stem for keys in the
* {@link ExecutionContext}. Subclasses should provide a default value, e.g.
* the short form of the class name.
*
* @param name the name for the component
*/
public void setName(String name) {
this.setExecutionContextName(name);
}
/**
* Encapsulates the runtime state of the writer. All state changing
* operations on the writer go through this class.

View File

@@ -179,16 +179,6 @@ public abstract class AbstractItemCountingItemStreamItemReader<T> extends Abstra
}
/**
* The name of the component which will be used as a stem for keys in the
* {@link ExecutionContext}. Subclasses should provide a default value, e.g.
* the short form of the class name.
*
* @param name the name for the component
*/
public void setName(String name) {
this.setExecutionContextName(name);
}
/**
* Set the flag that determines whether to save internal data for

View File

@@ -100,6 +100,19 @@ public class StaxEventItemWriterTests {
jaxbMarshaller = new Jaxb2Marshaller();
jaxbMarshaller.setClassesToBeBound(JAXBItem.class);
}
/**
* Test setting writer name.
*/
@Test
public void testSetName() throws Exception {
writer.setName("test");
writer.open(executionContext);
writer.write(items);
writer.update(executionContext);
writer.close();
assertTrue("execution context keys should be prefixed with writer name", executionContext.containsKey("test.position"));
}
/**
* Item is written to the output file only after flush.