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 theComponent
supported 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
TheCompositeComponentImpl
is an implementation of theCompositeComponent
. To make sure that the state change requests you require are supported by the managedComponent
instances, specify the according typeC
as generic type argument.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompositeComponentImpl.ExtendedCompositeComponentImpl<C extends Component,CTX,CON>
TheCompositeComponentImpl.ExtendedCompositeComponentImpl
is 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.DecomposeAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
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
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.UncheckedInitializable
-
Nested classes/interfaces inherited from interface org.refcodes.component.LifeCycleComponent
LifeCycleComponent.LifeCycleAutomaton, LifeCycleComponent.UncheckedLifeCycleComponent
-
Nested 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.UncheckedPausable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Resumable
Resumable.ResumeAutomaton, Resumable.ResumeBuilder<B extends Resumable.ResumeBuilder<B>>, Resumable.UncheckedResumable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Startable
Startable.StartAutomaton, Startable.StartBuilder<B extends Startable.StartBuilder<B>>, Startable.UncheckedStartable
-
Nested 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 aCompositeComponentImpl
containing the provided components.CompositeComponentImpl(Collection<C> aComponents)
Creates aCompositeComponentImpl
containing the provided components.CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, C... aComponents)
Creates aCompositeComponentImpl
containing the provided components.CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, Collection<C> aComponents)
Creates aCompositeComponentImpl
containing the provided components.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component's connection(s).void
decompose()
Decomposes the component.void
destroy()
Destroys the component.void
dispose()
void
flush()
protected Set<C>
getComponents()
Provides access to theComponent
instances.protected org.refcodes.controlflow.ExecutionStrategy
getExecutionStrategy()
Provides access to theExecutionStrategy
.void
initialize()
Initialize the component.void
open()
Open the component's connection(s).void
pause()
Pauses the component.void
reset()
Resets the component.void
resume()
Resumes the component.void
start()
Starts the component.void
stop()
Stops the component.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
Methods inherited from interface org.refcodes.component.Flushable
flushUnchecked, isFlushable
-
Methods inherited from interface org.refcodes.component.Initializable
initializeUnchecked
-
Methods inherited from interface org.refcodes.component.Openable
openUnchecked
-
Methods inherited from interface org.refcodes.component.Pausable
pauseUnchecked
-
Methods inherited from interface org.refcodes.component.Resumable
resumeUnchecked
-
Methods inherited from interface org.refcodes.component.Startable
startUnchecked
-
Methods inherited from interface org.refcodes.component.Stoppable
stopUnchecked
-
-
-
-
Constructor Detail
-
CompositeComponentImpl
public CompositeComponentImpl(Collection<C> aComponents)
Creates aCompositeComponentImpl
containing the provided components. TheExecutionStrategy.JOIN
ExecutionStrategy
is used by default.- Parameters:
aComponents
- The components to be managed by theCompositeComponentImpl
.
-
CompositeComponentImpl
public CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, Collection<C> aComponents)
Creates aCompositeComponentImpl
containing the provided components.- Parameters:
aStrategy
- TheExecutionStrategy
for executing the state change requests.aComponents
- The components to be managed by theCompositeComponentImpl
.
-
CompositeComponentImpl
@SafeVarargs public CompositeComponentImpl(C... aComponents)
Creates aCompositeComponentImpl
containing the provided components. TheExecutionStrategy.JOIN
ExecutionStrategy
is used by default.- Parameters:
aComponents
- The components to be managed by theCompositeComponentImpl
.
-
CompositeComponentImpl
@SafeVarargs public CompositeComponentImpl(org.refcodes.controlflow.ExecutionStrategy aStrategy, C... aComponents)
Creates aCompositeComponentImpl
containing the provided components.- Parameters:
aStrategy
- TheExecutionStrategy
for executing the state change requests.aComponents
- The components to be managed by theCompositeComponentImpl
.
-
-
Method Detail
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
-
decompose
public void decompose()
Decomposes the component. External resources might get deleted (such as files or DB schemas)!- Specified by:
decompose
in 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 aComponent
has been destroyed, then invoking any of thatComponent
instance's methods (except theDestroyable.destroy()
method) must throw anIllegalStateException
as by definition a once destroyedComponent
is in the state of being destroyed which is irreversible.- Specified by:
destroy
in interfaceDestroyable
-
stop
public void stop() throws StopException
Stops the component.- Specified by:
stop
in interfaceStoppable
- Throws:
StopException
- Thrown in case stopping fails.
-
resume
public void resume() throws ResumeException
Resumes the component.- Specified by:
resume
in interfaceResumable
- Throws:
ResumeException
- Thrown in case resuming fails.
-
pause
public void pause() throws PauseException
Pauses the component.- Specified by:
pause
in interfacePausable
- Throws:
PauseException
- in case pausing fails.
-
start
public void start() throws StartException
Starts the component.- Specified by:
start
in interfaceStartable
- Throws:
StartException
- Thrown in case starting fails.
-
initialize
public void initialize() throws InitializeException
Initialize the component.- Specified by:
initialize
in 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
public void open() throws IOException
Open the component's connection(s).- Specified by:
open
in interfaceOpenable
- Throws:
IOException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
-
close
public void close() throws IOException
Closes the component's connection(s). Throws aIOException
as 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:
close
in interfaceClosable
- Throws:
IOException
- thrown in case closing failed.
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
getExecutionStrategy
protected org.refcodes.controlflow.ExecutionStrategy getExecutionStrategy()
Provides access to theExecutionStrategy
.- Returns:
- The
ExecutionStrategy
being set.
-
-