BATCH-220: Complete rename StepHandler -> Tasklet

This commit is contained in:
dsyer
2008-08-28 11:37:50 +00:00
parent ad5b0010dd
commit 990e504583
28 changed files with 174 additions and 178 deletions

View File

@@ -5,7 +5,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.step.tasklet.StepHandler;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.core.AttributeAccessor;
@@ -13,19 +13,19 @@ import org.springframework.core.AttributeAccessor;
/**
* Dummy tasklet that retrieves message from the job execution context.
*/
public class DummyMessageReceivingStepHandler extends StepExecutionListenerSupport implements StepHandler {
public class DummyMessageReceivingTasklet extends StepExecutionListenerSupport implements Tasklet {
private static final Log logger = LogFactory.getLog(DummyMessageReceivingStepHandler.class);
private static final Log logger = LogFactory.getLog(DummyMessageReceivingTasklet.class);
private String receivedMessage = null;
public void beforeStep(StepExecution stepExecution) {
ExecutionContext ctx = stepExecution.getJobExecution().getExecutionContext();
receivedMessage = ctx.getString(DummyMessageSendingStepHandler.MESSAGE_KEY);
receivedMessage = ctx.getString(DummyMessageSendingTasklet.MESSAGE_KEY);
logger.info("Got message from context: " + receivedMessage);
}
public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception {
public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception {
return ExitStatus.FINISHED;
}

View File

@@ -2,10 +2,11 @@ package org.springframework.batch.sample.tasklet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.derby.impl.sql.compile.GetCurrentConnectionNode;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.step.tasklet.StepHandler;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.core.AttributeAccessor;
@@ -13,11 +14,11 @@ import org.springframework.core.AttributeAccessor;
/**
* Dummy tasklet that stores a message in the job execution context.
*/
public class DummyMessageSendingStepHandler extends StepExecutionListenerSupport implements StepHandler {
public class DummyMessageSendingTasklet extends StepExecutionListenerSupport implements Tasklet {
private static final Log logger = LogFactory.getLog(DummyMessageSendingStepHandler.class);
private static final Log logger = LogFactory.getLog(DummyMessageSendingTasklet.class);
public static final String MESSAGE_KEY = "DummyMessageSendingStepHandler.MESSAGE";
public static final String MESSAGE_KEY = DummyMessageSendingTasklet.class.getSimpleName()+".MESSAGE";
private String message = "Hello!";
@@ -28,7 +29,7 @@ public class DummyMessageSendingStepHandler extends StepExecutionListenerSupport
return null;
}
public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception {
public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception {
return ExitStatus.FINISHED;
}

View File

@@ -2,7 +2,7 @@ package org.springframework.batch.sample.tasklet;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.step.tasklet.StepHandler;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.AttributeAccessor;
@@ -15,11 +15,11 @@ import org.springframework.util.Assert;
*
* @author Robert Kasanicky
*/
public class FileDeletingStepHandler implements StepHandler, InitializingBean {
public class FileDeletingTasklet implements Tasklet, InitializingBean {
private Resource[] resources;
public ExitStatus handle(StepContribution contribution, AttributeAccessor attributes) throws Exception {
public ExitStatus execute(StepContribution contribution, AttributeAccessor attributes) throws Exception {
for (Resource resource : resources) {
boolean deleted = resource.getFile().delete();
if (!deleted) {

View File

@@ -12,21 +12,21 @@
<property name="steps">
<list>
<bean id="step1" parent="taskletStep">
<property name="stepHandler" ref="sender" />
<property name="tasklet" ref="sender" />
</bean>
<bean id="step2" parent="taskletStep">
<property name="stepHandler" ref="receiver" />
<property name="tasklet" ref="receiver" />
</bean>
</list>
</property>
</bean>
<bean id="sender"
class="org.springframework.batch.sample.tasklet.DummyMessageSendingStepHandler">
class="org.springframework.batch.sample.tasklet.DummyMessageSendingTasklet">
<property name="message" value="Hey!" />
</bean>
<bean id="receiver"
class="org.springframework.batch.sample.tasklet.DummyMessageReceivingStepHandler" />
class="org.springframework.batch.sample.tasklet.DummyMessageReceivingTasklet" />
</beans>

View File

@@ -17,15 +17,15 @@
<property name="steps">
<list>
<bean id="deleteFilesInDir" parent="taskletStep">
<property name="stepHandler">
<bean class="org.springframework.batch.sample.tasklet.FileDeletingStepHandler">
<property name="tasklet">
<bean class="org.springframework.batch.sample.tasklet.FileDeletingTasklet">
<property name="resources" value="file:target/test-outputs/test-dir/*" />
</bean>
</property>
</bean>
<bean id="executeSystemCommand" parent="taskletStep">
<property name="stepHandler">
<bean class="org.springframework.batch.core.step.tasklet.SystemCommandStepHandler">
<property name="tasklet">
<bean class="org.springframework.batch.core.step.tasklet.SystemCommandTasklet">
<property name="command" value="java -version" />
<!-- 5 second timeout for the command to complete -->
<property name="timeout" value="5000" />

View File

@@ -12,7 +12,7 @@
<property name="restartable" value="true" />
</bean>
<bean id="taskletStep" class="org.springframework.batch.core.step.tasklet.StepHandlerStep" abstract="true">
<bean id="taskletStep" class="org.springframework.batch.core.step.tasklet.TaskletStep" abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="jobRepository" ref="jobRepository" />
<property name="allowStartIfComplete" value="true" />

View File

@@ -3,8 +3,8 @@ package org.springframework.batch.sample;
import static org.junit.Assert.assertEquals;
import org.junit.runner.RunWith;
import org.springframework.batch.sample.tasklet.DummyMessageReceivingStepHandler;
import org.springframework.batch.sample.tasklet.DummyMessageSendingStepHandler;
import org.springframework.batch.sample.tasklet.DummyMessageReceivingTasklet;
import org.springframework.batch.sample.tasklet.DummyMessageSendingTasklet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -14,10 +14,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class JobExecutionContextSampleFunctionalTests extends AbstractValidatingBatchLauncherTests {
@Autowired
private DummyMessageSendingStepHandler sender;
private DummyMessageSendingTasklet sender;
@Autowired
private DummyMessageReceivingStepHandler receiver;
private DummyMessageReceivingTasklet receiver;
protected void validatePostConditions() throws Exception {
assertEquals(sender.getMessage(), receiver.getReceivedMessage());