Module org.refcodes.interceptor
Package org.refcodes.interceptor
Class CompositeSequentialInterceptorImpl<WP>
- java.lang.Object
-
- org.refcodes.interceptor.CompositeSequentialInterceptorImpl<WP>
-
- Type Parameters:
WP
- The work piece which is being passed to the contained interceptors one after the other and which is processed by the interceptors.
- All Implemented Interfaces:
Flushable
,org.refcodes.component.Closable
,org.refcodes.component.CompositeComponent
,org.refcodes.component.Decomposeable
,org.refcodes.component.Destroyable
,org.refcodes.component.Flushable
,org.refcodes.component.Initializable
,org.refcodes.component.LifecycleComponent
,org.refcodes.component.LinkComponent
,org.refcodes.component.Openable
,org.refcodes.component.Pausable
,org.refcodes.component.Resetable
,org.refcodes.component.Resumable
,org.refcodes.component.Startable
,org.refcodes.component.Stoppable
,Interceptor<WP>
,org.refcodes.mixin.Disposable
public class CompositeSequentialInterceptorImpl<WP> extends Object implements Interceptor<WP>, org.refcodes.component.CompositeComponent
A compound sequential interceptor which is passing the work piece from one contained interceptor to the next in the order in which them were passed. In case any of the contained interceptors returns flags the processing of the work piece to be "finished" (in itsdoIntercept(Object)
method it returns true), then this compound sequential interceptor returns true.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.CompositeComponent
org.refcodes.component.CompositeComponent.ExtendedCompositeComponent<CTX extends Object,CON extends Object>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Decomposeable
org.refcodes.component.Decomposeable.DecomposeAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
org.refcodes.component.Destroyable.DestroyAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.Disposedable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Flushable
org.refcodes.component.Flushable.FlushBuilder<B extends org.refcodes.component.Flushable.FlushBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Initializable
org.refcodes.component.Initializable.InitializeAutomaton, org.refcodes.component.Initializable.InitializeBuilder<B extends org.refcodes.component.Initializable.InitializeBuilder<B>>, org.refcodes.component.Initializable.UncheckedInitializable
-
Nested classes/interfaces inherited from interface org.refcodes.component.LifecycleComponent
org.refcodes.component.LifecycleComponent.LifecycleAutomaton, org.refcodes.component.LifecycleComponent.UncheckedLifecycleComponent
-
Nested classes/interfaces inherited from interface org.refcodes.component.LinkComponent
org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Openable
org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Pausable
org.refcodes.component.Pausable.PauseAutomaton, org.refcodes.component.Pausable.PauseBuilder<B extends org.refcodes.component.Pausable.PauseBuilder<B>>, org.refcodes.component.Pausable.UncheckedPausable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Resumable
org.refcodes.component.Resumable.ResumeAutomaton, org.refcodes.component.Resumable.ResumeBuilder<B extends org.refcodes.component.Resumable.ResumeBuilder<B>>, org.refcodes.component.Resumable.UncheckedResumable
-
-
Constructor Summary
Constructors Constructor Description CompositeSequentialInterceptorImpl(boolean isContinueOnFinished, boolean isContinueOnError, Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
.CompositeSequentialInterceptorImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, boolean isContinueOnFinished, boolean isContinueOnError, Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
.CompositeSequentialInterceptorImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
.CompositeSequentialInterceptorImpl(Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
decompose()
void
destroy()
void
dispose()
boolean
doIntercept(WP aWorkPiece)
This method is invoked with a work as argument.void
flush()
void
initialize()
void
open()
void
pause()
void
reset()
void
resume()
void
start()
void
stop()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
CompositeSequentialInterceptorImpl
@SafeVarargs public CompositeSequentialInterceptorImpl(Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
.- Parameters:
aInterceptors
- The interceptors to be invoked by the compound sequential interceptor.
-
CompositeSequentialInterceptorImpl
@SafeVarargs public CompositeSequentialInterceptorImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
.- Parameters:
aComponentExecutionStrategy
- The strategy on how to invoke the state change requests (as of theCompositeComponent
) defined methods) on the herein containedComponent
instances. CAUTION: The strategy does not affect on how thedoIntercept(Object)
methods of the herein contained instances are invoked.aInterceptors
- The interceptors to be invoked by the compound sequential interceptor.
-
CompositeSequentialInterceptorImpl
@SafeVarargs public CompositeSequentialInterceptorImpl(boolean isContinueOnFinished, boolean isContinueOnError, Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
. The sequential interceptor can be configured to continue the processing sequence even in case aWorkPieceException
was thrown or even if a containing interceptor signaled "finished" after processing the work piece (by returning true" after invocation of the methoddoIntercept(Object)
).- Parameters:
isContinueOnFinished
- True in case all subsequent interceptors are to be processed even if an interceptor signaled "finished" after processing the work piece.isContinueOnError
- True in case all subsequent interceptors are to be processed even if an interceptor signaled an error after processing the work piece (by throwing anWorkPieceException
).aInterceptors
- The interceptors to be invoked by the compound sequential interceptor.
-
CompositeSequentialInterceptorImpl
@SafeVarargs public CompositeSequentialInterceptorImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, boolean isContinueOnFinished, boolean isContinueOnError, Interceptor<WP>... aInterceptors)
Constructs the sequential interceptor which contains a list of interceptors being invoked in the order in which them were added upon calling the methoddoIntercept(Object)
. The sequential interceptor can be configured to continue the processing sequence even in case aWorkPieceException
was thrown or even if a containing interceptor signaled "finished" after processing the work piece (by returning true" after invocation of the methoddoIntercept(Object)
).- Parameters:
aComponentExecutionStrategy
- The strategy on how to invoke the state change requests (as of theCompositeComponent
) defined methods) on the herein containedComponent
instances. CAUTION: The strategy does not affect on how thedoIntercept(Object)
methods of the herein contained instances are invoked.isContinueOnFinished
- True in case all subsequent interceptors are to be processed even if an interceptor signaled "finished" after processing the work piece.isContinueOnError
- True in case all subsequent interceptors are to be processed even if an interceptor signaled an error after processing the work piece (by throwing anWorkPieceException
).aInterceptors
- The interceptors to be invoked by the compound sequential interceptor.
-
-
Method Detail
-
doIntercept
public boolean doIntercept(WP aWorkPiece) throws WorkPieceException
This method is invoked with a work as argument. The method processes the work piece in order to finish the work piece. In case the interceptor is able to finish the the work piece then this is indicated by returning true. In case false is returned, then the work piece is considered not to be finished.- Specified by:
doIntercept
in interfaceInterceptor<WP>
- Parameters:
aWorkPiece
- The work piece which is to be processed by the interceptor.- Returns:
- True in case the interceptor managed to "finish" the work piece. In such a case subsequent interceptors may not be required to be invoked. In such a case the interceptor signals "finished". In case the interceptor did not finish the work piece or is unsure whether the work piece is finished, then false is returned.
- Throws:
WorkPieceException
- In case the interceptor was not able to work with the provided work piece, then an according work piece exception is thrown.
-
initialize
public void initialize() throws org.refcodes.component.InitializeException
- Specified by:
initialize
in interfaceorg.refcodes.component.Initializable
- Throws:
org.refcodes.component.InitializeException
-
start
public void start() throws org.refcodes.component.StartException
- Specified by:
start
in interfaceorg.refcodes.component.Startable
- Throws:
org.refcodes.component.StartException
-
pause
public void pause() throws org.refcodes.component.PauseException
- Specified by:
pause
in interfaceorg.refcodes.component.Pausable
- Throws:
org.refcodes.component.PauseException
-
resume
public void resume() throws org.refcodes.component.ResumeException
- Specified by:
resume
in interfaceorg.refcodes.component.Resumable
- Throws:
org.refcodes.component.ResumeException
-
stop
public void stop() throws org.refcodes.component.StopException
- Specified by:
stop
in interfaceorg.refcodes.component.Stoppable
- Throws:
org.refcodes.component.StopException
-
decompose
public void decompose()
- Specified by:
decompose
in interfaceorg.refcodes.component.Decomposeable
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceorg.refcodes.component.Flushable
- Throws:
IOException
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceorg.refcodes.component.Destroyable
-
reset
public void reset()
- Specified by:
reset
in interfaceorg.refcodes.component.Resetable
-
open
public void open() throws IOException
- Specified by:
open
in interfaceorg.refcodes.component.Openable
- Throws:
IOException
-
close
public void close()
- Specified by:
close
in interfaceorg.refcodes.component.Closable
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
-