Minor tweaks to javadocs / visibility etc.

This commit is contained in:
dsyer
2008-07-23 08:34:06 +00:00
parent ecdf4816ec
commit a2c279dd80
6 changed files with 56 additions and 68 deletions

View File

@@ -64,7 +64,7 @@ public class SimpleJobRepository implements JobRepository {
/**
* Provide default constructor with low visibility in case user wants to use
* use aop:proxy-target-class="true" for transaction interceptor.
* use aop:proxy-target-class="true" for AOP interceptor.
*/
SimpleJobRepository() {
}

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" kind="src" output="bin/test-classes" path="src/test/java"/>
<classpathentry excluding="**/*.java" kind="src" output="bin/test-classes" path="src/test/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.devzuz.q.maven.jdt.core.mavenClasspathContainer"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin/classes"/>

View File

@@ -47,7 +47,7 @@ public abstract class AbstractTransactionalResourceItemWriter<T> implements Item
*
* @see org.springframework.batch.item.ItemWriter#flush()
*/
public void flush() throws FlushFailedException {
public final void flush() throws FlushFailedException {
bindTransactionResources();
try {
doFlush();
@@ -73,35 +73,18 @@ public abstract class AbstractTransactionalResourceItemWriter<T> implements Item
*
* @see org.springframework.batch.item.ItemWriter#write(Object)
*/
public void write(T output) throws Exception {
public final void write(T output) throws Exception {
bindTransactionResources();
getProcessed().add(output);
doWrite(output);
flushIfNecessary(output);
}
private void flushIfNecessary(Object output) {
boolean flush;
synchronized (failed) {
flush = failed.contains(output);
}
if (flush) {
// Force early completion to commit aggressively if we encounter a
// failed item (from a failed chunk but we don't know which one was
// the problem).
RepeatSynchronizationManager.setCompleteOnly();
// Flush now, so that if there is a failure this record can be
// skipped.
flush();
}
}
/**
* Delegate to subclass and unbind transactional resources, effectively
* clearing the item buffer.
*/
public void clear() throws ClearFailedException {
public final void clear() throws ClearFailedException {
try {
doClear();
}
@@ -131,6 +114,23 @@ public abstract class AbstractTransactionalResourceItemWriter<T> implements Item
*/
protected abstract String getResourceKey();
private void flushIfNecessary(Object output) {
boolean flush;
synchronized (failed) {
flush = failed.contains(output);
}
if (flush) {
// Force early completion to commit aggressively if we encounter a
// failed item (from a failed chunk but we don't know which one was
// the problem).
RepeatSynchronizationManager.setCompleteOnly();
// Flush now, so that if there is a failure this record can be
// skipped.
flush();
}
}
/**
* Set up the {@link RepeatContext} as a transaction resource.
*

View File

@@ -13,7 +13,7 @@ import org.springframework.core.io.ByteArrayResource;
public class StaxEventItemReaderCommonTests extends CommonItemStreamItemReaderTests {
private final String FOOS = "<foos> <foo value=\"1\"/> <foo value=\"2\"/> <foo value=\"3\"/> <foo value=\"4\"/> <foo value=\"5\"/> </foos>";
private final static String FOOS = "<foos> <foo value=\"1\"/> <foo value=\"2\"/> <foo value=\"3\"/> <foo value=\"4\"/> <foo value=\"5\"/> </foos>";
protected ItemReader<Foo> getItemReader() throws Exception {
StaxEventItemReader<Foo> reader = new StaxEventItemReader<Foo>();

View File

@@ -110,8 +110,8 @@ public class ExitStatusTests extends TestCase {
public void testAndExitStatusStillContinuable() {
assertTrue(ExitStatus.CONTINUABLE.and(ExitStatus.CONTINUABLE).isContinuable());
assertFalse(ExitStatus.CONTINUABLE.and(ExitStatus.FINISHED).isContinuable());
assertTrue(ExitStatus.CONTINUABLE.and(ExitStatus.CONTINUABLE).getExitCode() == ExitStatus.CONTINUABLE
.getExitCode());
assertTrue(ExitStatus.CONTINUABLE.and(ExitStatus.CONTINUABLE).getExitCode().equals(
ExitStatus.CONTINUABLE.getExitCode()));
}
/**
@@ -144,8 +144,8 @@ public class ExitStatusTests extends TestCase {
* {@link org.springframework.batch.repeat.ExitStatus#and(org.springframework.batch.repeat.ExitStatus)}.
*/
public void testAndExitStatusWhenCustomContinuableAddedToFinished() {
assertEquals(ExitStatus.FINISHED.getExitCode(), ExitStatus.FINISHED.and(ExitStatus.CONTINUABLE.replaceExitCode("CUSTOM"))
.getExitCode());
assertEquals(ExitStatus.FINISHED.getExitCode(), ExitStatus.FINISHED.and(
ExitStatus.CONTINUABLE.replaceExitCode("CUSTOM")).getExitCode());
}
public void testAddExitCode() throws Exception {

View File

@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
@@ -14,16 +12,13 @@
<bean id="step1" parent="simpleStep" p:commitInterval="3">
<property name="streams" ref="fileItemReader" />
<property name="itemReader">
<bean
class="org.springframework.batch.item.validator.ValidatingItemReader">
<property name="itemReader"
ref="fileItemReader" />
<bean class="org.springframework.batch.item.validator.ValidatingItemReader">
<property name="itemReader" ref="fileItemReader" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.item.writer.TradeWriter">
<bean class="org.springframework.batch.sample.item.writer.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
@@ -34,30 +29,25 @@
<!-- INFRASTRUCTURE SETUP -->
<!-- This input source is injected into the test case to verify the output - not used by the job at all -->
<bean id="testItemReader"
class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
<property name="lineTokenizer" ref="fixedFileTokenizer" />
<property name="fieldSetMapper" ref="fieldSetMapper" />
</bean>
<bean id="fileItemReader" parent="testItemReader"
autowire-candidate="false" />
<bean id="fixedFileTokenizer"
class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
</bean>
<bean id="fixedValidator"
class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator"
class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<bean id="testItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
<property name="lineTokenizer" ref="fixedFileTokenizer" />
<property name="fieldSetMapper" ref="fieldSetMapper" />
</bean>
<bean id="fileItemReader" parent="testItemReader" autowire-candidate="false" />
<bean id="fixedFileTokenizer" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
@@ -67,8 +57,7 @@
</property>
</bean>
<bean id="tradeDao"
class="org.springframework.batch.sample.dao.JdbcTradeDao">
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeDao">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
@@ -78,7 +67,6 @@
</property>
</bean>
<bean id="fieldSetMapper"
class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
</beans>