类 AsyncItemProcessor<I,O>
- java.lang.Object
- org.springframework.batch.integration.async.AsyncItemProcessor<I,O>
- 类型参数:
I
- the input object typeO
- the output object type (will be wrapped in a Future)
- 所有已实现的接口:
ItemProcessor<I,java.util.concurrent.Future<O>>
,org.springframework.beans.factory.InitializingBean
public class AsyncItemProcessor<I,O> extends java.lang.Object implements ItemProcessor<I,java.util.concurrent.Future<O>>, org.springframework.beans.factory.InitializingBean
AnItemProcessor
that delegates to a nested processor and in the background. To allow for background processing the return value from the processor is aFuture
which needs to be unpacked before the item can be used by a client. Because theFuture
is typically unwrapped in theItemWriter
, there are lifecycle and stats limitations (since the framework doesn't know what the result of the processor is). While not an exhaustive list, things likeStepExecution.filterCount
will not reflect the number of filtered items andItemProcessListener.onProcessError(Object, Exception)
will not be called.- 作者:
- Dave Syer
- 另请参阅:
AsyncItemWriter
构造器概要
构造器 构造器 说明 AsyncItemProcessor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Check mandatory properties (thesetDelegate(ItemProcessor)
).java.util.concurrent.Future<O>
process(I item)
Transform the input by delegating to the provided item processor.void
setDelegate(ItemProcessor<I,O> delegate)
TheItemProcessor
to use to delegate processing to in a background thread.void
setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
TheTaskExecutor
to use to allow the item processing to proceed in the background.
构造器详细资料
AsyncItemProcessor
public AsyncItemProcessor()
方法详细资料
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
Check mandatory properties (thesetDelegate(ItemProcessor)
).- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 抛出:
java.lang.Exception
- 另请参阅:
InitializingBean.afterPropertiesSet()
setDelegate
public void setDelegate(ItemProcessor<I,O> delegate)
TheItemProcessor
to use to delegate processing to in a background thread.- 参数:
delegate
- theItemProcessor
to use as a delegate
setTaskExecutor
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
TheTaskExecutor
to use to allow the item processing to proceed in the background. Defaults to aSyncTaskExecutor
so no threads are created unless this is overridden.- 参数:
taskExecutor
- aTaskExecutor
process
public java.util.concurrent.Future<O> process(I item) throws java.lang.Exception
Transform the input by delegating to the provided item processor. The return value is wrapped in aFuture
so that clients can unpack it later.- 指定者:
process
在接口中ItemProcessor<I,O>
- 参数:
item
- to be processed- 返回:
- potentially modified or new item for continued processing,
null
if processing of the provided item should not continue. - 抛出:
java.lang.Exception
- thrown if exception occurs during processing.- 另请参阅:
ItemProcessor.process(Object)