001         package com.croftsoft.core.lang.lifecycle;
002    
003         import com.croftsoft.core.lang.NullArgumentException;
004    
005         /*********************************************************************
006         * A Lifecycle using interface composition.
007         *
008         * @version
009         *   $Id: CompositeLifecycle.java,v 1.1 2006/01/03 19:40:08 croft Exp $
010         * @since
011         *   2006-01-03
012         * @author
013         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
014         *********************************************************************/
015    
016         public final class  CompositeLifecycle
017           implements Lifecycle
018         //////////////////////////////////////////////////////////////////////
019         //////////////////////////////////////////////////////////////////////
020         {
021    
022         private final Initializable [ ]  initializables;
023         
024         private final Startable     [ ]  startables;
025         
026         private final Stoppable     [ ]  stoppables;
027         
028         private final Destroyable   [ ]  destroyables;
029    
030         //////////////////////////////////////////////////////////////////////
031         //////////////////////////////////////////////////////////////////////
032    
033         public  CompositeLifecycle (
034           final Initializable [ ]  initializables,       
035           final Startable     [ ]  startables,       
036           final Stoppable     [ ]  stoppables,       
037           final Destroyable   [ ]  destroyables )
038         //////////////////////////////////////////////////////////////////////
039         {
040           NullArgumentException.check (
041             this.initializables = initializables );
042           
043           NullArgumentException.check ( this.startables   = startables   );
044           
045           NullArgumentException.check ( this.stoppables   = stoppables   );
046           
047           NullArgumentException.check ( this.destroyables = destroyables );
048         }
049    
050         //////////////////////////////////////////////////////////////////////
051         //////////////////////////////////////////////////////////////////////
052    
053         public void  init    ( ) { LifecycleLib.init   ( initializables ); }
054           
055         public void  start   ( ) { LifecycleLib.start   ( startables    ); }
056           
057         public void  stop    ( ) { LifecycleLib.stop    ( stoppables    ); }
058           
059         public void  destroy ( ) { LifecycleLib.destroy ( destroyables  ); }
060           
061         //////////////////////////////////////////////////////////////////////
062         //////////////////////////////////////////////////////////////////////
063         }