From 90c8f7117306bb6d114c44628e4cd352b890ceda Mon Sep 17 00:00:00 2001 From: dsyer Date: Fri, 29 Feb 2008 12:22:48 +0000 Subject: [PATCH] OPEN - issue BATCH-385: Merge user attributes in StepContext with ExecutionContext http://jira.springframework.org/browse/BATCH-385 Remove step scope support. --- .../batch/execution/job/SimpleJob.java | 19 +- .../listener/CompositeItemWriteListener.java | 1 - .../execution/scope/JobParametersAware.java | 39 ---- .../execution/scope/SimpleStepContext.java | 173 -------------- .../batch/execution/scope/StepContext.java | 70 ------ .../execution/scope/StepContextAware.java | 38 ---- .../batch/execution/scope/StepScope.java | 158 ------------- .../scope/StepSynchronizationManager.java | 76 ------- .../batch/execution/scope/package.html | 7 - .../batch/execution/job/SimpleJobTests.java | 16 -- .../JobParametersAwareStepScopeTests.java | 95 -------- .../scope/SimpleStepContextTests.java | 130 ----------- .../scope/StepContextAwareStepScopeTests.java | 181 --------------- .../batch/execution/scope/StepScopeTests.java | 211 ------------------ .../execution/step/TaskletStepTests.java | 13 +- .../src/main/resources/jobs/adhocLoopJob.xml | 3 - .../jobs/beanWrapperMapperSampleJob.xml | 8 - .../jobs/compositeProcessorSampleJob.xml | 12 +- .../resources/jobs/fixedLengthImportJob.xml | 7 +- .../src/main/resources/jobs/footballJob.xml | 15 +- .../src/main/resources/jobs/hibernateJob.xml | 9 +- .../src/main/resources/jobs/ibatisJob.xml | 19 +- .../main/resources/jobs/infiniteLoopJob.xml | 3 - .../src/main/resources/jobs/multilineJob.xml | 17 +- .../main/resources/jobs/multilineOrderIo.xml | 8 +- .../main/resources/jobs/multilineOrderJob.xml | 5 - .../src/main/resources/jobs/parallelJob.xml | 5 +- .../src/main/resources/jobs/restartSample.xml | 8 +- .../src/main/resources/jobs/retrySample.xml | 8 +- .../src/main/resources/jobs/rollbackJob.xml | 11 +- .../src/main/resources/jobs/simpleJob.xml | 138 ++++++------ .../src/main/resources/jobs/tradeJob.xml | 12 +- .../src/main/resources/jobs/tradeJobIo.xml | 6 +- .../src/main/resources/jobs/xmlStaxJob.xml | 13 +- .../resources/simple-container-definition.xml | 4 - .../item/writer/staging-test-context.xml | 4 - 36 files changed, 104 insertions(+), 1438 deletions(-) delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/JobParametersAware.java delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContextAware.java delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepScope.java delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepSynchronizationManager.java delete mode 100644 spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/package.html delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/JobParametersAwareStepScopeTests.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepContextAwareStepScopeTests.java delete mode 100644 spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java index da1289d06..edce1ddc3 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/job/SimpleJob.java @@ -31,9 +31,6 @@ import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier; import org.springframework.batch.execution.listener.CompositeJobListener; -import org.springframework.batch.execution.scope.SimpleStepContext; -import org.springframework.batch.execution.scope.StepContext; -import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.batch.execution.step.support.SimpleExitStatusExceptionClassifier; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.repeat.ExitStatus; @@ -87,7 +84,7 @@ public class SimpleJob extends AbstractJob { execution.setStartTime(new Date()); updateStatus(execution, BatchStatus.STARTING); - + listener.beforeJob(execution); int startedCount = 0; @@ -103,15 +100,7 @@ public class SimpleJob extends AbstractJob { updateStatus(execution, BatchStatus.STARTED); StepExecution stepExecution = execution.createStepExecution(step); - StepContext parentStepContext = StepSynchronizationManager.getContext(); - final StepContext stepContext = new SimpleStepContext(stepExecution, parentStepContext); - StepSynchronizationManager.register(stepContext); - try { - step.execute(stepExecution); - } finally { - // clear any registered synchronizations - StepSynchronizationManager.close(); - } + step.execute(stepExecution); status = stepExecution.getExitStatus(); @@ -190,8 +179,8 @@ public class SimpleJob extends AbstractJob { } else { // start max has been exceeded, throw an exception. - throw new BatchCriticalException("Maximum start limit exceeded for step: " + step.getName() - + "StartMax: " + step.getStartLimit()); + throw new BatchCriticalException("Maximum start limit exceeded for step: " + step.getName() + "StartMax: " + + step.getStartLimit()); } } diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/listener/CompositeItemWriteListener.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/listener/CompositeItemWriteListener.java index e1a47af9d..8f2e02496 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/listener/CompositeItemWriteListener.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/listener/CompositeItemWriteListener.java @@ -21,7 +21,6 @@ import java.util.Iterator; import java.util.List; import org.springframework.batch.core.domain.ChunkListener; -import org.springframework.batch.core.domain.ItemReadListener; import org.springframework.batch.core.domain.ItemWriteListener; /** diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/JobParametersAware.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/JobParametersAware.java deleted file mode 100644 index c3ae13705..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/JobParametersAware.java +++ /dev/null @@ -1,39 +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.execution.scope; - -import org.springframework.batch.core.domain.JobParameters; - -/** - * Marker interface for callback injecting {@link JobParameters}. A Spring bean - * which is step scoped will be injected with the {@link JobParameters} when it - * is instantiated. In most cases this will require the use of - * <aop:scoped-proxy> when the bean is used as a dependency in a - * singleton. - * - * @author Dave Syer - * - */ -public interface JobParametersAware { - - /** - * Callback method for injection of {@link JobParameters}. - * - * @param jobParameters the {@link JobParameters} to set. - */ - void setJobParameters(JobParameters jobParameters); - -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java deleted file mode 100644 index b63ea8705..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/SimpleStepContext.java +++ /dev/null @@ -1,173 +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.execution.scope; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.io.exception.BatchCriticalException; -import org.springframework.batch.repeat.context.SynchronizedAttributeAccessor; - -/** - * Simple implementation of {@link StepContext}. - * - * @author Dave Syer - * - */ -public class SimpleStepContext extends SynchronizedAttributeAccessor implements StepContext { - - private Map callbacks = new HashMap(); - - private StepContext parent; - - private StepExecution stepExecution; - - /** - * Default constructor. - */ - public SimpleStepContext(StepExecution stepExecution) { - this(stepExecution, null); - } - - /** - * @param object - */ - public SimpleStepContext(StepExecution stepExecution, StepContext parent) { - super(); - this.parent = parent; - this.stepExecution = stepExecution; - } - - /* - * (non-Javadoc) - * @see org.springframework.batch.repeat.context.SynchronizedAttributeAccessor#setAttribute(java.lang.String, - * java.lang.Object) - */ - public void setAttribute(String name, Object value) { - super.setAttribute(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.execution.scope.StepContext#getParent() - */ - public StepContext getParent() { - return parent; - } - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.repeat.RepeatContext#registerDestructionCallback(java.lang.String, - * java.lang.Runnable) - */ - /* - * (non-Javadoc) - * - * @see org.springframework.batch.execution.scope.StepContext#registerDestructionCallback(java.lang.String, - * java.lang.Runnable) - */ - public void registerDestructionCallback(String name, Runnable callback) { - synchronized (callbacks) { - Set set = (Set) callbacks.get(name); - if (set == null) { - set = new HashSet(); - callbacks.put(name, set); - } - set.add(callback); - } - } - - /* - * (non-Javadoc) - * @see org.springframework.batch.execution.scope.StepContext#close() - */ - public void close() { - - List errors = new ArrayList(); - - Set copy; - - synchronized (callbacks) { - copy = new HashSet(callbacks.entrySet()); - } - - for (Iterator iter = copy.iterator(); iter.hasNext();) { - Map.Entry entry = (Map.Entry) iter.next(); - Set set = (Set) entry.getValue(); - for (Iterator iterator = set.iterator(); iterator.hasNext();) { - Runnable callback = (Runnable) iterator.next(); - /* - * There used to be a check here to make sure there was an - * attribute with the given name, but an inner bean is not - * registered with the bean factory, so the destroy method is - * only called in inner bean if we make the callback - * unconditionally. - */ - if (callback != null) { - /* - * The documentation of the interface says that these - * callbacks must not throw exceptions, but we don't trust - * them necessarily... - */ - try { - callback.run(); - } - catch (RuntimeException t) { - errors.add(t); - } - } - } - } - - if (errors.isEmpty()) { - return; - } - - Exception error = (Exception) errors.get(0); - if (error instanceof RuntimeException) { - throw (RuntimeException) error; - } - else { - throw new BatchCriticalException("Could not close step context, rethrowing first of " + errors.size() - + " execptions.", error); - } - } - - /* - * (non-Javadoc) - * - * @see org.springframework.batch.execution.scope.StepContext#getJobIdentifier() - */ - public StepExecution getStepExecution() { - return stepExecution; - } - - /* (non-Javadoc) - * @see org.springframework.batch.execution.scope.StepContext#getIdentifier() - */ - public String getIdentifier() { - return "JOB_EXECUTION_ID:"+stepExecution.getJobExecutionId(); - } - -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java deleted file mode 100644 index 07611bfc8..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContext.java +++ /dev/null @@ -1,70 +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.execution.scope; - -import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.core.AttributeAccessor; - -/** - * Interface for step-scoped context object and step-scoped services. This - * interface extends {@link AttributeAccessor}, so there is an underlying map - * that can be used for storing state during a step execution. The storage is - * volatile: the attributes are not persisted and not durable across - * steps in a job, or across restarts of a failed job. - * - * @see ExecutionContext for access to durable attributes that will be restored - * in the case of a restart. - * - * @author Dave Syer - * - */ -public interface StepContext extends AttributeAccessor { - - /** - * Accessor for the {@link StepExecution} associated with the currently - * executing step. - * - * @return the {@link StepExecution} associated with the current step - */ - StepExecution getStepExecution(); - - /** - * Accessor for the parent context. - * - * @return the parent of this context (or null if there isn't one) - */ - StepContext getParent(); - - /** - * Register a destruction callback for the end of life of the scope. - */ - void registerDestructionCallback(String name, Runnable callback); - - /** - * Clean up any resources held during the context of the step. - */ - void close(); - - /** - * Identify this context so that concurrently running jobs in the same VM - * can be distinguished. - * - * @return a sufficiently unique identifier for this context - */ - String getIdentifier(); - -} \ No newline at end of file diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContextAware.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContextAware.java deleted file mode 100644 index c36397f4d..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepContextAware.java +++ /dev/null @@ -1,38 +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.execution.scope; - -/** - * Marker interface for beans to be injected with a {@link StepContext}. Useful - * for business logic implementations that want to store some state in the - * context, to communicate between iterations, or with an enclosing executor.
- * - * A bean which is step scoped which also implements this interface will be - * injected with the context at the start of the bean lifecycle. - * - * @author Dave Syer - * - */ -public interface StepContextAware { - - /** - * Callback for injection of {@link StepContext}. - * - * @param context - * the current context supplied by framework. - */ - void setStepContext(StepContext context); -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepScope.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepScope.java deleted file mode 100644 index 990dbeaf7..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepScope.java +++ /dev/null @@ -1,158 +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.execution.scope; - -import org.springframework.batch.core.domain.JobParameters; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.config.Scope; -import org.springframework.core.Ordered; - -/** - * Scope for step context. Objects in this scope with <aop:scoped-proxy/> - * use the Spring container as an object factory, so there is only one instance - * of such a bean per executing step. - * - * @author Dave Syer - * - */ -public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { - - private int order = Ordered.LOWEST_PRECEDENCE; - - private Object mutex = new Object(); - - /** - * @param order the order value to set priority of callback execution for - * the {@link BeanFactoryPostProcessor} part of this scope bean. - */ - public void setOrder(int order) { - this.order = order; - } - - /* - * (non-Javadoc) - * @see org.springframework.core.Ordered#getOrder() - */ - public int getOrder() { - return order; - } - - private String name = "step"; - - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#get(java.lang.String, - * org.springframework.beans.factory.ObjectFactory) - */ - public Object get(String name, ObjectFactory objectFactory) { - StepContext context = getContext(); - Object scopedObject = context.getAttribute(name); - if (scopedObject == null) { - synchronized (mutex) { - scopedObject = context.getAttribute(name); - if (scopedObject == null) { - scopedObject = objectFactory.getObject(); - if (scopedObject instanceof StepContextAware) { - ((StepContextAware) scopedObject).setStepContext(context); - } - if (scopedObject instanceof JobParametersAware) { - try { - JobParameters jobParameters = context.getStepExecution().getJobExecution().getJobInstance() - .getJobParameters(); - ((JobParametersAware) scopedObject).setJobParameters(jobParameters); - } - catch (NullPointerException e) { - // ignore - } - } - context.setAttribute(name, scopedObject); - } - } - } - return scopedObject; - } - - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#getConversationId() - */ - public String getConversationId() { - StepContext context = getContext(); - return context.getIdentifier(); - } - - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String, - * java.lang.Runnable) - */ - public void registerDestructionCallback(String name, Runnable callback) { - StepContext context = getContext(); - context.registerDestructionCallback(name, callback); - } - - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#remove(java.lang.String) - */ - public Object remove(String name) { - StepContext context = getContext(); - return context.removeAttribute(name); - } - - /** - * Get an attribute accessor in the form of a {@link SimpleStepContext} that - * can be used to store scoped bean instances. - * - * @return the current step context which we can use as a scope storage - * medium - */ - private StepContext getContext() { - StepContext context = StepSynchronizationManager.getContext(); - if (context == null) { - throw new IllegalStateException("No context holder available for step scope"); - } - return context; - } - - /** - * Register this scope with the enclosing BeanFactory. - * - * @param beanFactory the BeanFactory to register with - * @throws BeansException if there is a problem. - */ - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { - beanFactory.registerScope(name, this); - } - - /** - * Public setter for the name property. This can then be used as a bean - * definition attribute, e.g. scope="step". Defaults to "step". - * - * @param name the name to set for this scope. - */ - public void setName(String name) { - this.name = name; - } - -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepSynchronizationManager.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepSynchronizationManager.java deleted file mode 100644 index 3d05718fb..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/StepSynchronizationManager.java +++ /dev/null @@ -1,76 +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.execution.scope; - -/** - * @author Dave Syer - * - */ -public class StepSynchronizationManager { - - private static final ThreadLocal contextHolder = new InheritableThreadLocal(); - - /** - * Getter for the current context.. - * - * @return the current {@link StepContext} or null if there is none - * (if we are not in a step). - */ - public static StepContext getContext() { - return (StepContext) contextHolder.get(); - } - - /** - * Method for registering a context - should only be used by - * {@link StepExecutor} implementations to ensure that {@link #getContext()} - * always returns the correct value. - * @param context the step context to register - */ - public static void register(StepContext context) { - StepSynchronizationManager.contextHolder.set(context); - } - - /** - * Method for de-registering the current context - should only be used by - * {@link StepExecutor} implementations to ensure that {@link #getContext()} - * always returns the correct value. - * - * @return the old value if there was one. - */ - public static StepContext close() { - StepContext oldSession = getContext(); - if (oldSession == null) { - return null; - } - oldSession.close(); - StepContext context = oldSession.getParent(); - StepSynchronizationManager.contextHolder.set(context); - return context; - } - - /** - * Used internally by {@link StepExecutor} implementations to clear the - * current context at the end of a batch. - * - * @return the old value if there was one. - */ - public static StepContext clear() { - StepContext context = getContext(); - StepSynchronizationManager.contextHolder.set(null); - return context; - } - -} diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/package.html b/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/package.html deleted file mode 100644 index d9e268e6d..000000000 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/scope/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

-Specific implementations of scope concerns. -

- - diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java index 6024e1023..df11dc8a4 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/job/SimpleJobTests.java @@ -38,7 +38,6 @@ import org.springframework.batch.execution.repository.dao.MapJobExecutionDao; import org.springframework.batch.execution.repository.dao.MapJobInstanceDao; import org.springframework.batch.execution.repository.dao.MapStepExecutionDao; import org.springframework.batch.execution.repository.dao.StepExecutionDao; -import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.batch.execution.step.AbstractStep; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.item.reader.AbstractItemReader; @@ -267,21 +266,6 @@ public class SimpleJobTests extends TestCase { "JobInterruptedException")); } - public void testStepContextInitialized() throws Exception { - - stepConfiguration1.setCallback(new Runnable() { - public void run() { - assertNotNull(StepSynchronizationManager.getContext().getStepExecution()); - list.add("asserted context"); - }; - }); - - job.execute(jobExecution); - assertEquals(2, list.size()); - assertTrue(list.contains("asserted context")); - - } - /* * Check JobRepository to ensure status is being saved. */ diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/JobParametersAwareStepScopeTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/JobParametersAwareStepScopeTests.java deleted file mode 100644 index 8ae094b97..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/JobParametersAwareStepScopeTests.java +++ /dev/null @@ -1,95 +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.execution.scope; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.domain.JobParameters; -import org.springframework.batch.execution.job.JobSupport; -import org.springframework.batch.execution.step.StepSupport; -import org.springframework.batch.repeat.synch.RepeatSynchronizationManager; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ObjectFactory; - -/** - * @author Dave Syer - * - */ -public class JobParametersAwareStepScopeTests extends TestCase { - - private StepScope scope = new StepScope(); - - private SimpleStepContext context; - - JobParameters parameters = new JobParameters(); - - /* - * (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1L), parameters, new JobSupport()), new Long(11L)); - context = new SimpleStepContext(jobExecution.createStepExecution(new StepSupport())); - StepSynchronizationManager.register(context); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - RepeatSynchronizationManager.clear(); - super.tearDown(); - } - - public void testInjection() throws Exception { - final TestBeanAware foo = new TestBeanAware(); - Object value = scope.get("foo", new ObjectFactory() { - public Object getObject() throws BeansException { - return foo; - } - }); - assertEquals(foo, value); - assertTrue(context.hasAttribute("foo")); - assertEquals(parameters, foo.getJobParameters()); - } - - public void testFailedInjection() throws Exception { - // Null JobInstance so no parameters - context.getStepExecution().getJobExecution().setJobInstance(null); - final TestBeanAware foo = new TestBeanAware(); - Object value = scope.get("foo", new ObjectFactory() { - public Object getObject() throws BeansException { - return foo; - } - }); - assertEquals(foo, value); - assertTrue(context.hasAttribute("foo")); - assertEquals(null, foo.getJobParameters()); - } - - public static class TestBeanAware implements JobParametersAware { - private JobParameters jobParameters; - public void setJobParameters(JobParameters jobParameters) { - this.jobParameters = jobParameters; - } - public JobParameters getJobParameters() { - return jobParameters; - } - } -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java deleted file mode 100644 index d58ccef19..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/SimpleStepContextTests.java +++ /dev/null @@ -1,130 +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.execution.scope; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.StepExecution; -import org.springframework.batch.execution.step.StepSupport; - -/** - * @author Dave Syer - * - */ -public class SimpleStepContextTests extends TestCase { - - private SimpleStepContext context = new SimpleStepContext(null, new SimpleStepContext(null)); - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.SimpleStepContext#StepScopeContext()}. - */ - public void testStepScopeContext() { - assertNull(new SimpleStepContext(null).getParent()); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.SimpleStepContext#getParent()}. - */ - public void testGetParent() { - assertNotNull(context.getParent()); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.SimpleStepContext#getStepExecution()}. - */ - public void testGetStepExecution() { - assertNull(context.getStepExecution()); - context = new SimpleStepContext(new StepExecution(new StepSupport("stepName"), null, null)); - assertNotNull(context.getStepExecution()); - } - - private List list = new ArrayList(); - - /** - * Test method for - * {@link org.springframework.batch.repeat.context.SimpleStepContext#registerDestructionCallback(java.lang.String, java.lang.Runnable)}. - */ - public void testDestructionCallbackSunnyDay() throws Exception { - SimpleStepContext context = new SimpleStepContext(null); - context.setAttribute("foo", "FOO"); - context.registerDestructionCallback("foo", new Runnable() { - public void run() { - list.add("bar"); - } - }); - context.close(); - assertEquals(1, list.size()); - assertEquals("bar", list.get(0)); - } - - /** - * Test method for - * {@link org.springframework.batch.repeat.context.SimpleStepContext#registerDestructionCallback(java.lang.String, java.lang.Runnable)}. - */ - public void testDestructionCallbackMissingAttribute() throws Exception { - SimpleStepContext context = new SimpleStepContext(null); - context.registerDestructionCallback("foo", new Runnable() { - public void run() { - list.add("bar"); - } - }); - context.close(); - // Yes the callback should be called even if the attribute is missing - - // for inner beans - assertEquals(1, list.size()); - } - - /** - * Test method for - * {@link org.springframework.batch.repeat.context.SimpleStepContext#registerDestructionCallback(java.lang.String, java.lang.Runnable)}. - */ - public void testDestructionCallbackWithException() throws Exception { - SimpleStepContext context = new SimpleStepContext(null); - context.setAttribute("foo", "FOO"); - context.setAttribute("bar", "BAR"); - context.registerDestructionCallback("bar", new Runnable() { - public void run() { - list.add("spam"); - throw new RuntimeException("fail!"); - } - }); - context.registerDestructionCallback("foo", new Runnable() { - public void run() { - list.add("bar"); - throw new RuntimeException("fail!"); - } - }); - try { - context.close(); - fail("Expected RuntimeException"); - } - catch (RuntimeException e) { - // We don't care which one was thrown... - assertEquals("fail!", e.getMessage()); - } - // ...but we do care that both were executed: - assertEquals(2, list.size()); - assertTrue(list.contains("bar")); - assertTrue(list.contains("spam")); - } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepContextAwareStepScopeTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepContextAwareStepScopeTests.java deleted file mode 100644 index 71c335a9a..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepContextAwareStepScopeTests.java +++ /dev/null @@ -1,181 +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.execution.scope; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.core.AttributeAccessor; - -/** - * @author Dave Syer - * - */ -public class StepContextAwareStepScopeTests extends TestCase { - - private static List list = new ArrayList(); - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - StepSynchronizationManager.clear(); - list.clear(); - } - - public void testScopedBean() throws Exception { - StepSynchronizationManager.register(new SimpleStepContext(null)); - ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass()); - TestBean bean = (TestBean) applicationContext.getBean("bean"); - assertNotNull(bean); - assertEquals("foo", bean.name); - } - - public void testScopedBeanWithDestroyCallback() throws Exception { - assertEquals(0, list.size()); - StepSynchronizationManager.register(new SimpleStepContext(null)); - ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass()); - TestBean bean = (TestBean) applicationContext.getBean("bean"); - assertNotNull(bean); - StepSynchronizationManager.close(); - assertEquals(1, list.size()); - } - - public void testScopedBeanWithAware() throws Exception { - StepContext context = new SimpleStepContext(null); - StepSynchronizationManager.register(context); - ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass()); - TestBeanAware bean = (TestBeanAware) applicationContext.getBean("aware"); - assertNotNull(bean); - assertEquals("bar", bean.name); - assertEquals(context, bean.context); - } - - public void testScopedBeanWithInner() throws Exception { - StepSynchronizationManager.register(new SimpleStepContext(null)); - ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( - "scope-tests.xml", getClass()); - TestBean bean = ((TestBean) applicationContext.getBean("inner")).child; - assertNotNull(bean); - assertEquals("bar", bean.name); - StepSynchronizationManager.close(); - assertEquals(1, list.size()); - } - - public void testScopedBeanWithProxy() throws Exception { - StepContext context = new SimpleStepContext(null); - StepSynchronizationManager.register(context); - ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass()); - TestBeanAware bean = (TestBeanAware) applicationContext.getBean("proxy"); - assertNotNull(bean); - // A scoped proxy is only accessible through public methods - assertEquals(null, bean.name); - assertEquals("spam", bean.getName()); - assertEquals(context, bean.getContext()); - } - - public void testScopedBeanWithProxyInThread() throws Exception { - StepSynchronizationManager.register(new SimpleStepContext(null)); - final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass()); - new Thread(new Runnable() { - public void run() { - TestBeanAware bean = (TestBeanAware) applicationContext.getBean("proxy"); - list.add(bean.getName()); - } - }).start(); - int count = 0; - while(list.size()==0 && count++ <10) { - Thread.sleep(100); - } - if (list.size()==0) { - fail("Scoped proxy was not created in child thread - maybe we need to use InheritableThreadLocal?"); - } - String name = (String) list.get(0); - assertEquals("spam", name); - } - - public void testScopedBeanWithTwoProxiesInThreads() throws Exception { - StepSynchronizationManager.register(new SimpleStepContext(null)); - final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("scope-tests.xml", getClass()); - new Thread(new Runnable() { - public void run() { - TestBeanAware bean = (TestBeanAware) applicationContext.getBean("proxy"); - int count = 0; - while(list.size()==0 && count++ <10) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - fail("Timeout waiting for other thread to add a bean to list."); - } - } - bean.getName(); - list.add(bean); - } - }).start(); - new Thread(new Runnable() { - public void run() { - TestBeanAware bean = (TestBeanAware) applicationContext.getBean("proxy"); - bean.getName(); - list.add(bean); - } - }).start(); - int count = 0; - while(list.size()<2 && count++ <10) { - Thread.sleep(100); - } - if (list.size()<2) { - fail("Scoped proxies were not created in child threads"); - } - TestBeanAware bean1 = (TestBeanAware) list.get(0); - TestBeanAware bean2 = (TestBeanAware) list.get(1); - assertEquals("spam", bean1.getName()); - assertSame(bean1.getLock(), bean2.getLock()); - } - - public static class TestBean { - String name; - TestBean child; - public void setName(String name) { - this.name = name; - } - public String getName() { - return name; - } - public void setChild(TestBean child) { - this.child = child; - } - public void close() { - list.add("close"); - } - } - - public static class TestBeanAware extends TestBean implements StepContextAware { - AttributeAccessor context; - Object lock = new Object(); - public void setStepContext(StepContext context) { - this.context = context; - } - public AttributeAccessor getContext() { - return context; - } - public Object getLock() { - return lock; - } - } -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java deleted file mode 100644 index 20054459b..000000000 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/scope/StepScopeTests.java +++ /dev/null @@ -1,211 +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.execution.scope; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.springframework.batch.core.domain.JobExecution; -import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.execution.job.JobSupport; -import org.springframework.batch.execution.step.StepSupport; -import org.springframework.batch.repeat.synch.RepeatSynchronizationManager; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.context.support.StaticApplicationContext; - -/** - * @author Dave Syer - * - */ -public class StepScopeTests extends TestCase { - - private StepScope scope = new StepScope(); - - private SimpleStepContext context; - - /* - * (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - JobExecution jobExecution = new JobExecution(new JobInstance(new Long(1L), null, new JobSupport()), new Long(11L)); - context = new SimpleStepContext(jobExecution.createStepExecution(new StepSupport())); - StepSynchronizationManager.register(context); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - RepeatSynchronizationManager.clear(); - super.tearDown(); - } - - public void testGetWithNoContext() throws Exception { - final String foo = "bar"; - StepSynchronizationManager.clear(); - try { - scope.get("foo", new ObjectFactory() { - public Object getObject() throws BeansException { - return foo; - } - }); - fail("Expected IllegalStateException"); - } - catch (IllegalStateException e) { - // expected - } - - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#get(java.lang.String, org.springframework.beans.factory.ObjectFactory)}. - */ - public void testGetWithNothingAlreadyThere() { - final String foo = "bar"; - Object value = scope.get("foo", new ObjectFactory() { - public Object getObject() throws BeansException { - return foo; - } - }); - assertEquals(foo, value); - assertTrue(context.hasAttribute("foo")); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#get(java.lang.String, org.springframework.beans.factory.ObjectFactory)}. - */ - public void testGetWithSomethingAlreadyThere() { - context.setAttribute("foo", "bar"); - Object value = scope.get("foo", new ObjectFactory() { - public Object getObject() throws BeansException { - return null; - } - }); - assertEquals("bar", value); - assertTrue(context.hasAttribute("foo")); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#get(java.lang.String, org.springframework.beans.factory.ObjectFactory)}. - */ - public void testGetWithSomethingAlreadyInParentContext() { - StepContext context = new SimpleStepContext(null); - StepSynchronizationManager.register(context); - context.setAttribute("foo", "bar"); - Object value = scope.get("foo", new ObjectFactory() { - public Object getObject() throws BeansException { - return null; - } - }); - assertEquals("bar", value); - assertTrue(context.hasAttribute("foo")); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#getConversationId()}. - */ - public void testGetConversationId() { - String id = scope.getConversationId(); - assertNotNull(id); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#getConversationId()}. - */ - public void testGetConversationIdFromAttribute() { - String id = scope.getConversationId(); - assertEquals("JOB_EXECUTION_ID:11", id); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#registerDestructionCallback(java.lang.String, java.lang.Runnable)}. - */ - public void testRegisterDestructionCallback() { - final List list = new ArrayList(); - context.setAttribute("foo", "bar"); - scope.registerDestructionCallback("foo", new Runnable() { - public void run() { - list.add("foo"); - } - }); - assertEquals(0, list.size()); - // When the context is closed, provided the attribute exists the - // callback is called... - context.close(); - assertEquals(1, list.size()); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#registerDestructionCallback(java.lang.String, java.lang.Runnable)}. - */ - public void testRegisterAnotherDestructionCallback() { - final List list = new ArrayList(); - context.setAttribute("foo", "bar"); - scope.registerDestructionCallback("foo", new Runnable() { - public void run() { - list.add("foo"); - } - }); - scope.registerDestructionCallback("foo", new Runnable() { - public void run() { - list.add("bar"); - } - }); - assertEquals(0, list.size()); - // When the context is closed, provided the attribute exists the - // callback is called... - context.close(); - assertEquals(2, list.size()); - } - - /** - * Test method for - * {@link org.springframework.batch.execution.scope.StepScope#remove(java.lang.String)}. - */ - public void testRemove() { - context.setAttribute("foo", "bar"); - scope.remove("foo"); - assertFalse(context.hasAttribute("foo")); - } - - public void testOrder() throws Exception { - assertEquals(Integer.MAX_VALUE, scope.getOrder()); - scope.setOrder(11); - assertEquals(11, scope.getOrder()); - } - - public void testName() throws Exception { - scope.setName("foo"); - StaticApplicationContext beanFactory = new StaticApplicationContext(); - scope.postProcessBeanFactory(beanFactory.getDefaultListableBeanFactory()); - String[] scopes = beanFactory.getDefaultListableBeanFactory().getRegisteredScopeNames(); - assertEquals(1, scopes.length); - assertEquals("foo", scopes[0]); - } - -} diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java index 5163ccee7..25b35f7d3 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/step/TaskletStepTests.java @@ -14,7 +14,6 @@ import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.listener.StepListenerSupport; import org.springframework.batch.core.tasklet.Tasklet; import org.springframework.batch.execution.job.JobSupport; -import org.springframework.batch.execution.scope.StepSynchronizationManager; import org.springframework.batch.execution.step.support.JobRepositorySupport; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.repeat.ExitStatus; @@ -63,6 +62,7 @@ public class TaskletStepTests extends TestCase { public void testSuccessfulExecutionWithStepContext() throws Exception { TaskletStep step = new TaskletStep(new StubTasklet(false, false, true), new JobRepositorySupport()); + step.afterPropertiesSet(); step.execute(stepExecution); assertNotNull(stepExecution.getStartTime()); assertEquals(ExitStatus.FINISHED, stepExecution.getExitStatus()); @@ -85,6 +85,7 @@ public class TaskletStepTests extends TestCase { throw new RuntimeException("foo"); } }); + step.afterPropertiesSet(); try { step.execute(stepExecution); fail("Expected BatchCriticalException"); @@ -130,13 +131,15 @@ public class TaskletStepTests extends TestCase { } } - private class StubTasklet implements Tasklet{ + private class StubTasklet extends StepListenerSupport implements Tasklet { private final boolean exitFailure; private final boolean throwException; private final boolean assertStepContext; + + private StepExecution stepExecution; public StubTasklet(boolean exitFailure, boolean throwException) { this(exitFailure, throwException, false); @@ -158,11 +161,15 @@ public class TaskletStepTests extends TestCase { } if (assertStepContext) { - assertNotNull(StepSynchronizationManager.getContext()); + assertNotNull(this.stepExecution); } return ExitStatus.FINISHED; } + + public void beforeStep(StepExecution stepExecution) { + this.stepExecution = stepExecution; + } } diff --git a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml index df984151d..6f982b789 100644 --- a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml @@ -12,9 +12,6 @@ - - - diff --git a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml index 14663032c..e88cc8a55 100644 --- a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml @@ -11,9 +11,6 @@ - - - @@ -122,9 +119,4 @@ class="org.springframework.batch.sample.domain.Person" scope="prototype" /> - - - - - diff --git a/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml index da9006b59..f7686be90 100644 --- a/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/compositeProcessorSampleJob.xml @@ -9,9 +9,6 @@ - - - @@ -40,9 +37,7 @@ - - + @@ -96,9 +91,4 @@ - - - - - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/fixedLengthImportJob.xml b/spring-batch-samples/src/main/resources/jobs/fixedLengthImportJob.xml index 2884e2eb4..628971361 100644 --- a/spring-batch-samples/src/main/resources/jobs/fixedLengthImportJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/fixedLengthImportJob.xml @@ -11,9 +11,6 @@ - - - @@ -46,9 +43,7 @@ - - + autowire-candidate="false"/> diff --git a/spring-batch-samples/src/main/resources/jobs/footballJob.xml b/spring-batch-samples/src/main/resources/jobs/footballJob.xml index c5f1fce51..19e99c941 100644 --- a/spring-batch-samples/src/main/resources/jobs/footballJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/footballJob.xml @@ -11,9 +11,6 @@ - - - @@ -65,9 +62,7 @@ - + class="org.springframework.batch.io.file.FlatFileItemReader"> @@ -84,9 +79,7 @@ - + class="org.springframework.batch.io.file.FlatFileItemReader"> @@ -103,9 +96,7 @@ - + class="org.springframework.batch.io.cursor.JdbcCursorItemReader"> - - - @@ -59,13 +56,9 @@ - + class="org.springframework.batch.io.cursor.HibernateCursorItemReader"> - - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml b/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml index 10fa5b71b..cb0e6b536 100644 --- a/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/ibatisJob.xml @@ -12,9 +12,6 @@ Example for iBATIS integration. - - - @@ -25,9 +22,7 @@ class="org.springframework.batch.sample.item.writer.CustomerCreditIncreaseWriter"> - + class="org.springframework.batch.sample.dao.IbatisCustomerCreditWriter"> - + class="org.springframework.batch.io.driving.IbatisDrivingQueryItemReader"> @@ -61,12 +54,4 @@ - - - - - - - - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml index 7dc728162..3ca00773f 100644 --- a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml @@ -11,9 +11,6 @@ - - - diff --git a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml b/spring-batch-samples/src/main/resources/jobs/multilineJob.xml index 4d2dc3e79..79e8def6d 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineJob.xml @@ -8,9 +8,6 @@ http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - - - @@ -24,9 +21,7 @@ - + class="org.springframework.batch.io.file.FlatFileItemWriter"> @@ -39,9 +34,7 @@ - + class="org.springframework.batch.io.file.FlatFileItemReader"> @@ -79,10 +72,4 @@ - - - - - - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderIo.xml b/spring-batch-samples/src/main/resources/jobs/multilineOrderIo.xml index fb9b02584..6ec447a37 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderIo.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineOrderIo.xml @@ -9,9 +9,7 @@ http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + class="org.springframework.batch.io.file.FlatFileItemReader"> @@ -24,9 +22,7 @@ class="org.springframework.batch.item.writer.ItemTransformerItemWriter"> - + class="org.springframework.batch.io.file.FlatFileItemWriter"> - - - @@ -143,6 +140,4 @@ - - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml index 8b499aa15..11a92e44c 100644 --- a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml @@ -10,10 +10,7 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> - - - - + diff --git a/spring-batch-samples/src/main/resources/jobs/restartSample.xml b/spring-batch-samples/src/main/resources/jobs/restartSample.xml index 4952868bd..e5e573737 100644 --- a/spring-batch-samples/src/main/resources/jobs/restartSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/restartSample.xml @@ -11,10 +11,6 @@ - - - - @@ -50,9 +46,7 @@ - + class="org.springframework.batch.io.file.FlatFileItemReader"> diff --git a/spring-batch-samples/src/main/resources/jobs/retrySample.xml b/spring-batch-samples/src/main/resources/jobs/retrySample.xml index 2a7f1400e..13f6240fd 100644 --- a/spring-batch-samples/src/main/resources/jobs/retrySample.xml +++ b/spring-batch-samples/src/main/resources/jobs/retrySample.xml @@ -11,9 +11,6 @@ - - - @@ -35,10 +32,9 @@ - - - + + \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml b/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml index df9e775ca..1ebf1fdc9 100644 --- a/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/rollbackJob.xml @@ -13,9 +13,6 @@ - - - @@ -56,9 +53,7 @@ - + class="org.springframework.batch.io.cursor.JdbcCursorItemReader"> @@ -69,9 +64,7 @@ - + class="org.springframework.batch.io.cursor.JdbcCursorItemReader"> diff --git a/spring-batch-samples/src/main/resources/jobs/simpleJob.xml b/spring-batch-samples/src/main/resources/jobs/simpleJob.xml index 65b74e8f8..a44a61eab 100644 --- a/spring-batch-samples/src/main/resources/jobs/simpleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/simpleJob.xml @@ -1,84 +1,78 @@ - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml index 04ff5401d..36c9fa5d5 100644 --- a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml @@ -12,9 +12,6 @@ - - - @@ -55,9 +52,7 @@ - + class="org.springframework.batch.io.cursor.JdbcCursorItemReader"> @@ -67,10 +62,7 @@ - - - + diff --git a/spring-batch-samples/src/main/resources/jobs/tradeJobIo.xml b/spring-batch-samples/src/main/resources/jobs/tradeJobIo.xml index f5adbf7f6..c5cdfdcd1 100644 --- a/spring-batch-samples/src/main/resources/jobs/tradeJobIo.xml +++ b/spring-batch-samples/src/main/resources/jobs/tradeJobIo.xml @@ -24,8 +24,7 @@ - + id="customerReportOutputSource"> - + id="fileInputTemplate"> diff --git a/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml b/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml index 4183e6d21..acc67ee8f 100644 --- a/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/xmlStaxJob.xml @@ -13,17 +13,12 @@ - - - - + class="org.springframework.batch.io.xml.StaxEventItemReader"> - + id="tradeStaxWriter"> @@ -77,7 +71,4 @@ - - - diff --git a/spring-batch-samples/src/main/resources/simple-container-definition.xml b/spring-batch-samples/src/main/resources/simple-container-definition.xml index 2f8d99570..35c1e49f2 100644 --- a/spring-batch-samples/src/main/resources/simple-container-definition.xml +++ b/spring-batch-samples/src/main/resources/simple-container-definition.xml @@ -11,10 +11,6 @@ - - - - - -