diff --git a/spring-batch-core-tests/.classpath b/spring-batch-core-tests/.classpath index 96489ff1c..972642784 100644 --- a/spring-batch-core-tests/.classpath +++ b/spring-batch-core-tests/.classpath @@ -1,10 +1,10 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/spring-batch-core-tests/.settings/org.springframework.ide.eclipse.beans.core.prefs b/spring-batch-core-tests/.settings/org.springframework.ide.eclipse.beans.core.prefs index ce40fadc6..5eb2e7998 100644 --- a/spring-batch-core-tests/.settings/org.springframework.ide.eclipse.beans.core.prefs +++ b/spring-batch-core-tests/.settings/org.springframework.ide.eclipse.beans.core.prefs @@ -1,23 +1,24 @@ -#Tue Sep 22 11:04:01 BST 2009 -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/aop= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/batch= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/beans= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/context= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/faces= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jdbc= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jee= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jms= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/lang= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/osgi= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/osgi-compendium= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/oxm= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/p= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/security= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/task= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/tx= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/util= -//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/webflow-config= -eclipse.preferences.version=1 -org.springframework.ide.eclipse.beans.core.default.version.check.classpath=true -org.springframework.ide.eclipse.beans.core.enable.namespace.versions=false -org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false +#Sun Dec 20 09:45:20 GMT 2009 +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.osgi.org/xmlns/blueprint/v1.0.0= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/aop= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/batch= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/beans= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/context= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/faces= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jdbc= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jee= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jms= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/lang= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/osgi= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/osgi-compendium= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/oxm= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/p= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/security= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/task= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/tx= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/util= +//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/webflow-config= +eclipse.preferences.version=1 +org.springframework.ide.eclipse.beans.core.default.version.check.classpath=true +org.springframework.ide.eclipse.beans.core.enable.namespace.versions=false +org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false diff --git a/spring-batch-core-tests/.springBeans b/spring-batch-core-tests/.springBeans index f3f83d52b..1b9ab6d8e 100644 --- a/spring-batch-core-tests/.springBeans +++ b/spring-batch-core-tests/.springBeans @@ -1,237 +1,241 @@ - - - 1 - - - - - - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - - true - false - - - - - + + + 1 + + + + + + + src/test/resources/adhoc-job-launcher-context.xml + src/test/resources/jobs/adhocLoopJob.xml + src/test/resources/data-source-context.xml + src/test/resources/simple-job-launcher-context.xml + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + + true + false + + + + + diff --git a/spring-batch-core-tests/pom.xml b/spring-batch-core-tests/pom.xml index 25f88fa03..3c3e7a835 100644 --- a/spring-batch-core-tests/pom.xml +++ b/spring-batch-core-tests/pom.xml @@ -62,6 +62,10 @@ spring-batch-core 2.1.0.CI-SNAPSHOT + + commons-dbcp + commons-dbcp + hsqldb hsqldb diff --git a/spring-batch-core-tests/src/main/resources/batch-hsql.properties b/spring-batch-core-tests/src/main/resources/batch-hsql.properties index d68b8457e..362846da7 100644 --- a/spring-batch-core-tests/src/main/resources/batch-hsql.properties +++ b/spring-batch-core-tests/src/main/resources/batch-hsql.properties @@ -7,16 +7,11 @@ batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true # batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples batch.jdbc.user=sa batch.jdbc.password= -batch.schema= -batch.jndi.name= -batch.naming.factory.initial= -batch.naming.provider.url= -batch.schema.script=schema-hsqldb.sql -batch.drop.script=schema-drop-hsqldb.sql -batch.business.schema.script=business-schema-hsqldb.sql +batch.jdbc.testWhileIdle=false +batch.jdbc.validationQuery= +batch.schema.script=classpath:/org/springframework/batch/core/schema-hsqldb.sql +batch.business.schema.script=classpath:/business-schema-hsqldb.sql +batch.data.source.init=true batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer -batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler - -# Bean Properties for override -# when not using sequences: -incrementerParent.columnName=ID +batch.database.incrementer.parent=columnIncrementerParent +batch.grid.size=2 diff --git a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/env-context.xml b/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/env-context.xml deleted file mode 100644 index e18ed2c68..000000000 --- a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/env-context.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - ${batch.schema.script} - ${batch.business.schema.script} - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/execution-context.xml b/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/execution-context.xml deleted file mode 100644 index 4d46593bb..000000000 --- a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/execution-context.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/init.sql b/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/init.sql deleted file mode 100644 index 105bd81af..000000000 --- a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/init.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE T_FOOS; -create table T_FOOS ( - id integer not null primary key, - name varchar(80), - foo_date timestamp -); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/JdbcJobRepositoryTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java similarity index 99% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/support/JdbcJobRepositoryTests.java rename to spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java index 38b6913ce..4b67ee2d5 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/JdbcJobRepositoryTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JdbcJobRepositoryTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.support; +package org.springframework.batch.core.test.repository; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java new file mode 100644 index 000000000..0624a8697 --- /dev/null +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java @@ -0,0 +1,152 @@ +/* + * 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.core.test.repository; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParametersIncrementer; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.UnexpectedJobExecutionException; +import org.springframework.beans.factory.BeanNameAware; +import org.springframework.util.ClassUtils; + +/** + * Batch domain object representing a job. Job is an explicit abstraction + * representing the configuration of a job specified by a developer. It should + * be noted that restart policy is applied to the job as a whole and not to a + * step. + * + * @author Lucas Ward + * @author Dave Syer + */ +public class JobSupport implements BeanNameAware, Job { + + private List steps = new ArrayList(); + + private String name; + + private boolean restartable = false; + + private int startLimit = Integer.MAX_VALUE; + + /** + * Default constructor. + */ + public JobSupport() { + super(); + } + + /** + * Convenience constructor to immediately add name (which is mandatory but + * not final). + * + * @param name the name + */ + public JobSupport(String name) { + super(); + this.name = name; + } + + /** + * Set the name property if it is not already set. Because of the order of + * the callbacks in a Spring container the name property will be set first + * if it is present. Care is needed with bean definition inheritance - if a + * parent bean has a name, then its children need an explicit name as well, + * otherwise they will not be unique. + * + * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) + */ + public void setBeanName(String name) { + if (this.name == null) { + this.name = name; + } + } + + /** + * Set the name property. Always overrides the default value if this object + * is a Spring bean. + * + * @see #setBeanName(java.lang.String) + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /* (non-Javadoc) + * @see org.springframework.batch.core.domain.IJob#getName() + */ + public String getName() { + return name; + } + + public void setSteps(List steps) { + this.steps.clear(); + this.steps.addAll(steps); + } + + public void addStep(Step step) { + this.steps.add(step); + } + + public List getSteps() { + return steps; + } + + /* (non-Javadoc) + * @see org.springframework.batch.core.domain.IJob#getStartLimit() + */ + public int getStartLimit() { + return startLimit; + } + + public void setStartLimit(int startLimit) { + this.startLimit = startLimit; + } + + public void setRestartable(boolean restartable) { + this.restartable = restartable; + } + + /* (non-Javadoc) + * @see org.springframework.batch.core.domain.IJob#isRestartable() + */ + public boolean isRestartable() { + return restartable; + } + + /* (non-Javadoc) + * @see org.springframework.batch.core.Job#getJobParametersIncrementer() + */ + public JobParametersIncrementer getJobParametersIncrementer() { + return null; + } + + /* (non-Javadoc) + * @see org.springframework.batch.core.domain.Job#run(org.springframework.batch.core.domain.JobExecution) + */ + public void execute(JobExecution execution) throws UnexpectedJobExecutionException { + throw new UnsupportedOperationException("JobSupport does not provide an implementation of run(). Use a smarter subclass."); + } + + public String toString() { + return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; + } +} diff --git a/spring-batch-core-tests/src/test/resources/adhoc-job-launcher-context.xml b/spring-batch-core-tests/src/test/resources/adhoc-job-launcher-context.xml new file mode 100644 index 000000000..919fc4540 --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/adhoc-job-launcher-context.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-batch-core-tests/src/test/resources/batch-derby.properties b/spring-batch-core-tests/src/test/resources/batch-derby.properties new file mode 100644 index 000000000..0f2a0eb60 --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/batch-derby.properties @@ -0,0 +1,18 @@ +# Placeholders batch.* +# for Derby: +batch.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver +batch.jdbc.url=jdbc:derby:derby-home/test;create=true +batch.jdbc.user=sa +batch.jdbc.password= +batch.schema= +batch.jndi.name= +batch.naming.factory.initial= +batch.naming.provider.url= +batch.schema.script=schema-derby.sql +batch.business.schema.script=business-schema-derby.sql +batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer +batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler + +# Bean Properties for override +# when not using sequences: +incrementerParent.columnName=ID diff --git a/spring-batch-core-tests/src/test/resources/batch-hsql.properties b/spring-batch-core-tests/src/test/resources/batch-hsql.properties new file mode 100644 index 000000000..362846da7 --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/batch-hsql.properties @@ -0,0 +1,17 @@ +# Placeholders batch.* +# for HSQLDB: +batch.jdbc.driver=org.hsqldb.jdbcDriver +batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true +# use this one for a separate server process so you can inspect the results +# (or add it to system properties with -D to override at run time). +# batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples +batch.jdbc.user=sa +batch.jdbc.password= +batch.jdbc.testWhileIdle=false +batch.jdbc.validationQuery= +batch.schema.script=classpath:/org/springframework/batch/core/schema-hsqldb.sql +batch.business.schema.script=classpath:/business-schema-hsqldb.sql +batch.data.source.init=true +batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer +batch.database.incrementer.parent=columnIncrementerParent +batch.grid.size=2 diff --git a/spring-batch-core-tests/src/test/resources/batch-mysql.properties b/spring-batch-core-tests/src/test/resources/batch-mysql.properties new file mode 100644 index 000000000..f481d74a7 --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/batch-mysql.properties @@ -0,0 +1,19 @@ +# Placeholders batch.* +# for MySQL: +batch.jdbc.driver=com.mysql.jdbc.Driver +batch.jdbc.url=jdbc:mysql://localhost/test +batch.jdbc.user=root +batch.jdbc.password=root +batch.schema= +batch.jndi.name= +batch.naming.factory.initial= +batch.naming.provider.url= +batch.schema.script=schema-mysql.sql +batch.drop.script=schema-drop-mysql.sql +batch.business.schema.script=business-schema-mysql.sql +batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer +batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler + +# Bean Properties for override +# when not using sequences: +incrementerParent.columnName=ID diff --git a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/data-source-context.xml b/spring-batch-core-tests/src/test/resources/data-source-context.xml similarity index 85% rename from spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/data-source-context.xml rename to spring-batch-core-tests/src/test/resources/data-source-context.xml index 438ec23c0..ae90208ce 100644 --- a/spring-batch-core-tests/src/main/resources/org/springframework/batch/core/test/data-source-context.xml +++ b/spring-batch-core-tests/src/test/resources/data-source-context.xml @@ -7,7 +7,7 @@ - + ${batch.drop.script} @@ -17,7 +17,7 @@ - + @@ -55,9 +55,16 @@ - + - + + + + + + + + diff --git a/spring-batch-core-tests/src/test/resources/jobs/adhocLoopJob.xml b/spring-batch-core-tests/src/test/resources/jobs/adhocLoopJob.xml new file mode 100644 index 000000000..1151f23e2 --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/jobs/adhocLoopJob.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-core-tests/src/test/resources/log4j.properties b/spring-batch-core-tests/src/test/resources/log4j.properties new file mode 100644 index 000000000..f8c8855eb --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/log4j.properties @@ -0,0 +1,12 @@ +log4j.rootCategory=INFO, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{1}:%L - %m%n + +log4j.category.org.apache.activemq=ERROR +# log4j.category.org.springframework=DEBUG +log4j.category.org.springframework.jdbc=DEBUG +log4j.category.org.springframework.jms=DEBUG +log4j.category.org.springframework.batch=DEBUG +log4j.category.org.springframework.retry=DEBUG diff --git a/spring-batch-core-tests/src/test/resources/simple-job-launcher-context.xml b/spring-batch-core-tests/src/test/resources/simple-job-launcher-context.xml new file mode 100644 index 000000000..8aa43c2c4 --- /dev/null +++ b/spring-batch-core-tests/src/test/resources/simple-job-launcher-context.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java index 2f9228df1..84b20a66f 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java @@ -38,7 +38,6 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.NoSuchJobException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRestartException; -import org.springframework.batch.sample.support.JobSupport; /** * @author Dave Syer diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/JobSupport.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobSupport.java similarity index 98% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/support/JobSupport.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobSupport.java index 952692366..bc188dc78 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/JobSupport.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobSupport.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.support; +package org.springframework.batch.sample.quartz; import java.util.ArrayList; import java.util.List; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/StepSupport.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/StepSupport.java deleted file mode 100644 index dd8a916d9..000000000 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/support/StepSupport.java +++ /dev/null @@ -1,109 +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.sample.support; - -import org.springframework.batch.core.JobInterruptedException; -import org.springframework.batch.core.Step; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.UnexpectedJobExecutionException; -import org.springframework.beans.factory.BeanNameAware; - -/** - * Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that - * if no name is provided explicitly it will be inferred from the bean definition in Spring configuration. - * - * @author Dave Syer - * - */ -public class StepSupport implements Step, BeanNameAware { - - private String name; - - private int startLimit = Integer.MAX_VALUE; - - private boolean allowStartIfComplete; - - /** - * Default constructor for {@link StepSupport}. - */ - public StepSupport() { - super(); - } - - public StepSupport(String string) { - super(); - this.name = string; - } - - public String getName() { - return this.name; - } - - /** - * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the - * name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent - * bean has a name, then its children need an explicit name as well, otherwise they will not be unique. - * - * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) - */ - public void setBeanName(String name) { - if (this.name == null) { - this.name = name; - } - } - - public void setName(String name) { - this.name = name; - } - - public int getStartLimit() { - return this.startLimit; - } - - /** - * Public setter for the startLimit. - * - * @param startLimit the startLimit to set - */ - public void setStartLimit(int startLimit) { - this.startLimit = startLimit; - } - - public boolean isAllowStartIfComplete() { - return this.allowStartIfComplete; - } - - /** - * Public setter for the shouldAllowStartIfComplete. - * - * @param allowStartIfComplete the shouldAllowStartIfComplete to set - */ - public void setAllowStartIfComplete(boolean allowStartIfComplete) { - this.allowStartIfComplete = allowStartIfComplete; - } - - /** - * Not supported but provided so that tests can easily create a step. - * - * @throws UnsupportedOperationException always - * - * @see org.springframework.batch.core.Step#execute(org.springframework.batch.core.StepExecution) - */ - public void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException { - throw new UnsupportedOperationException( - "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); - } -}