Class AbstractComponentComposite<C extends Component>

java.lang.Object
org.refcodes.component.AbstractComponentComposite<C>
Type Parameters:
C - The type of the Component supported by the AbstractComponentComposite.
All Implemented Interfaces:
Flushable, Closable, ComponentComposite, Decomposable, Destroyable, Flushable, Initializable, LifecycleComponent, LinkComponent, Openable, Pausable, Resumable, Startable, Stoppable, org.refcodes.mixin.Disposable, org.refcodes.mixin.Resetable
Direct Known Subclasses:
AbstractComponentComposite.ExtendedCompositeComponentImpl

public abstract class AbstractComponentComposite<C extends Component> extends Object implements ComponentComposite
The AbstractComponentComposite is an implementation of the ComponentComposite. 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

    • AbstractComponentComposite

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

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

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

      @SafeVarargs public AbstractComponentComposite(org.refcodes.controlflow.ExecutionStrategy aStrategy, C... aComponents)
      Creates a AbstractComponentComposite containing the provided components.
      Parameters:
      aStrategy - The ExecutionStrategy for executing the state change requests.
      aComponents - The components to be managed by the AbstractComponentComposite.
  • 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 Decomposable
    • 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()
      Specified by:
      reset in interface org.refcodes.mixin.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.