avalon-cvs 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/avalon/phoenix/frontends CLIMain.java CLISetup.java PhoenixServlet.java Resources.properties
Date Thu, 21 Mar 2002 04:39:15 GMT
donaldp     02/03/20 20:39:15

  Modified:    .        build.xml
               src/java/org/apache/avalon/phoenix/components/embeddor
                        DefaultEmbeddor.java Resources.properties
                        SingleAppEmbeddor.java
               src/java/org/apache/avalon/phoenix/frontends CLIMain.java
                        CLISetup.java PhoenixServlet.java
                        Resources.properties
  Added:       src/conf kernel.xml
               src/java/org/apache/avalon/phoenix/components/embeddor
                        EmbeddorEntry.java
  Log:
  Rework the embeddor so that the componentns it instantiates are read out of a config file
(namely conf/kernel.xml)
  
  Submitted By: Joerg Bauer bauer@denic.de
  
  Revision  Changes    Path
  1.103     +3 -1      jakarta-avalon-phoenix/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/build.xml,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- build.xml	16 Mar 2002 00:06:42 -0000	1.102
  +++ build.xml	21 Mar 2002 04:39:14 -0000	1.103
  @@ -57,7 +57,7 @@
     <property name="xerces.file" value="xerces.jar"/>
     <property name="xerces.jar" value="${xerces.dir}/${xerces.file}"/>
     <property name="xalan.jar" value="${tools.dir}/lib/xalan-2.2.0-D8.jar"/>
  -  <property name="framework.jar" value="${lib.dir}/avalon-framework-4.1.2.jar"/>
  +  <property name="framework.jar" value="${lib.dir}/avalon-framework-20022103.jar"/>
     <property name="excalibur.jar" value="${lib.dir}/avalon-excalibur-4.1.jar"/>
     <property name="scratchpad.jar" value="${lib.dir}/avalon-scratchpad-4.1.jar"/>
     <property name="logkit.jar" value="${lib.dir}/logkit-1.0.1.jar"/>
  @@ -228,6 +228,7 @@
       <mkdir dir="${bin.dist.apps}"/>
       <mkdir dir="${bin.dist.ext}"/>
       <mkdir dir="${bin.dist.lib}"/>
  +    <mkdir dir="${bin.dist.conf}"/>
   
       <copy file="${build.lib}/phoenix-loader.jar" todir="${bin.dist.bin}/"/>
       <copy file="${build.lib}/phoenix-engine.jar" todir="${bin.dist.bin}"/>
  @@ -241,6 +242,7 @@
       <copy file="${excalibur.jar}" todir="${bin.dist.lib}"/>
       <copy file="${scratchpad.jar}" todir="${bin.dist.lib}"/>
       <copy file="${xerces.jar}" todir="${bin.dist.lib}"/>
  +    <copy file="${conf.dir}/kernel.xml" todir="${bin.dist.conf}"/>
       <!--
       This was not copying for relatively local ..\jakarta-avalon\tools\lib\xerces.jar -
