Module org.refcodes.component
Package org.refcodes.component
Class CompositeComponentImpl<C extends Component>
java.lang.Object
org.refcodes.component.CompositeComponentImpl<C>
- Type Parameters:
C- The type of theComponentsupported by theCompositeComponentImpl.
- All Implemented Interfaces:
Flushable,Closable,CompositeComponent,Decomposeable,Destroyable,Flushable,Initializable,LifeCycleComponent,LinkComponent,Openable,Pausable,Resetable,Resumable,Startable,Stoppable,org.refcodes.mixin.Disposable
- Direct Known Subclasses:
CompositeComponentImpl.ExtendedCompositeComponentImpl
public class CompositeComponentImpl<C extends Component> extends Object implements CompositeComponent
The
CompositeComponentImpl is an implementation of the
CompositeComponent. To make sure that the state change requests you
require are supported by the managed Component instances, specify the
according type C as generic type argument.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompositeComponentImpl.ExtendedCompositeComponentImpl<C extends Component,CTX,CON>TheCompositeComponentImpl.ExtendedCompositeComponentImplis an implementation of theCompositeComponent.ExtendedCompositeComponent.Nested classes/interfaces inherited from interface org.refcodes.component.Closable
Closable.CloseAutomaton, Closable.CloseBuilder<B extends Closable.CloseBuilder<B>>Nested classes/interfaces inherited from interface org.refcodes.component.CompositeComponent
CompositeComponent.ExtendedCompositeComponent<CTX,CON>Nested classes/interfaces inherited from interface org.refcodes.component.Decomposeable
Decomposeable.DecomposeAutomatonNested classes/interfaces inherited from interface org.refcodes.component.Destroyable
Destroyable.DestroyAutomatonNested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.DisposedableNested classes/interfaces inherited from interface org.refcodes.component.Flushable
Flushable.FlushBuilder<B extends Flushable.FlushBuilder<B>>Nested classes/interfaces inherited from interface org.refcodes.component.Initializable
Initializable.InitializeAutomaton, Initializable.InitializeBuilder<B extends Initializable.InitializeBuilder<B>>, Initializable.UncheckedInitializableNested classes/interfaces inherited from interface org.refcodes.component.LifeCycleComponent
LifeCycleComponent.LifeCycleAutomaton, LifeCycleComponent.UncheckedLifeCycleComponentNested classes/interfaces inherited from interface org.refcodes.component.LinkComponent
LinkComponent.LinkAutomaton, LinkComponent.LinkComponentBuilder<B extends LinkComponent.LinkComponentBuilder<B>>Nested classes/interfaces inherited from interface org.refcodes.component.Openable
Openable.OpenAutomaton, Openable.OpenBuilder<B extends Openable.OpenBuilder<B>>Nested classes/interfaces inherited from interface org.refcodes.component.Pausable
Pausable.PauseAutomaton, Pausable.PauseBuilder<B extends Pausable.PauseBuilder<B>>, Pausable.UncheckedPausableNested classes/interfaces inherited from interface org.refcodes.component.Resumable
Resumable.ResumeAutomaton, Resumable.ResumeBuilder<B extends Resumable.ResumeBuilder<B>>, Resumable.UncheckedResumableNested classes/interfaces inherited from interface org.refcodes.component.Startable
Startable.StartAutomaton, Startable.StartBuilder<B extends Startable.StartBuilder<B>>, Startable.UncheckedStartableNested classes/interfaces inherited from interface org.refcodes.component.Stoppable
Stoppable.StopAutomaton, Stoppable.StopBuilder<B extends Stoppable.StopBuilder<B>>, Stoppable.UncheckedStoppable -
Constructor Summary
Constructors Constructor Description CompositeComponentImpl(C... aComponents)Creates aCompositeComponentImplcontaining the provided components.CompositeComponentImpl(Collection<C> aComponents)Creates aCompositeComponentImplcontaining the provided components.CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, C... aComponents)Creates aCompositeComponentImplcontaining the provided components.CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, Collection<C> aComponents)Creates aCompositeComponentImplcontaining the provided components. -
Method Summary
Modifier and Type Method Description voidclose()Closes the component's connection(s).voiddecompose()Decomposes the component.voiddestroy()Destroys the component.voiddispose()voidflush()protected Set<C>getComponents()Provides access to theComponentinstances.protected org.refcodes.controlflow.ExecutionStrategygetExecutionStrategy()Provides access to theExecutionStrategy.voidinitialize()Initialize the component.voidopen()Open the component's connection(s).voidpause()Pauses the component.voidreset()Resets the component.voidresume()Resumes the component.voidstart()Starts the component.voidstop()Stops the component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface org.refcodes.component.Flushable
flushUnchecked, isFlushableMethods inherited from interface org.refcodes.component.Initializable
initializeUncheckedMethods inherited from interface org.refcodes.component.Openable
openUncheckedMethods inherited from interface org.refcodes.component.Pausable
pauseUncheckedMethods inherited from interface org.refcodes.component.Resumable
resumeUncheckedMethods inherited from interface org.refcodes.component.Startable
startUncheckedMethods inherited from interface org.refcodes.component.Stoppable
stopUnchecked
-
Constructor Details
-
CompositeComponentImpl
Creates aCompositeComponentImplcontaining the provided components. TheExecutionStrategy.JOINExecutionStrategyis used by default.- Parameters:
aComponents- The components to be managed by theCompositeComponentImpl.
-
CompositeComponentImpl
public CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, Collection<C> aComponents)Creates aCompositeComponentImplcontaining the provided components.- Parameters:
aStrategy- TheExecutionStrategyfor executing the state change requests.aComponents- The components to be managed by theCompositeComponentImpl.
-
CompositeComponentImpl
Creates aCompositeComponentImplcontaining the provided components. TheExecutionStrategy.JOINExecutionStrategyis used by default.- Parameters:
aComponents- The components to be managed by theCompositeComponentImpl.
-
CompositeComponentImpl
@SafeVarargs public CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, C... aComponents)Creates aCompositeComponentImplcontaining the provided components.- Parameters:
aStrategy- TheExecutionStrategyfor executing the state change requests.aComponents- The components to be managed by theCompositeComponentImpl.
-
-
Method Details
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
decompose
public void decompose()Decomposes the component. External resources might get deleted (such as files or DB schemas)!- Specified by:
decomposein interfaceDecomposeable
-
destroy
public void destroy()Destroys the component. External resources might stay untouched! This should always be possible and must not throw any exception. In case aComponenthas been destroyed, then invoking any of thatComponentinstance's methods (except theDestroyable.destroy()method) must throw anIllegalStateExceptionas by definition a once destroyedComponentis in the state of being destroyed which is irreversible.- Specified by:
destroyin interfaceDestroyable
-
stop
Stops the component.- Specified by:
stopin interfaceStoppable- Throws:
StopException- Thrown in case stopping fails.
-
resume
Resumes the component.- Specified by:
resumein interfaceResumable- Throws:
ResumeException- Thrown in case resuming fails.
-
pause
Pauses the component.- Specified by:
pausein interfacePausable- Throws:
PauseException- in case pausing fails.
-
start
Starts the component.- Specified by:
startin interfaceStartable- Throws:
StartException- Thrown in case starting fails.
-
initialize
Initialize the component.- Specified by:
initializein interfaceInitializable- Throws:
InitializeException- Thrown in case initializing fails.
-
reset
public void reset()Resets the component. No exception is thrown as decomposition must work always! -
open
Open the component's connection(s).- Specified by:
openin interfaceOpenable- Throws:
IOException- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
-
close
Closes the component's connection(s). Throws aIOExceptionas upon close we may have to do things like flushing buffers which can fail (and would otherwise fail unhandled or even worse unnoticed).- Specified by:
closein interfaceClosable- Throws:
IOException- thrown in case closing failed.
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.refcodes.mixin.Disposable
-
getExecutionStrategy
protected org.refcodes.controlflow.ExecutionStrategy getExecutionStrategy()Provides access to theExecutionStrategy.- Returns:
- The
ExecutionStrategybeing set.
-
getComponents
Provides access to theComponentinstances.- Returns:
- The
Componentinstances being set.
-