org.springframework.batch.core.step.item
Class SimpleStepFactoryBean<T,S>

java.lang.Object
  extended by org.springframework.batch.core.step.item.SimpleStepFactoryBean<T,S>
All Implemented Interfaces:
BeanNameAware, FactoryBean
Direct Known Subclasses:
FaultTolerantStepFactoryBean

public class SimpleStepFactoryBean<T,S>
extends Object
implements FactoryBean, BeanNameAware

Most common configuration options for simple steps should be found here. Use this factory bean instead of creating a Step implementation manually. This factory does not support configuration of fault-tolerant behavior, use appropriate subclass of this factory bean to configure skip or retry.

Author:
Dave Syer, Robert Kasanicky
See Also:
FaultTolerantStepFactoryBean

Field Summary
protected  Log logger
           
 
Constructor Summary
SimpleStepFactoryBean()
          Default constructor for SimpleStepFactoryBean.
 
Method Summary
protected  void applyConfiguration(TaskletStep step)
           
protected  SimpleChunkProcessor<T,S> configureChunkProcessor()
          Extension point for creating appropriate ChunkProcessor.
protected  SimpleChunkProvider<T> configureChunkProvider()
          Extension point for creating appropriate ChunkProvider.
protected  RepeatOperations getChunkOperations()
          Protected getter for the chunk operations to make them available in subclasses.
protected  ExceptionHandler getExceptionHandler()
          Protected getter for the ExceptionHandler.
protected  ItemProcessor<? super T,? extends S> getItemProcessor()
          Protected getter for the ItemProcessor for subclasses to use
protected  ItemReader<? extends T> getItemReader()
          Protected getter for the ItemReader for subclasses to use.
protected  ItemWriter<? super S> getItemWriter()
          Protected getter for the ItemWriter for subclasses to use
protected  StepListener[] getListeners()
          Protected getter for the StepListeners.
 String getName()
          Public getter for the name of the step.
 Object getObject()
          Create a Step from the configuration provided.
 Class<TaskletStep> getObjectType()
           
protected  RepeatOperations getStepOperations()
          Protected getter for the step operations to make them available in subclasses.
protected  TaskExecutor getTaskExecutor()
          Mkae the TaskExecutor available to subclasses
protected  TransactionAttribute getTransactionAttribute()
          Getter for the TransactionAttribute for subclasses only.
protected  boolean isReaderTransactionalQueue()
          Convenience method for subclasses.
 boolean isSingleton()
          Returns true by default, but in most cases a Step should not be treated as thread safe.
protected  void registerStreams(TaskletStep step, ItemStream[] streams)
          Register the streams with the step.
 void setAllowStartIfComplete(boolean allowStartIfComplete)
          Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the first time.
 void setBeanName(String name)
          Set the bean name property, which will become the name of the Step when it is created.
 void setChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy)
          Public setter for the CompletionPolicy applying to the chunk level.
 void setChunkOperations(RepeatOperations chunkOperations)
          Public setter for the chunkOperations.
 void setCommitInterval(int commitInterval)
          Set the commit interval.
 void setExceptionHandler(ExceptionHandler exceptionHandler)
          Public setter for the ExceptionHandler.
 void setIsolation(Isolation isolation)
           
 void setIsReaderTransactionalQueue(boolean isReaderTransactionalQueue)
          Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a rollback.
 void setItemProcessor(ItemProcessor<? super T,? extends S> itemProcessor)
           
 void setItemReader(ItemReader<? extends T> itemReader)
           
 void setItemWriter(ItemWriter<? super S> itemWriter)
           
 void setJobRepository(JobRepository jobRepository)
          Public setter for JobRepository.
 void setListeners(StepListener[] listeners)
          The listeners to inject into the Step.
 void setPropagation(Propagation propagation)
           
 void setSingleton(boolean singleton)
          Public setter for the singleton flag.
 void setStartLimit(int startLimit)
          Public setter for the start limit for the step.
 void setStepOperations(RepeatOperations stepOperations)
          Public setter for the stepOperations.
 void setStreams(ItemStream[] streams)
          The streams to inject into the Step.
 void setTaskExecutor(TaskExecutor taskExecutor)
          Public setter for the TaskExecutor.
 void setThrottleLimit(int throttleLimit)
          Public setter for the throttle limit.
 void setTransactionManager(PlatformTransactionManager transactionManager)
          Public setter for the PlatformTransactionManager.
 void setTransactionTimeout(int transactionTimeout)
          The timeout for an individual transaction in the step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Constructor Detail