PH
       <copy todir="${bin.dist.lib}">
  
  
  
  1.1                  jakarta-avalon-phoenix/src/conf/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <phoenix>
      <embeddor role="org.apache.avalon.phoenix.interfaces.Embeddor"
          class="org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor">
  
          <component role="org.apache.avalon.phoenix.interfaces.Deployer"
              class="org.apache.avalon.phoenix.components.deployer.DefaultDeployer"
              logger="deployer"/>
  
          <component role="org.apache.avalon.phoenix.interfaces.DeploymentRecorder"
              class="org.apache.avalon.phoenix.components.deployer.DefaultDeploymentRecorder"
              logger="recorder"/>
  
          <component role="org.apache.avalon.phoenix.interfaces.LogManager"
              class="org.apache.avalon.phoenix.components.logger.DefaultLogManager"
              logger="logs"/>
  
          <component role="org.apache.avalon.phoenix.interfaces.Kernel"
              class="org.apache.avalon.phoenix.components.kernel.DefaultKernel"
              logger="kernel"/>
  
          <component role="org.apache.avalon.phoenix.interfaces.SystemManager"
              class="org.apache.avalon.phoenix.components.manager.NoopSystemManager"
              logger="manager"></component>
  
          <!-- use this one if you need the DefaultManager
          <component role="org.apache.avalon.phoenix.interfaces.SystemManager"
              class="org.apache.avalon.phoenix.components.manager.DefaultManager"
              logger="manager" >
          </component>
          -->
  
          <component role="org.apache.avalon.phoenix.interfaces.ConfigurationRepository"
              class="org.apache.avalon.phoenix.components.configuration.DefaultConfigurationRepository"
              logger="config"/>
          <component role="org.apache.avalon.phoenix.interfaces.ClassLoaderManager"
              class="org.apache.avalon.phoenix.components.classloader.DefaultClassLoaderManager"
              logger="classes"/>
          <component role="org.apache.avalon.phoenix.interfaces.PackageRepository"
              class="org.apache.avalon.phoenix.components.extensions.PhoenixPackageRepository"
              logger="packages"/>
      </embeddor>
  </phoenix>
  
  
  1.48      +101 -132  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- DefaultEmbeddor.java	16 Mar 2002 00:11:55 -0000	1.47
  +++ DefaultEmbeddor.java	21 Mar 2002 04:39:14 -0000	1.48
  @@ -22,8 +22,9 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.DefaultComponentManager;
  +import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
  @@ -32,16 +33,10 @@
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.phoenix.Constants;
  -import org.apache.avalon.phoenix.interfaces.ClassLoaderManager;
  -import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
   import org.apache.avalon.phoenix.interfaces.Deployer;
  -import org.apache.avalon.phoenix.interfaces.DeploymentRecorder;
   import org.apache.avalon.phoenix.interfaces.Embeddor;
   import org.apache.avalon.phoenix.interfaces.EmbeddorMBean;
   import org.apache.avalon.phoenix.interfaces.Kernel;
  -import org.apache.avalon.phoenix.interfaces.LogManager;
  -import org.apache.avalon.phoenix.interfaces.PackageRepository;
  -import org.apache.avalon.phoenix.interfaces.SystemManager;
   
   /**
    * This is the object that is interacted with to create, manage and
  @@ -49,11 +44,13 @@
    *
    * @author <a href="mail@leosimons.com">Leo Simons</a>
    * @author <a href="peter@apache.org">Peter Donald</a>
  + * @author <a href="bauer@denic.de">Joerg Bauer</a>
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  -    implements Embeddor, Contextualizable, Parameterizable, EmbeddorMBean
  +    implements Embeddor, Contextualizable, Parameterizable, Configurable, EmbeddorMBean
   {
  +
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultEmbeddor.class );
   
  @@ -63,14 +60,7 @@
       private Parameters m_parameters;
       private String m_phoenixHome;
   
  -    private ClassLoaderManager m_classLoaderManager;
  -    private ConfigurationRepository m_repository;
  -    private Kernel m_kernel;
  -    private Deployer m_deployer;
  -    private DeploymentRecorder m_recorder;
  -    private LogManager m_logManager;
  -    private SystemManager m_systemManager;
  -    private PackageRepository m_packageRepository;
  +    private EmbeddorEntry[] components;
   
       /**
        * If true, flag indicates that the Embeddor should continue running
  @@ -135,13 +125,33 @@
       public synchronized void parameterize( final Parameters parameters )
           throws ParameterException
       {
  -        m_parameters = createDefaultParameters();
  -        m_parameters.merge( parameters );
  -
  +        m_parameters = parameters;
  +        m_parameters.setParameter( "phoenix.home", ".." );
  +        m_parameters.setParameter( "persistent", "false" );
           m_phoenixHome = m_parameters.getParameter( "phoenix.home" );
           m_persistent = m_parameters.getParameterAsBoolean( "persistent" );
       }
   
  +    public void configure( final Configuration configuration )
  +        throws ConfigurationException
  +    {
  +        Configuration[] childs = configuration.getChildren( "component" );
  +        components = new EmbeddorEntry[ childs.length ];
  +        for( int i = 0; i < childs.length; i++ )
  +        {
  +            final String role = childs[ i ].getAttribute( "role" );
  +            final String classname = childs[ i ].getAttribute( "class" );
  +            final String logger = childs[ i ].getAttribute( "logger" );
  +            final Configuration childConfiguration = childs[ i ];
  +
  +            components[ i ] = new EmbeddorEntry();
  +            components[ i ].setRole( role );
  +            components[ i ].setClassName( classname );
  +            components[ i ].setLoggerName( logger );
  +            components[ i ].setConfiguration( childConfiguration );
  +        }
  +    }
  +
       /**
        * Creates the core handlers - logger, deployer, Manager and
        * Kernel. Note that these are not set up properly until you have
  @@ -154,16 +164,7 @@
           try
           {
               createComponents();
  -
  -            // setup core handler components
  -            setupComponent( m_packageRepository, "packages" );
  -            setupComponent( m_logManager, "logs" );
  -            setupComponent( m_classLoaderManager, "classes" );
  -            setupComponent( m_repository, "config" );
  -            setupComponent( m_deployer, "deployer" );
  -            setupComponent( m_recorder, "recorder" );
  -            setupComponent( m_systemManager, "manager" );
  -            setupComponent( m_kernel, "kernel" );
  +            setupComponents();
           }
           catch( final Exception e )
           {
  @@ -221,9 +222,10 @@
   
       private boolean emptyKernel()
       {
  -        if( null != m_kernel )
  +        Kernel kernel = (Kernel)getEmbeddorComponent( Kernel.ROLE );
  +        if( null != kernel )
           {
  -            final String[] names = m_kernel.getApplicationNames();
  +            final String[] names = kernel.getApplicationNames();
               return ( 0 == names.length );
           }
           else
  @@ -256,14 +258,7 @@
           shutdown();
           try
           {
  -            shutdownComponent( m_systemManager );
  -            shutdownComponent( m_recorder );
  -            shutdownComponent( m_deployer );
  -            shutdownComponent( m_kernel );
  -            shutdownComponent( m_repository );
  -            shutdownComponent( m_logManager );
  -            shutdownComponent( m_classLoaderManager );
  -            shutdownComponent( m_packageRepository );
  +            shutdownComponents();
           }
           catch( final Exception e )
           {
  @@ -271,14 +266,10 @@
               final String message = REZ.getString( "embeddor.error.shutdown.failed" );
               getLogger().fatalError( message, e );
           }
  -
  -        m_packageRepository = null;
  -        m_systemManager = null;
  -        m_kernel = null;
  -        m_repository = null;
  -        m_classLoaderManager = null;
  -        m_logManager = null;
  -        m_deployer = null;
  +        for( int i = 0; i < components.length; i++ )
  +        {
  +            components[ i ].setObject( null );
  +        }
           System.gc(); // make sure resources are released
       }
   
  @@ -380,44 +371,30 @@
           return "(" + Constants.DATE + ")";
       }
   
  -
       //////////////////////
       /// HELPER METHODS ///
       //////////////////////
  -
       /**
        * Create the logger, deployer and kernel components.
        * Note that these components are not ready to be used
        * until setupComponents() is called.
        */
       private synchronized void createComponents()
  -        throws Exception
       {
  -        String component = null;
  -
  -        component = m_parameters.getParameter( PackageRepository.ROLE );
  -        m_packageRepository = (PackageRepository)createComponent( component, PackageRepository.class
);
  -
  -        component = m_parameters.getParameter( ConfigurationRepository.ROLE );
  -        m_repository = (ConfigurationRepository)createComponent( component, ConfigurationRepository.class
);
  -
  -        component = m_parameters.getParameter( LogManager.ROLE );
  -        m_logManager = (LogManager)createComponent( component, LogManager.class );
  -
  -        component = m_parameters.getParameter( ClassLoaderManager.ROLE );
  -        m_classLoaderManager = (ClassLoaderManager)createComponent( component, ClassLoaderManager.class
);
  -
  -        component = m_parameters.getParameter( Deployer.ROLE );
  -        m_deployer = (Deployer)createComponent( component, Deployer.class );
  -
  -        component = m_parameters.getParameter( DeploymentRecorder.ROLE );
  -        m_recorder = (DeploymentRecorder)createComponent( component, DeploymentRecorder.class
);
  -
  -        component = m_parameters.getParameter( SystemManager.ROLE );
  -        m_systemManager = (SystemManager)createComponent( component, SystemManager.class
);
  -
  -        component = m_parameters.getParameter( Kernel.ROLE );
  -        m_kernel = (Kernel)createComponent( component, Kernel.class );
  +        Object object;
  +        try
  +        {
  +            for( int i = 0; i < components.length; i++ )
  +            {
  +                object = createComponent( components[ i ].getClassName(), Class.forName(
components[ i ].getClassName() ) );
  +                components[ i ].setObject( object );
  +            }
  +        }
  +        catch( Exception e )
  +        {
  +            final String message = REZ.getString( "embeddor.error.createComponents.failed"
);
  +            getLogger().fatalError( message, e );
  +        }
       }
   
       /**
  @@ -437,8 +414,7 @@
               final File file = new File( application );
               deployFile( file );
           }
  -        final String defaultAppsLocation =
  -            m_parameters.getParameter( "applications-directory", m_phoenixHome + DEFAULT_APPS_PATH
);
  +        final String defaultAppsLocation = m_parameters.getParameter( "applications-directory",
m_phoenixHome + DEFAULT_APPS_PATH );
           if( null != defaultAppsLocation )
           {
               final File directory = new File( defaultAppsLocation );
  @@ -474,7 +450,20 @@
       protected final synchronized void deployFile( final String name, final File file )
           throws Exception
       {
  -        m_deployer.deploy( name, file.toURL() );
  +        final Deployer deployer = (Deployer)getEmbeddorComponent( Deployer.ROLE );
  +        deployer.deploy( name, file.toURL() );
  +    }
  +
  +    private void setupComponents()
  +        throws Exception
  +    {
  +        for( int i = 0; i < components.length; i++ )
  +        {
  +            final Component component = (Component)( components[ i ].getObject() );
  +            final String loggerName = components[ i ].getLoggerName();
  +            final Configuration configuration = components[ i ].getConfiguration();
  +            setupComponent( component, loggerName, configuration );
  +        }
       }
   
       /**
  @@ -484,7 +473,7 @@
        * @param component the component
        * @exception Exception if an error occurs
        */
  -    private void setupComponent( final Component component, final String loggerName )
  +    private void setupComponent( final Component component, final String loggerName, Configuration
config )
           throws Exception
       {
           setupLogger( component, loggerName );
  @@ -497,6 +486,10 @@
           {
               ( (Parameterizable)component ).parameterize( m_parameters );
           }
  +        else if( component instanceof Configurable )
  +        {
  +            ( (Configurable)component ).configure( config );
  +        }
           if( component instanceof Initializable )
           {
               ( (Initializable)component ).initialize();
  @@ -507,6 +500,15 @@
           }
       }
   
  +    private void shutdownComponents()
  +        throws Exception
  +    {
  +        for( int i = 0; i < components.length; i++ )
  +        {
  +            shutdownComponent( (Component)components[ i ] );
  +        }
  +    }
  +
       /**
        * Shutdown a component and run it through al of it's
        * shutdown lifecycle stages.
  @@ -556,14 +558,12 @@
           }
           catch( final InstantiationException ie )
           {
  -            final String message =
  -                REZ.getString( "no-instantiate.error", clazz.getName(), component );
  +            final String message = REZ.getString( "no-instantiate.error", clazz.getName(),
component );
               throw new CascadingException( message, ie );
           }
           catch( final ClassNotFoundException cnfe )
           {
  -            final String message =
  -                REZ.getString( "no-class.error", clazz.getName(), component );
  +            final String message = REZ.getString( "no-class.error", clazz.getName(), component
);
               throw new CascadingException( message, cnfe );
           }
       }
  @@ -572,53 +572,21 @@
       {
           final DefaultComponentManager componentManager = new DefaultComponentManager();
           componentManager.put( Embeddor.ROLE, this );
  -        componentManager.put( LogManager.ROLE, m_logManager );
  -        componentManager.put( PackageRepository.ROLE, m_packageRepository );
  -        componentManager.put( ClassLoaderManager.ROLE, m_classLoaderManager );
  -        componentManager.put( ConfigurationRepository.ROLE, m_repository );
  -        componentManager.put( Deployer.ROLE, m_deployer );
  -        componentManager.put( DeploymentRecorder.ROLE, m_recorder );
  -        componentManager.put( SystemManager.ROLE, m_systemManager );
  -        componentManager.put( Kernel.ROLE, m_kernel );
  +        for( int i = 0; i < components.length; i++ )
  +        {
  +            componentManager.put( components[ i ].getRole(), (Component)getEmbeddorComponent(
components[ i ].getRole() ) );
  +        }
           return componentManager;
       }
   
       /**
  -     * Create default properties which includes default names of all components.
  -     * Overide this in sub-classes to change values.
  -     *
  -     * @return the Parameters
  -     */
  -    protected Parameters createDefaultParameters()
  -    {
  -        final Parameters defaults = new Parameters();
  -        defaults.setParameter( "phoenix.home", ".." );
  -        defaults.setParameter( "persistent", "false" );
  -
  -        final String PREFIX = "org.apache.avalon.phoenix.components.";
  -        defaults.setParameter( Deployer.ROLE, PREFIX + "deployer.DefaultDeployer" );
  -        defaults.setParameter( DeploymentRecorder.ROLE, PREFIX + "deployer.DefaultDeploymentRecorder"
);
  -        //defaults.setParameter( DeploymentRecorder.ROLE, PREFIX + "deployer.PersistentDeploymentRecorder"
);
  -        defaults.setParameter( LogManager.ROLE, PREFIX + "logger.DefaultLogManager" );
  -        defaults.setParameter( Kernel.ROLE, PREFIX + "kernel.DefaultKernel" );
  -        defaults.setParameter( SystemManager.ROLE, PREFIX + "manager.NoopSystemManager"
);
  -        defaults.setParameter( ConfigurationRepository.ROLE,
  -                               PREFIX + "configuration.DefaultConfigurationRepository"
);
  -        defaults.setParameter( ClassLoaderManager.ROLE,
  -                               PREFIX + "classloader.DefaultClassLoaderManager" );
  -        defaults.setParameter( PackageRepository.ROLE,
  -                               PREFIX + "extensions.PhoenixPackageRepository" );
  -        return defaults;
  -    }
  -
  -    /**
        * Allow subclasses to get access to kernel.
        *
        * @return the Kernel
        */
       protected final Kernel getKernel()
       {
  -        return m_kernel;
  +        return (Kernel)getEmbeddorComponent( Kernel.ROLE );
       }
   
       /**
  @@ -631,18 +599,19 @@
           return m_parameters;
       }
   
  -    /**
  -     * Helper method to retrieve configuration from a location on filesystem.
  -     *
  -     * @param location the location of configuration
  -     * @return the configuration
  -     * @exception Exception if an error occurs
  -     */
  -    private Configuration getConfigurationFor( final String location )
  -        throws Exception
  +    private Object getEmbeddorComponent( final String role )
       {
  -        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -        return builder.buildFromFile( location );
  +        for( int i = 0; i < components.length; i++ )
  +        {
  +            final EmbeddorEntry entry = components[ i ];
  +            if( entry.getRole().equals( role ) )
  +            {
  +                return components[ i ].getObject();
  +            }
  +        }
  +        // Should never happen
  +        // TODO: create error / warning
  +        return null;
       }
   }
   
  @@ -653,4 +622,4 @@
       {
           super.setChanged();
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.6       +1 -0      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/Resources.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resources.properties	7 Feb 2002 07:05:06 -0000	1.5
  +++ Resources.properties	21 Mar 2002 04:39:14 -0000	1.6
  @@ -1,6 +1,7 @@
   embeddor.error.start.failed=There was a fatal error while starting Embeddor.
   embeddor.error.start.no-apps=Unable to start because there are not any applications in
the apps directory.
   embeddor.error.shutdown.failed=There was an unexpected error while shutting down Embeddor.
  +embeddor.error.createComponents.failed=There was an unexpected error while creating Components
for Embeddor.
   embeddor.notice.no-restart=Phoenix was not started by the daemon thus it will not be possible
to restart the JVM via the Management interface.
   embeddor.shutdown.all-apps-disposed=Shutting down because there are not any applications
running.
   bad-type.error=Object {0} is not an instance of {1}.
  
  
  
  1.18      +0 -15     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/SingleAppEmbeddor.java
  
  Index: SingleAppEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/SingleAppEmbeddor.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SingleAppEmbeddor.java	11 Dec 2001 10:13:33 -0000	1.17
  +++ SingleAppEmbeddor.java	21 Mar 2002 04:39:14 -0000	1.18
  @@ -34,21 +34,6 @@
       ///Sole application hosted in kernel
       private Application m_application;
   
  -    /**
  -     * Use ContextClassLoaderManager for ClassLoaderManager.
  -     *
  -     * @return the Parameters
  -     */
  -    protected Parameters createDefaultParameters()
  -    {
  -        final Parameters defaults = super.createDefaultParameters();
  -        final String PREFIX = "org.apache.avalon.phoenix.components.";
  -        defaults.setParameter( ClassLoaderManager.ROLE,
  -                               PREFIX + "classloader.ContextClassLoaderManager" );
  -        defaults.setParameter( PackageRepository.ROLE,
  -                               PREFIX + "extensions.NoopPackageRepository" );
  -        return defaults;
  -    }
   
       /**
        * Deploy a single application.
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/EmbeddorEntry.java
  
  Index: EmbeddorEntry.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.phoenix.components.embeddor;
  
  import org.apache.avalon.framework.configuration.Configuration;
  
  /**
   * @author <a href="bauer@denic.de">Joerg Bauer</a>
   */
  public class EmbeddorEntry
  {
      private String m_role;
      private Configuration m_configuration;
      private String m_classname;
      private String m_loggerName;
      private Object m_object;
  
      public String getRole()
      {
          return m_role;
      }
  
      public void setRole( String role )
      {
          m_role = role;
      }
  
      public Configuration getConfiguration()
      {
          return m_configuration;
      }
  
      public void setConfiguration( Configuration conf )
      {
          this.m_configuration = conf;
      }
  
      public String getClassName()
      {
          return m_classname;
      }
  
      public void setClassName( String name )
      {
          m_classname = name;
      }
  
      public Object getObject()
      {
          return m_object;
      }
  
      public void setObject( Object object )
      {
          m_object = object;
      }
  
      public String getLoggerName()
      {
          return m_loggerName;
      }
  
      public void setLoggerName( String logger )
      {
          m_loggerName = logger;
      }
  }
  
  
  1.25      +16 -2     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLIMain.java
  
  Index: CLIMain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLIMain.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CLIMain.java	16 Mar 2002 00:11:55 -0000	1.24
  +++ CLIMain.java	21 Mar 2002 04:39:15 -0000	1.25
  @@ -14,6 +14,9 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.ExceptionUtil;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.logger.AvalonFormatter;
  @@ -23,7 +26,6 @@
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.phoenix.Constants;
  -import org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor;
   import org.apache.avalon.phoenix.interfaces.Embeddor;
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
  @@ -162,7 +164,8 @@
       {
           try
           {
  -            m_embeddor = new DefaultEmbeddor();
  +            Configuration conf = getConfigurationFor( parameters.getParameter( "phoenix.configfile"
) ).getChild( "embeddor" );
  +            m_embeddor = (Embeddor)Class.forName( conf.getAttribute( "class" ) ).newInstance();
   
               if( m_embeddor instanceof LogEnabled )
               {
  @@ -180,6 +183,10 @@
               {
                   ( (Parameterizable)m_embeddor ).parameterize( parameters );
               }
  +            if( m_embeddor instanceof Configurable )
  +            {
  +                ( (Configurable)m_embeddor ).configure( conf );
  +            }
   
               m_embeddor.initialize();
           }
  @@ -297,6 +304,13 @@
           System.out.println( REZ.getString( "main.exception.footer" ) );
   
           m_exitCode = 1;
  +    }
  +
  +    private Configuration getConfigurationFor( final String location )
  +        throws Exception
  +    {
  +        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        return builder.buildFromFile( location );
       }
   }
   
  
  
  
  1.12      +17 -1     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLISetup.java
  
  Index: CLISetup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/CLISetup.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CLISetup.java	2 Feb 2002 09:41:06 -0000	1.11
  +++ CLISetup.java	21 Mar 2002 04:39:15 -0000	1.12
  @@ -33,6 +33,7 @@
       private static final int LOG_FILE_OPT = 'l';
       private static final int APPS_PATH_OPT = 'a';
       private static final int PERSISTENT_OPT = 'p';
  +    private static final int CONFIGFILE_OPT = 'f';
       private static final int REMOTE_MANAGER_OPT = 1;
       private static final int DISABLE_HOOK_OPT = 2;
       private static final int APPLICATION_OPT = 3;
  @@ -63,7 +64,7 @@
        */
       private CLOptionDescriptor[] createCLOptions()
       {
  -        final CLOptionDescriptor options[] = new CLOptionDescriptor[ 8 ];
  +        final CLOptionDescriptor options[] = new CLOptionDescriptor[ 9 ];
           options[ 0 ] =
               new CLOptionDescriptor( "help",
                                       CLOptionDescriptor.ARGUMENT_DISALLOWED,
  @@ -111,6 +112,13 @@
                                       PERSISTENT_OPT,
                                       REZ.getString( "cli.opt.persistent.desc" ) );
   
  +        options[ 8 ] =
  +            new CLOptionDescriptor( "configfile",
  +                                    CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                                    CONFIGFILE_OPT,
  +                                    REZ.getString( "cli.opt.configfile.desc" ) );
  +
  +
           return options;
       }
   
  @@ -133,6 +141,9 @@
   
           final List clOptions = parser.getArguments();
           final int size = clOptions.size();
  +        
  +        m_parameters.setParameter( "phoenix.configfile", "../conf/kernel.xml");  // setting
default
  +        
   
           for( int i = 0; i < size; i++ )
           {
  @@ -180,6 +191,11 @@
                   case DISABLE_HOOK_OPT:
                       m_parameters.setParameter( "disable-hook", "true" );
                       break;
  +
  +                case CONFIGFILE_OPT:
  +                    m_parameters.setParameter( "phoenix.configfile", option.getArgument()
);
  +                    break;
  +
               }
           }
   
  
  
  
  1.9       +7 -1      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/PhoenixServlet.java
  
  Index: PhoenixServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/PhoenixServlet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PhoenixServlet.java	16 Mar 2002 00:11:55 -0000	1.8
  +++ PhoenixServlet.java	21 Mar 2002 04:39:15 -0000	1.9
  @@ -73,6 +73,7 @@
           final String logPriority = getInitParameter( "log-priority", "INFO" );
           final String appName = getInitParameter( "application-name", "default" );
           final String appLoc = getInitParameter( "application-location", phoenixHome + "/"
+ appName );
  +        final String configFile = getInitParameter( "config-file", phoenixHome + "/conf/kernel.xml");
   
           m_parameters = new Parameters();
           m_parameters.setParameter( "phoenix.home", context.getRealPath( phoenixHome ) );
  @@ -83,12 +84,17 @@
   
           try
           {
  -            m_embeddor = new SingleAppEmbeddor();
  +			Configuration conf = getConfigurationFor(configFile).getChild("embeddor");
  +			m_embeddor = (Embeddor) Class.forName(conf.getAttribute("class")).newInstance();
               m_embeddor.enableLogging( createLogger( m_parameters ) );
  +
               if( m_embeddor instanceof Parameterizable )
               {
                   ( (Parameterizable)m_embeddor ).parameterize( m_parameters );
               }
  +			if (m_embeddor instanceof Configurable) {
  +				((Configurable) m_embeddor).configure(conf);
  +			}
               m_embeddor.initialize();
   
               final Thread thread = new Thread( this, "Phoenix" );
  
  
  
  1.9       +1 -0      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/frontends/Resources.properties,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Resources.properties	2 Feb 2002 09:41:06 -0000	1.8
  +++ Resources.properties	21 Mar 2002 04:39:15 -0000	1.9
  @@ -6,6 +6,7 @@
   cli.opt.application.desc=Start the Application specified by path.
   cli.opt.disable-hook.desc=Disable the Shutdown hook for JVM. Disabling this may mean that
your application is not shutdown cleanly.
   cli.opt.persistent.desc=If specified the Embeddor will persist even after all applications
have been removed from the kernel.
  +cli.opt.configfile.desc=If specified Phoenix will use this configfile.
   
   cli.desc.available.header=Available options:
   
  
  
  

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