org.springframework.batch.integration.file
Class FileToMessagesJobFactoryBean

java.lang.Object
  extended by org.springframework.batch.integration.file.FileToMessagesJobFactoryBean
All Implemented Interfaces:
BeanNameAware, FactoryBean

public class FileToMessagesJobFactoryBean
extends Object
implements FactoryBean, BeanNameAware

A FactoryBean for a Job with a single step which just pumps messages from a file into a channel. The channel has to be a DirectChannel to ensure that failures propagate up to the step and fail the job execution. Normally this job will be used in conjunction with a JobLaunchingMessageHandler and a ResourcePayloadAsJobParameterStrategy, so that the user can just send a message to a request channel listing the files to be processed, and everything else just happens by magic. After a failure the job will be restarted just by sending it the same message.

Author:
Dave Syer

Constructor Summary
FileToMessagesJobFactoryBean()
           
 
Method Summary
 Object getObject()
          Creates a Job that can process a flat file or XML file into messages.
 Class<?> getObjectType()
          Always returns Job.
 boolean isSingleton()
          Always true.
 void setBeanName(String name)
           
 void setChannel(org.springframework.integration.channel.MessageChannel channel)
          Public setter for the channel.
 void setItemReader(ItemReader itemReader)
          Public setter for the ItemReader.
 void setJobRepository(JobRepository jobRepository)
          Public setter for the JobRepository.
 void setTransactionManager(PlatformTransactionManager transactionManager)
          Public setter for the PlatformTransactionManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileToMessagesJobFactoryBean

public FileToMessagesJobFactoryBean()
Method Detail

setBeanName

public void setBeanName(String name)
Specified by:
setBeanName in interface BeanNameAware

setItemReader

public void setItemReader(ItemReader itemReader)
Public setter for the ItemReader. Must be either a FlatFileItemReader or a StaxEventItemReader. In either case there is no need to set the resource property as it will be set by this factory.

Parameters:
itemReader - the itemReader to set

setChannel

public void setChannel(org.springframework.integration.channel.MessageChannel channel)
Public setter for the channel. Each item from the item reader will be sent to this channel.

Parameters:
channel - the channel to set

setJobRepository

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

Parameters:
jobRepository - the job repository to set

setTransactionManager

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

Parameters:
transactionManager - the transaction manager to set

getObject

public Object getObject()
                 throws Exception
Creates a Job that can process a flat file or XML file into messages. To launch the job will require only a JobParameters instance with a resource location as a URL.

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

getObjectType

public Class<?> getObjectType()
Always returns Job.

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

isSingleton

public boolean isSingleton()
Always true. TODO: should it be false?

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


Copyright © 2009 SpringSource. All Rights Reserved.