SimpleStepFactoryBean

public SimpleStepFactoryBean()
Default constructor for SimpleStepFactoryBean.

Method Detail

setIsReaderTransactionalQueue

public void setIsReaderTransactionalQueue(boolean isReaderTransactionalQueue)
Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a rollback. The default is false and readers are assumed to be forward-only.

Parameters:
isReaderTransactionalQueue - the value of the flag

isReaderTransactionalQueue

protected boolean isReaderTransactionalQueue()
Convenience method for subclasses.

Returns:
true if the flag is set (default false)

setBeanName

public void setBeanName(String name)
Set the bean name property, which will become the name of the Step when it is created.

Specified by:
setBeanName in interface BeanNameAware
See Also:
BeanNameAware.setBeanName(java.lang.String)

getName

public String getName()
Public getter for the name of the step.

Returns:
the name

setTransactionTimeout

public void setTransactionTimeout(int transactionTimeout)
The timeout for an individual transaction in the step.

Parameters:
transactionTimeout - the transaction timeout to set, defaults to infinite

setPropagation

public void setPropagation(Propagation propagation)
Parameters:
propagation - the propagation to set for business transactions

setIsolation

public void setIsolation(Isolation isolation)
Parameters:
isolation - the isolation to set for business transactions

setStartLimit

public void setStartLimit(int startLimit)
Public setter for the start limit for the step.

Parameters:
startLimit - the startLimit to set

setAllowStartIfComplete

public void setAllowStartIfComplete(boolean allowStartIfComplete)
Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the first time.

Parameters:
allowStartIfComplete - the shouldAllowStartIfComplete to set

setItemReader

public void setItemReader(ItemReader<? extends T> itemReader)
Parameters:
itemReader - the ItemReader to set

setItemWriter

public void setItemWriter(ItemWriter<? super S> itemWriter)
Parameters:
itemWriter - the ItemWriter to set

setItemProcessor

public void setItemProcessor(ItemProcessor<? super T,? extends S> itemProcessor)
Parameters:
itemProcessor - the ItemProcessor to set

setStreams

public void setStreams(ItemStream[] streams)
The streams to inject into the Step. Any instance of ItemStream can be used, and will then receive callbacks at the appropriate stage in the step.

Parameters:
streams - an array of listeners

setListeners

public void setListeners(StepListener[] listeners)
The listeners to inject into the Step. Any instance of StepListener can be used, and will then receive callbacks at the appropriate stage in the step.

Parameters:
listeners - an array of listeners

getListeners

protected StepListener[] getListeners()
Protected getter for the StepListeners.

Returns:
the listeners

getItemReader

protected ItemReader<? extends T> getItemReader()
Protected getter for the ItemReader for subclasses to use.

Returns:
the itemReader

getItemWriter

protected ItemWriter<? super S> getItemWriter()
Protected getter for the ItemWriter for subclasses to use

Returns:
the itemWriter

getItemProcessor

protected ItemProcessor<? super T,? extends S> getItemProcessor()
Protected getter for the ItemProcessor for subclasses to use

Returns:
the itemProcessor

setJobRepository

public void setJobRepository(JobRepository jobRepository)
Public setter for JobRepository.

Parameters:
jobRepository - is a mandatory dependence (no default).

setTransactionManager

public void setTransactionManager(PlatformTransactionManager transactionManager)
Public setter for the PlatformTransactionManager.

