avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/builder ApplianceBuilder.java ApplianceCreator.java package.html
Date Mon, 18 Nov 2002 11:02:29 GMT
mcconnell    2002/11/18 03:02:29

  Added:       assembly/src/java/org/apache/excalibur/assembly/appliance
                        Appliance.java ApplianceException.java
                        ApplianceRuntimeException.java
                        DefaultAppliance.java package.html
               assembly/src/java/org/apache/excalibur/assembly/appliance/builder
                        ApplianceBuilder.java ApplianceCreator.java
                        package.html
  Log:
  Initial commit of the appliance abstraction.  An appliance is an object that
  encapsulates a profile togetherr with lifecycle and lifestyle handling capabilities
  and actis as a gateway between and component instance and a container
  theat is using and managing appliance instances.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/Appliance.java
  
  Index: Appliance.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.excalibur.assembly.appliance;
  
  import org.apache.excalibur.meta.info.StageDescriptor;
  import org.apache.excalibur.meta.model.Profile;
  
  /**
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/18 11:02:28 $
   */
  public interface Appliance
  {
      /**
       * Set the activation policy for the component.  If TRUE, activation
       * will occur at startup.  If false, activation will be deferred to
       * the first lookup invocation if any (i.e. lazy activation).
       *
       * @return the activation policy
       */
      void setActivationPolicy( boolean policy );
  
      /**
       * Return the activation policy for the component.  If TRUE, activation
       * will occur at startup.  If false, activation will be deferred to
       * the first lookup invocation if any (i.e. lazy activation).
       *
       * @return the activation policy
       */
      boolean getActivationPolicy();
  
      /**
       * Test is this profile is enabled.  A profile is enabled unless explicitly disabled
by an
       * assembly directive, or implicity disabled as a result of an assembly failure.
       *
       * @return TRUE if the profile is enabled.
       * @see #setEnabled( boolean )
       */
      boolean isEnabled();
  
      /**
       * Set the enabled status of the profile to the supplied value.
       * @param value the enabled status - TRUE or FALSE
       */
      void setEnabled( boolean value );
  
      /**
       * Return the assigned service providers.
       *
       * @return the set of service provider appliances.
       */
      Appliance[] getServiceProviders();
  
      /**
       * Return the dependency associations for component type with specified role.
       *
       * @param role the dependency role name
       * @return the dependency metadata for component with specified role.
       */
      Appliance getServiceProvider( final String role );
  
      /**
       * Add an association for a service dependency.
       * @param role the role against which the supplied resource is to be associated
       * @param appliance the appliance that will fulfill the provider dependency
       * @return an association binding the role and provider within the scope of the
       *   profile's set of service depedencies
       */
      void addServiceProvider( String role, Appliance appliance );
  
      /**
       * Return the assigned extension providers.
       *
       * @return the set of extension provider appliances.
       */
      Appliance[] getExtensionProviders();
  
      /**
       * Returns the appliace assigned to handle the components lifecycle stage.
       * @param stage the lifecycle stage specification
       * @return a reference to the stage extension
       */
      Appliance getExtensionProvider( StageDescriptor stage );
  
      /**
       * Add a lifecycle stage extension.
       * @param stage the identifier of the stage to assign the manager to
       * @param appliance the appliance that will handle the stage
       */
      void addExtensionProvider( StageDescriptor stage, Appliance appliance );
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/ApplianceException.java
  
  Index: ApplianceException.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.excalibur.assembly.appliance;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was a appliance related error.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/18 11:02:28 $
   */
  public final class ApplianceException
      extends CascadingException
  {
  
      /**
       * Construct a new <code>ApplianceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ApplianceException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ApplianceException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ApplianceException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/ApplianceRuntimeException.java
  
  Index: ApplianceRuntimeException.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.excalibur.assembly.appliance;
  
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  /**
   * Exception to indicate that there was an appliance related runtime error.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/18 11:02:28 $
   */
  public final class ApplianceRuntimeException
      extends CascadingRuntimeException
  {
  
      /**
       * Construct a new <code>ApplianceRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ApplianceRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ApplianceRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ApplianceRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.excalibur.assembly.appliance;
  
  import java.util.Map;
  import java.util.Hashtable;
  
  import org.apache.excalibur.meta.info.StageDescriptor;
  import org.apache.excalibur.meta.model.Profile;
  
  /**
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/18 11:02:28 $
   */
  public class DefaultAppliance implements Appliance
  {
      //=====================================================================
      // state
      //=====================================================================
  
      /**
       * The underlying profile that this appliance is managing.
       */
       private Profile m_profile;
  
      /**
       * The enabled status of the profile.  Normally a profile is enabled however, a
       * failure to assemble will result in the disabling of the profile.
       */
      private boolean m_enabled = true;
  
      /**
       * The activation policy - TRUE if activation on startup, FALSE to activate on request.
       */
      private boolean m_activation = true;
  
      /**
       * The dependencies providers keyed by role name.
       */
      private final Hashtable m_providers = new Hashtable();
  
      /**
       * The stage extension providers keyed by stage descriptor.
       */
      private final Hashtable m_managers = new Hashtable();
  
      //=====================================================================
      // constructor
      //=====================================================================
  
      /**
       * Create an new Appliance instance.
       *
       * @param profile the component profile to be managed by the appliance
       * @param enabled the enabled state of the appliance
       * @param policy the appliance activation policy - TRUE if the appliance should 
       *   should be auto-activated on startup of the host container
       */
      public DefaultAppliance( final Profile profile,
                      final boolean enabled,
                      final boolean policy )
      {
          if( profile == null )
          {
              throw new NullPointerException("profile");
          }
  
          m_profile = profile;
          m_enabled = enabled;
          m_activation = policy;
      }
  
       //=====================================================================
       // implementation
       //=====================================================================
  
      /**
       * Set the activation policy for the component.  If TRUE, activation
       * will occur at startup.  If false, activation will be deferred to
       * the first lookup invocation if any (i.e. lazy activation).
       *
       * @return the activation policy
       */
      public void setActivationPolicy( boolean policy )
      {
          m_activation = policy;
      }
  
      /**
       * Return the activation policy for the component.  If TRUE, activation
       * will occur at startup.  If false, activation will be deferred to
       * the first lookup invocation if any (i.e. lazy activation).
       *
       * @return the activation policy
       */
      public boolean getActivationPolicy()
      {
          return m_activation;
      }
  
      /**
       * Test is this profile is enabled.  A profile is enabled unless explicitly disabled
by an
       * assembly directive, or implicity disabled as a result of an assembly failure.
       *
       * @return TRUE if the profile is enabled.
       * @see #setEnabled( boolean )
       */
      public boolean isEnabled()
      {
          return m_enabled;
      }
  
      /**
       * Set the enabled status of the profile to the supplied value.
       * @param value the enabled status - TRUE or FALSE
       */
      public void setEnabled( boolean value )
      {
          m_enabled = value;
      }
  
      /**
       * Return the assigned service providers.
       *
       * @return the set of service provider assignments.
       */
      public Appliance[] getServiceProviders()
      {
          return (Appliance[])m_providers.values().toArray( new Appliance[ 0 ] );
      }
  
      /**
       * Return the provider appliance for the specified role.
       *
       * @param role the role name
       * @return the appliance servicing the role
       */
      public Appliance getServiceProvider( final String role )
      {
          return (Appliance)m_providers.get( role );
      }
  
      /**
       * Add an appliance servicing for a dependency.
       * @param role the role against which the supplied resource is to be associated
       * @param appliance the appliance that will fulfill the dependency
       */
      public void addServiceProvider( String role, Appliance appliance )
      {
          m_providers.put( role, appliance );
      }
  
      /**
       * Add a lifecycle stage extension.
       * @param stage the identifier of the stage to assign the manager to
       * @param appliance the appliance that will handle the stage
       */
      public void addExtensionProvider( StageDescriptor stage, Appliance appliance )
      {
          m_managers.put( stage, appliance );
      }
  
      /**
       * Return the assigned extension providers.
       *
       * @return the set of extension provider appliances.
       */
      public Appliance[] getExtensionProviders()
      {
          return (Appliance[])m_managers.values().toArray( new Appliance[ 0 ] );
      }
  
      /**
       * Return a reference to the lifecycle stage extension assigned to handle
       * the components custom stage.
       * @param stage the lifecycle stage specification
       * @return the appliance handling the stage extension
       */
      public Appliance getExtensionProvider( StageDescriptor stage )
      {
          return (Appliance)m_managers.get( stage );
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  The <code>appliace</code> package contains classes and interfaces for the {@link
org.apache.excalibur.assembly.appliance.Appliance} and related default implementations supporting
the management of the lifecycle and lifestyle of a profiled service provider.
  </p>
  </body>
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/builder/ApplianceBuilder.java
  
  Index: ApplianceBuilder.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */
  
  package org.apache.excalibur.assembly.appliance.builder;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  
  import org.apache.excalibur.meta.info.Type;
  import org.apache.excalibur.meta.model.Profile;
  import org.apache.excalibur.meta.model.builder.ProfileCreator;
  import org.apache.excalibur.meta.model.builder.ProfileBuilder;
  import org.apache.excalibur.assembly.appliance.DefaultAppliance;
  import org.apache.excalibur.assembly.appliance.Appliance;
  import org.apache.excalibur.assembly.type.TypeManager;
  
  /**
   * A ApplianceBuilder is responsible for building an {@link Appliance}
   * objects from Configuration objects or profile and supporting policy.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/18 11:02:29 $
   */
  public final class ApplianceBuilder implements Contextualizable
  {
      //==================================================================
      // state
      //==================================================================
  
     /**
      * The profile building to use when creating the profile encapsulated 
      * within the appliance declaration (supplied during contextualization).
      */
      private ProfileBuilder m_profileBuilder;
  
     /**
      * The type building to use when creating the profile encapsulated 
      * within the appliance declaration (supplied during contextualization).
      */
      private TypeManager m_typeManager;
  
     /**
      * The profile classloader to use (supplied during contextualization).
      */
      private ClassLoader m_loader;
  
      //==================================================================
      // Contextualizable
      //==================================================================
  
     /**
      * Supply of the rutime context by the container managing this builder.
      * @param context the context
      * @exception ContextException if a required contect value was not supplied
      */
      public void contextualize( Context context ) throws ContextException
      {
          m_typeManager = (TypeManager) context.get("merlin:appliance.type-manager");
          m_profileBuilder = (ProfileBuilder) context.get("merlin:appliance.profile-builder");
          m_loader = (ClassLoader) context.get("merlin:appliance.classloader");
      }
  
      //==================================================================
      // ApplianceCreator
      //==================================================================
  
     /**
      * Create an {@link Appliance} instances from a configuration.
      * @param config the appliance description
      * @return the appliance
      * @exception Exception if an error occurs during appliance creation
      */
      public Appliance createAppliance( Configuration config )
         throws Exception
      {
          return build( config );
      }
  
      /**
       * Create an {@link Appliance} instances from the supplied arguments.
       * @param profile the component profile
       * @param enabled the inital appliance enabled state
       * @param activation the inital activation policy
       * @return the appliance
       * @exception Exception if an error occurs during appliance creation
       */
      public Appliance createAppliance( Profile profile, boolean enabled, boolean activation
)
      {
          return new DefaultAppliance( profile, enabled, activation );
      }
  
      //==================================================================
      // internal utilities
      //==================================================================
  
      /**
       * Utility method to get the activation mode for the profile.
       * If the activation attribute value is equal to "startup"
       * TRUE is returned.  If the value if "lazy", FALSE is returned.
       * Otherwise the value will be resolved as a boolean.
       *
       * @param config the profile configuration
       * @return boolean TRUE if activation on startup
       */
      protected boolean getActivationMode( Configuration config )
      {
          String value = config.getAttribute( "activation", "lazy" );
          if( value.equalsIgnoreCase( "startup" ) )
          {
              return true;
          }
          if( value.equalsIgnoreCase( "lazy" ) )
          {
              return false;
          }
          return config.getAttributeAsBoolean( "activation", false );
      }
  
      /**
       * Build an Appliance from a configuration.
       *
       * @param config the appliance configuration fragment
       * @return the created Appliance
       * @throws Exception if an error occurs during apliance creation
       */
      private Appliance build( Configuration config )
          throws Exception
      {
          final boolean enabled =
              config.getAttributeAsBoolean( "enabled", true );
          final boolean activation =
              getActivationMode( config );
  
          final Configuration conf = config.getChild("profile");
          String classname = conf.getAttribute("type");
          Type type = m_typeManager.register( classname );
          final Profile profile = m_profileBuilder.build( type, conf );
          return createAppliance( profile, enabled, activation );
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/builder/ApplianceCreator.java
  
  Index: ApplianceCreator.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.excalibur.assembly.appliance.builder;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.excalibur.assembly.appliance.Appliance;
  import org.apache.excalibur.meta.model.Profile;
  
  /**
   * Appliance creation interface from a Configuration sorce.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/11/18 11:02:29 $
   */
  public interface ApplianceCreator
  {
      /**
       * Create an {@link Appliance} instances from a configuration.
       * @param config the appliance description
       * @return the appliance
       * @exception Exception if an error occurs during appliance creation
       */
      Appliance createAppliance( Configuration config )
          throws Exception;
  
      /**
       * Create an {@link Appliance} instances from the supplied arguments.
       * @param profile the compoent profile
       * @param enabled the inital appliance enabled state
       * @param activation the inital activation policy
       * @return the appliance
       * @exception Exception if an error occurs during appliance creation
       */
      Appliance createAppliance( Profile profile, boolean enabled, boolean activation );
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/assembly/appliance/builder/package.html
  
  Index: package.html
  ===================================================================
  <body>
  <p>
  The <code>builder</code> package contains classes and interfaces supporting
the creation of {@link org.apache.excalibur.assembly.appliance.Appliance } instances.
  </p>
  </body>
  
  
  
  

--
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