avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util ComponentStateValidator.java
Date Wed, 26 Jun 2002 13:36:03 GMT
bloritsch    2002/06/26 06:36:03

  Modified:    util/src/java/org/apache/excalibur/util
                        ComponentStateValidator.java
  Log:
  update ComponentValidator
  
  Revision  Changes    Path
  1.3       +58 -11    jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util/ComponentStateValidator.java
  
  Index: ComponentStateValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/util/src/java/org/apache/excalibur/util/ComponentStateValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ComponentStateValidator.java	2 May 2002 16:54:22 -0000	1.2
  +++ ComponentStateValidator.java	26 Jun 2002 13:36:03 -0000	1.3
  @@ -12,6 +12,7 @@
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.activity.Suspendable;
   import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.component.Recomposable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Reconfigurable;
  @@ -41,10 +42,11 @@
       private static final long LOGGABLE = 0x00000002;
       private static final long CONTEXTUALIZABLE = 0x00000004;
       private static final long COMPOSABLE = 0x00000008;
  -    private static final long CONFIGURABLE = 0x00000010;
  -    private static final long PARAMETERIZABLE = 0x00000020;
  -    private static final long INITIALIZABLE = 0x00000040;
  -    private static final long STARTABLE = 0x00000060;
  +    private static final long SERVICEABLE = 0x00000010;
  +    private static final long CONFIGURABLE = 0x00000020;
  +    private static final long PARAMETERIZABLE = 0x00000040;
  +    private static final long INITIALIZABLE = 0x00000080;
  +    private static final long STARTABLE = 0x00000100;
       private static final long SUSPENDABLE = 0x00001000;
       private static final long RECONTEXTUALIZABLE = 0x00002000;
       private static final long RECOMPOSABLE = 0x00004000;
  @@ -55,11 +57,12 @@
       private static final long ENABLE_LOGGING = 0x00000001;
       private static final long SET_LOGGER = 0x00000002;
       private static final long CONTEXTUALIZE = 0x00000004;
  -    private static final long COMPOSE = 0x00000008;
  -    private static final long CONFIGURE = 0x00000010;
  -    private static final long PARAMETERIZE = 0x00000020;
  -    private static final long INITIALIZE = 0x00000040;
  -    private static final long START = 0x00000080;
  +    private static final long SERVICE = 0x00000008;
  +    private static final long COMPOSE = 0x00000010;
  +    private static final long CONFIGURE = 0x00000020;
  +    private static final long PARAMETERIZE = 0x00000040;
  +    private static final long INITIALIZE = 0x00000080;
  +    private static final long START = 0x00000100;
       private static final long INIT_COMPLETE = 0x00000400;
   
       // Active Service Methods
  @@ -75,7 +78,7 @@
   
       // Masks
       private static final long INIT_MASK = ENABLE_LOGGING | SET_LOGGER |
  -        CONTEXTUALIZE | COMPOSE | CONFIGURE | PARAMETERIZE | INITIALIZE |
  +        CONTEXTUALIZE | COMPOSE | SERVICE | CONFIGURE | PARAMETERIZE | INITIALIZE |
           START;
   
       private final long m_interfaces;
  @@ -112,9 +115,20 @@
               interfaces |= CONTEXTUALIZABLE;
               methods |= CONTEXTUALIZE;
           }
  +        
  +        if( object instanceof Serviceable )
  +        {
  +            interfaces |= SERVICEABLE;
  +            methods |= SERVICE;
  +        }
   
           if( object instanceof Composable )
           {
  +            if ( (interfaces & SERVICEABLE) > 0 )
  +            {
  +                throw new IllegalStateException("Cannot implement Composable and Serviceable
together");
  +            }
  +
               interfaces |= COMPOSABLE;
               methods |= COMPOSE;
           }
  @@ -193,6 +207,10 @@
           {
               return Contextualizable.class.getName();
           }
  +        else if( interfaceId == SERVICEABLE )
  +        {
  +            return Serviceable.class.getName();
  +        }
           else if( interfaceId == COMPOSABLE )
           {
               return Composable.class.getName();
  @@ -253,6 +271,10 @@
           {
               return "contextualize()";
           }
  +        else if( methodId == SERVICE )
  +        {
  +            return "service()";
  +        }
           else if( methodId == COMPOSE )
           {
               return "compose()";
  @@ -573,6 +595,31 @@
       public void checkContextualized( final String message )
       {
           generalCheckInit( message, CONTEXTUALIZABLE, CONTEXTUALIZE );
  +    }
  +
  +    /**
  +     * Throw an exception if the initialization is out of order.  It tests to see
  +     * if the SERVICE state has already been set, if the component implements
  +     * Composable, and if the state has progressed beyond the Configuration stage.
  +     *
  +     * @throws IllegalStateException if the state is manage out of order
  +     */
  +    public void checkServiced()
  +    {
  +        checkServiced( null );
  +    }
  +
  +    /**
  +     * Throw an exception if the initialization is out of order.  It tests to see
  +     * if the SERVICE state has already been set, if the component implements
  +     * Composable, and if the state has progressed beyond the Configuration stage.
  +     *
  +     * @param message the message to include in the thrown exception
  +     * @throws IllegalStateException if the state is manage out of order
  +     */
  +    public void checkServiced( final String message )
  +    {
  +        generalCheckInit( message, SERVICEABLE, SERVICE );
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message