Class RemoteChunkHandlerFactoryBean<T>
- java.lang.Object
- org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean<T>
- All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<ChunkHandler<T>>
public class RemoteChunkHandlerFactoryBean<T> extends java.lang.Object implements org.springframework.beans.factory.FactoryBean<ChunkHandler<T>>
Convenient factory bean for a chunk handler that also converts an existing chunk-oriented step into a remote chunk master. The idea is to lift the existing chunk processor out of a Step that works locally, and replace it with a one that writes chunks into a message channel. The existing step hands its business chunk processing responsibility over to the handler produced by the factory, which then needs to be set up as a worker on the other end of the channel the chunks are being sent to. Once this chunk handler is installed the application is playing the role of both the master and the slave listeners in the Remote Chunking pattern for the Step in question.- Author:
- Dave Syer, Mahmoud Ben Hassine
Constructor Summary
Constructors Constructor Description RemoteChunkHandlerFactoryBean()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChunkHandler<T>
getObject()
java.lang.Class<?>
getObjectType()
The type of object created by this factory.boolean
isSingleton()
Optimization for the bean factory (always returns true).void
setChunkWriter(ItemWriter<T> chunkWriter)
The item writer to be injected into the step.void
setStep(TaskletStep step)
The local step that is to be converted to a remote chunk master.void
setStepContributionSource(StepContributionSource stepContributionSource)
A source ofStepContribution
instances coming back from remote workers.protected void
updateStepContribution(StepContribution contribution, StepContributionSource stepContributionSource)
Update a StepContribution with all the data from a StepContributionSource.
Method Detail
setStep
public void setStep(TaskletStep step)
The local step that is to be converted to a remote chunk master.- Parameters:
step
- the step to set
setChunkWriter
public void setChunkWriter(ItemWriter<T> chunkWriter)
The item writer to be injected into the step. Its responsibility is to send chunks of items to remote workers. Usually in practice it will be aChunkMessageChannelItemWriter
.- Parameters:
chunkWriter
- the chunk writer to set
setStepContributionSource
public void setStepContributionSource(StepContributionSource stepContributionSource)
A source ofStepContribution
instances coming back from remote workers.- Parameters:
stepContributionSource
- the step contribution source to set (defaults to the chunk writer)
getObjectType
public java.lang.Class<?> getObjectType()
The type of object created by this factory. ReturnsChunkHandler
class.- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<T>
- See Also:
FactoryBean.getObjectType()
isSingleton
public boolean isSingleton()
Optimization for the bean factory (always returns true).- Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<T>
- See Also:
FactoryBean.isSingleton()
getObject
public ChunkHandler<T> getObject() throws java.lang.Exception
Builds aChunkHandler
from theChunkProcessor
extracted from thestep
provided. Also modifies the step to send chunks to the chunk handler via thechunk writer
.- Specified by:
getObject
in interfaceorg.springframework.beans.factory.FactoryBean<T>
- Throws:
java.lang.Exception
- See Also:
FactoryBean.getObject()
updateStepContribution
protected void updateStepContribution(StepContribution contribution, StepContributionSource stepContributionSource)
Update a StepContribution with all the data from a StepContributionSource. The filter and write counts plus the exit status will be updated to reflect the data in the source.- Parameters:
contribution
- the current contributionstepContributionSource
- a source of StepContributions