Class CompositeComponentImpl<C extends Component>

java.lang.Object
org.refcodes.component.CompositeComponentImpl<C>
Type Parameters:
C - The type of the Component supported by the CompositeComponentImpl.
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.
  • Constructor Details

    • CompositeComponentImpl

      public CompositeComponentImpl​(Collection<C> aComponents)
      Creates a CompositeComponentImpl containing the provided components. The ExecutionStrategy.JOIN ExecutionStrategy is used by default.
      Parameters:
      aComponents - The components to be managed by the CompositeComponentImpl.
    • CompositeComponentImpl

      public CompositeComponentImpl​(org.refcodes.controlflow.ExecutionStrategy aStrategy, Collection<C> aComponents)
      Creates a CompositeComponentImpl containing the provided components.
      Parameters:
      aStrategy - The ExecutionStrategy for executing the state change requests.
      aComponents - The components to be managed by the CompositeComponentImpl.
    • CompositeComponentImpl

      @SafeVarargs public CompositeComponentImpl​(C... aComponents)
      Creates a CompositeComponentImpl containing the provided components. The ExecutionStrategy.JOIN ExecutionStrategy is used by default.
      Parameters:
      aComponents - The components to be managed by the CompositeComponentImpl.
    • CompositeComponentImpl

      @SafeVarargs public CompositeComponentImpl​(org.refcodes.controlflow.ExecutionStrategy aStrategy, C... aComponents)
      Creates a CompositeComponentImpl containing the provided components.
      Parameters:
      aStrategy - The ExecutionStrategy for executing the state change requests.
      aComponents - The components to be managed by the CompositeComponentImpl.
  • Method Details

    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface Flushable
      Throws:
      IOException
    • decompose

      public void decompose()
      Decomposes the component. External resources might get deleted (such as files or DB schemas)!
      Specified by:
      decompose in interface Decomposeable
    • 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 a Component has been destroyed, then invoking any of that Component instance's methods (except the Destroyable.destroy() method) must throw an IllegalStateException as by definition a once destroyed Component is in the state of being destroyed which is irreversible.
      Specified by:
      destroy in interface Destroyable
    • stop

      public void stop() throws StopException
      Stops the component.
      Specified by:
      stop in interface Stoppable
      Throws:
      StopException - Thrown in case stopping fails.
    • resume

      public void resume() throws ResumeException
      Resumes the component.
      Specified by:
      resume in interface Resumable
      Throws:
      ResumeException - Thrown in case resuming fails.
    • pause

      public void pause() throws PauseException
      Pauses the component.
      Specified by:
      pause in interface Pausable
      Throws:
      PauseException - in case pausing fails.
    • start

      public void start() throws StartException
      Starts the component.
      Specified by:
      start in interface Startable
      Throws:
      StartException - Thrown in case starting fails.
    • initialize

      public void initialize() throws InitializeException
      Initialize the component.
      Specified by:
      initialize in interface Initializable
      Throws:
      InitializeException - Thrown in case initializing fails.
    • reset

      public void reset()
      Resets the component. No exception is thrown as decomposition must work always!
      Specified by:
      reset in interface Resetable
    • open

      public void open() throws IOException
      Open the component's connection(s).
      Specified by:
      open in interface Openable
      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 a IOException 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 interface Closable
      Throws:
      IOException - thrown in case closing failed.
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.refcodes.mixin.Disposable
    • getExecutionStrategy

      protected org.refcodes.controlflow.ExecutionStrategy getExecutionStrategy()
      Provides access to the ExecutionStrategy.
      Returns:
      The ExecutionStrategy being set.
    • getComponents

      protected Set<C> getComponents()
      Provides access to the Component instances.
      Returns:
      The Component instances being set.