Parameters:
transactionManager - the transaction manager to set

getTransactionAttribute

protected TransactionAttribute getTransactionAttribute()
Getter for the TransactionAttribute for subclasses only.

Returns:
the transactionAttribute

getObject

public final Object getObject()
                       throws Exception
Create a Step from the configuration provided.

Specified by:
getObject in interface FactoryBean
Throws:
Exception
See Also:
FactoryBean.getObject()

getObjectType

public Class<TaskletStep> getObjectType()
Specified by:
getObjectType in interface FactoryBean

isSingleton

public boolean isSingleton()
Returns true by default, but in most cases a Step should not be treated as thread safe. Clients are recommended to create a new step for each job execution.

Specified by:
isSingleton in interface FactoryBean
See Also:
FactoryBean.isSingleton()

setSingleton

public void setSingleton(boolean singleton)
Public setter for the singleton flag.

Parameters:
singleton - the value to set. Defaults to true.

setCommitInterval

public void setCommitInterval(int commitInterval)
Set the commit interval. Either set this or the chunkCompletionPolicy but not both.

Parameters:
commitInterval - 1 by default

setChunkCompletionPolicy

public void setChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy)
Public setter for the CompletionPolicy applying to the chunk level. A transaction will be committed when this policy decides to complete. Defaults to a SimpleCompletionPolicy with chunk size equal to the commitInterval property.

Parameters:
chunkCompletionPolicy - the chunkCompletionPolicy to set

getStepOperations

protected RepeatOperations getStepOperations()
Protected getter for the step operations to make them available in subclasses.

Returns:
the step operations

setStepOperations

public void setStepOperations(RepeatOperations stepOperations)
Public setter for the stepOperations.

Parameters:
stepOperations - the stepOperations to set

setChunkOperations

public void setChunkOperations(RepeatOperations chunkOperations)
Public setter for the chunkOperations.

Parameters:
chunkOperations - the chunkOperations to set

getChunkOperations

protected RepeatOperations getChunkOperations()
Protected getter for the chunk operations to make them available in subclasses.

Returns:
the step operations

setExceptionHandler

public void setExceptionHandler(ExceptionHandler exceptionHandler)
Public setter for the ExceptionHandler.

Parameters:
exceptionHandler - the exceptionHandler to set

getExceptionHandler

protected ExceptionHandler getExceptionHandler()
Protected getter for the ExceptionHandler.

Returns:
the ExceptionHandler

setTaskExecutor

public void setTaskExecutor(TaskExecutor taskExecutor)
Public setter for the TaskExecutor. If this is set, then it will be used to execute the chunk processing inside the Step.

Parameters:
taskExecutor - the taskExecutor to set

getTaskExecutor

protected TaskExecutor getTaskExecutor()
Mkae the TaskExecutor available to subclasses

Returns:
the taskExecutor to be used to execute chunks

setThrottleLimit

public void setThrottleLimit(int throttleLimit)
Public setter for the throttle limit. This limits the number of tasks queued for concurrent processing to prevent thread pools from being overwhelmed. Defaults to TaskExecutorRepeatTemplate.DEFAULT_THROTTLE_LIMIT.

Parameters:
throttleLimit - the throttle limit to set.

applyConfiguration

protected void applyConfiguration(TaskletStep step)
Parameters:
step -

registerStreams

protected void registerStreams(TaskletStep step,
                               ItemStream[] streams)
Register the streams with the step.

Parameters:
step - the TaskletStep
streams - the streams to register

configureChunkProvider

protected SimpleChunkProvider<T> configureChunkProvider()
Extension point for creating appropriate ChunkProvider. Return value must subclass SimpleChunkProvider due to listener registration.


configureChunkProcessor

protected SimpleChunkProcessor<T,S> configureChunkProcessor()
Extension point for creating appropriate ChunkProcessor. Return value must subclass SimpleChunkProcessor due to listener registration.



Copyright © 2009 SpringSource. All Rights Reserved.