avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine Main.java PhoenixEmbeddor.java PhoenixManager.java
Date Tue, 24 Apr 2001 09:08:55 GMT
donaldp     01/04/24 02:08:54

  Modified:    src/java/org/apache/phoenix/engine Main.java
                        PhoenixEmbeddor.java PhoenixManager.java
  Log:
  Load no-op SystemManager
  
  Revision  Changes    Path
  1.12      +10 -3     jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Main.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Main.java	2001/04/23 06:32:24	1.11
  +++ Main.java	2001/04/24 09:08:48	1.12
  @@ -32,9 +32,12 @@
       private static final String    DEFAULT_LOG_FILE     = PHOENIX_HOME + "/logs/phoenix.log";
       private static final String    DEFAULT_APPS_PATH    = PHOENIX_HOME + "/apps";
   
  -    private static final String    DEFAULT_KERNEL_CLASS =
  +    private static final String    DEFAULT_KERNEL       =
           System.getProperty( "phoenix.kernel", "org.apache.phoenix.engine.PhoenixKernel"
);
   
  +    private static final String    DEFAULT_MANAGER      =
  +        System.getProperty( "phoenix.manager", "org.apache.phoenix.engine.PhoenixManager"
);
  +
       private static final int       DEBUG_LOG_OPT        = 'd';
       private static final int       HELP_OPT             = 'h';
       private static final int       LOG_FILE_OPT         = 'l';
  @@ -188,9 +191,13 @@
           throws Exception
       {
           final Parameters parameters = new Parameters();
  -        parameters.setParameter( "kernel-class", "org.apache.phoenix.engine.PhoenixKernel"
);
  -        parameters.setParameter( "deployer-class", "org.apache.phoenix.engine.DefaultSarDeployer"
);
  +        parameters.setParameter( "kernel-class", DEFAULT_KERNEL );
           parameters.setParameter( "kernel-configuration-source", null );
  +
  +        parameters.setParameter( "manager-class", DEFAULT_MANAGER );
  +        parameters.setParameter( "manager-configuration-source", null );
  +
  +        parameters.setParameter( "deployer-class", "org.apache.phoenix.engine.DefaultSarDeployer"
);
           parameters.setParameter( "log-destination", m_logFile );
           parameters.setParameter( "applications-directory", m_appsPath );
   
  
  
  
  1.6       +95 -7     jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixEmbeddor.java
  
  Index: PhoenixEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixEmbeddor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PhoenixEmbeddor.java	2001/04/22 07:28:30	1.5
  +++ PhoenixEmbeddor.java	2001/04/24 09:08:49	1.6
  @@ -14,6 +14,7 @@
   import org.apache.avalon.Initializable;
   import org.apache.avalon.atlantis.Embeddor;
   import org.apache.avalon.atlantis.Kernel;
  +import org.apache.avalon.atlantis.SystemManager;
   import org.apache.avalon.camelot.CamelotUtil;
   import org.apache.avalon.camelot.Container;
   import org.apache.avalon.camelot.Deployer;
  @@ -48,6 +49,7 @@
       private Parameters     m_parameters;
       private Kernel         m_kernel;
       private Deployer       m_deployer;
  +    private SystemManager  m_systemManager;
   
       private boolean        m_shutdown;
   
  @@ -142,12 +144,19 @@
       public void dispose()
           throws Exception
       {
  +        if( null != m_systemManager )
  +        {
  +            m_systemManager.stop();
  +            m_systemManager.dispose();
  +        }
  +
           if( null != m_kernel )
           {
               m_kernel.stop();
               m_kernel.dispose();
           }
   
  +        m_systemManager = null;
           m_kernel = null;
           m_deployer = null;
           System.gc(); // make sure resources are released
  @@ -191,6 +200,17 @@
   
           try
           {
  +            m_systemManager = createSystemManager();
  +        }
  +        catch( final Exception e )
  +        {
  +            final String message = "Unable to create SystemManager!";
  +            getLogger().fatalError( message, e );
  +            throw new CascadingException( message, e );
  +        }
  +
  +        try
  +        {
               m_kernel = createKernel();
           }
           catch( final Exception e )
  @@ -220,6 +240,16 @@
   
           try
           {
  +            setupSystemManager();
  +        }
  +        catch( final Exception e )
  +        {
  +            getLogger().fatalError( "Unable to setup SystemManager!", e );
  +            throw e;
  +        }
  +
  +        try
  +        {
               setupKernel();
           }
           catch( final Exception e )
  @@ -265,8 +295,10 @@
       }
   
       /**
  -     * Creates a new deployer from the Parameters's deployer-class.
  -     * TODO: fill the Parameters for Deployer properly.
  +     * Creates a new deployer from the Parameters's deployer-class variable.
  +     *
  +     * @return the new Deployer
  +     * @exception ConfigurationException if an error occurs
        */
       private Deployer createDeployer()
           throws ConfigurationException
  @@ -290,9 +322,6 @@
        * passed a Context. If it is a Composable it is given a
        * ComponentManager which references the Kernel, cast to a
        * Container.
  -     * The deployer is now used to load the applications from the
  -     * default-facilities-location specified in Context.
  -     * TODO: load facilities from .fars as well.
        */
       private void setupDeployer()
           throws Exception
  @@ -331,9 +360,66 @@
           // CamelotUtil.deployFromDirectory( deployer, directory2, ".far" );
       }
   
  +    /**
  +     * Creates a new SystemManager from the Parameters's manager-class parameter.
  +     *
  +     * @return the created SystemManager
  +     * @exception ConfigurationException if an error occurs
  +     */
  +    private SystemManager createSystemManager()
  +        throws ConfigurationException
  +    {
  +        final String className = m_parameters.getParameter( "manager-class", null );
  +        try
  +        {
  +            Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
  +            return (SystemManager)Class.forName( className ).newInstance();
  +        }
  +        catch( final Exception e )
  +        {
  +            throw new ConfigurationException( "Failed to create SystemManager of class
" +
  +                                              className, e );
  +        }
  +    }
  +
  +    /**
  +     * Sets up the SystemManager. We determine whether it supports Loggable
  +     * and Configurable and supply information based on that.
  +     *
  +     * @exception Exception if an error occurs
  +     */
  +    private void setupSystemManager()
  +        throws Exception
  +    {
  +        setupLogger( m_systemManager );
  +
  +        if( m_systemManager instanceof Configurable )
  +        {
  +            final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +            final String kernelConfigLocation =
  +                m_parameters.getParameter( "manager-configuration-source", null );
  +            final Configuration configuration = builder.build( kernelConfigLocation );
  +
  +            ((Configurable)m_systemManager).configure( configuration );
  +        }
  +
  +        try
  +        {
  +            m_systemManager.init();
  +        }
  +        catch( final Exception e )
  +        {
  +            getLogger().fatalError( "There was a fatal error; " + 
  +                                    "phoenix's SystemManager could not be started", e );
  +            throw e;
  +        }
  +    }
  +
       /**
  -     * Creates a new deployer from the Parameters's kernel-class.
  -     * TODO: fill the Parameters for kernel properly.
  +     * Creates a new kernel from the Parameters's kernel-class parameter.
  +     *
  +     * @return the created Kernel
  +     * @exception ConfigurationException if an error occurs
        */
       private Kernel createKernel()
           throws ConfigurationException
  @@ -354,6 +440,8 @@
       /**
        * Sets up the Kernel. We determine whether it supports Loggable
        * and Configurable and supply information based on that.
  +     *
  +     * @exception Exception if an error occurs
        */
       private void setupKernel()
           throws Exception
  
  
  
  1.2       +24 -3     jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixManager.java
  
  Index: PhoenixManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PhoenixManager.java	2001/04/24 05:44:35	1.1
  +++ PhoenixManager.java	2001/04/24 09:08:50	1.2
  @@ -8,15 +8,36 @@
   package org.apache.phoenix.engine;
   
   import org.apache.avalon.atlantis.SystemManager;
  +import org.apache.avalon.logger.AbstractLoggable;
   
   /**
  - * This facility is responsible for managing phoenix instance. 
  + * This component is responsible for managing phoenix instance.
    * This includes managing embeddor, deployer and kernel.
    *
    * @author <a href="mail@leosimons.com">Leo Simons</a>
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    */
  -public interface PhoenixManager
  -    extends SystemManager
  +public class PhoenixManager
  +    extends AbstractLoggable
  +    implements SystemManager
   {
  +    public void init()
  +        throws Exception
  +    {
  +    }
  +
  +    public void start()
  +        throws Exception
  +    {
  +    }
  +
  +    public void stop()
  +        throws Exception
  +    {
  +    }
  +
  +    public void dispose()
  +        throws Exception
  +    {
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message