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 PhoenixEmbeddor.java
Date Wed, 25 Apr 2001 01:04:24 GMT
donaldp     01/04/24 18:04:24

  Modified:    src/java/org/apache/phoenix/engine PhoenixEmbeddor.java
  Log:
  Refactored Configuration loading into new method.
  
  Propogated parameters to systemManager/kernel if they implement paramaterizable.
  
  Revision  Changes    Path
  1.8       +37 -12    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PhoenixEmbeddor.java	2001/04/24 09:50:56	1.7
  +++ PhoenixEmbeddor.java	2001/04/25 01:04:23	1.8
  @@ -27,6 +27,7 @@
   import org.apache.avalon.context.Contextualizable;
   import org.apache.avalon.logger.AbstractLoggable;
   import org.apache.avalon.parameters.ParameterException;
  +import org.apache.avalon.parameters.Parameterizable;
   import org.apache.avalon.parameters.Parameters;
   import org.apache.log.LogKit;
   import org.apache.log.LogTarget;
  @@ -393,12 +394,14 @@
       {
           setupLogger( m_systemManager );
   
  -        if( m_systemManager instanceof Configurable )
  +        if( m_systemManager instanceof Parameterizable )
           {
  -            final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -            final String kernelConfigLocation =
  -                m_parameters.getParameter( "manager-configuration-source", null );
  -            final Configuration configuration = builder.build( kernelConfigLocation );
  +            ((Parameterizable)m_systemManager).parameterize( m_parameters );
  +        }
  +        else if( m_systemManager instanceof Configurable )
  +        {
  +            final String location = m_parameters.getParameter( "manager-configuration-source",
null );
  +            final Configuration configuration = getConfigurationFor( location );
   
               ((Configurable)m_systemManager).configure( configuration );
           }
  @@ -409,7 +412,7 @@
           }
           catch( final Exception e )
           {
  -            getLogger().fatalError( "There was a fatal error; " + 
  +            getLogger().fatalError( "There was a fatal error; " +
                                       "phoenix's SystemManager could not be started", e );
               throw e;
           }
  @@ -452,17 +455,25 @@
           if( m_kernel instanceof Composable )
           {
               final DefaultComponentManager componentManager = new DefaultComponentManager();
  -            componentManager.put( "org.apache.avalon.atlantis.SystemManager", 
  -                                  (SystemManager)m_systemManager );
  +            componentManager.put( "org.apache.avalon.atlantis.SystemManager", m_systemManager
);
               ((Composable)m_kernel).compose( componentManager );
           }
   
  +        /*
  +          if( m_kernel instanceof Parameterizable )
  +          {
  +          final String location = m_parameters.getParameter( "kernel-parameters-source",
null );
  +          final Parameters parameters = getParametersFor( location );
  +
  +          ((Parameterizable)m_kernel).parameterize( parameters );
  +          }
  +          else
  +        */
  +
           if( m_kernel instanceof Configurable )
           {
  -            final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -            final String kernelConfigLocation =
  -                m_parameters.getParameter( "kernel-configuration-source", null );
  -            final Configuration configuration = builder.build( kernelConfigLocation );
  +            final String location = m_parameters.getParameter( "kernel-configuration-source",
null );
  +            final Configuration configuration = getConfigurationFor( location );
   
               ((Configurable)m_kernel).configure( configuration );
           }
  @@ -476,5 +487,19 @@
               getLogger().fatalError( "There was a fatal error; phoenix could not be started",
e );
               throw e;
           }
  +    }
  +
  +    /**
  +     * 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
  +    {
  +        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        return builder.build( location );
       }
   }
  
  
  

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