mcconnell    02/02/22 08:29:35

  Modified:    apps/enterprise/orb/src/java/org/apache/orb
                        DefaultORBFactory.java DefaultORBFactory.xml
                        ORB.java package.html
               apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel
                        DefaultLoader.java
  Added:       apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel
                        DefaultLoader.xml orb.properties
  Removed:     apps/enterprise/orb/src/java/org/apache/orb
                        ORBInitContext.java
  Log:
  code rationalization
  
  Revision  Changes    Path
  1.3       +29 -14    
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBFactory.java
  
  Index: DefaultORBFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultORBFactory.java    19 Feb 2002 14:49:39 -0000      1.2
  +++ DefaultORBFactory.java    22 Feb 2002 16:29:35 -0000      1.3
  @@ -10,6 +10,9 @@
   import java.io.File;
   import java.net.URL;
   import java.io.InputStream;
  +import java.io.IOException;
  +import java.util.Properties;
  +import java.util.Enumeration;
   
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.logger.LogEnabled;
  @@ -79,6 +82,11 @@
       */
       public static final String DEFAULT_ORB_SINGLETON = 
"org.openorb.CORBA.ORBSingleton";
   
  +   /**
  +    * The default ORB loader property.
  +    */
  +    private static final String DEFAULT_ORB_LOADER = 
"org.apache.orb.CORBA.kernel.DefaultLoader";
  +
       //=================================================================
       // state
       //=================================================================
  @@ -129,9 +137,6 @@
       {
           Configuration defaults = 
loadConfiguration("org/apache/orb/DefaultORBFactory.xml");
           m_config = new CascadingConfiguration( config, defaults );
  -        if( getLogger().isDebugEnabled() ) getLogger().debug(
  -           "configuration (children: "
  -           + m_config.getChildren().length + ")" );
       }
   
       //=================================================================
  @@ -145,8 +150,6 @@
       public void initialize()
       throws Exception
       {
  -        // TODO: add validation that the minimum set of initalizers and
  -        // properties are declared
       }
       
       //=================================================================
  @@ -205,26 +208,39 @@
       * @param configuration optional orb configuration
       * @return ORB a portable CORBA Object Request Broker (ORB)
       */
  -    public ORB createORB( String[] args, java.util.Properties properties, 
  +    public ORB createORB( String[] args, java.util.Properties props, 
         Logger logger, Context context, Configuration configuration )
       {
   
           Logger log = logger;
  -        if( log == null ) log = getLogger();
  +        if( log == null ) log = getLogger().getChildLogger(
  +          m_config.getChild("logging").getAttribute("channel","orb") );
   
           Context ctx = context;
           if( ctx == null ) ctx = m_context;
   
           CascadingConfiguration config = new CascadingConfiguration( 
configuration, m_config );
  -        ORBInitContext props = new ORBInitContext( properties, log, ctx, 
config );
  +
  +        //
  +        // Override the default properties with any properrties supplied by 
the client.
  +        //
  +
  +        java.util.Properties properties = new java.util.Properties();
  +        properties.setProperty("org.omg.CORBA.ORBClass", DEFAULT_ORB_CLASS );
  +       properties.setProperty("org.omg.CORBA.ORBSingletonClass", 
DEFAULT_ORB_SINGLETON );
  +        properties.setProperty("openorb.ORBLoader", DEFAULT_ORB_LOADER );
  +
  +        // add the logger, context and config as properties
  +
  +        properties.put("LOGGER", log );
  +        properties.put("CONTEXT", ctx );
  +        properties.put("CONFIGURATION", config );
  +       
  +        // create the ORB
   
           try
           {
  -           props.setProperty("org.omg.CORBA.ORBClass", DEFAULT_ORB_CLASS );
  -           props.setProperty("org.omg.CORBA.ORBSingletonClass", 
DEFAULT_ORB_SINGLETON );
  -            props.addProperties( m_root, m_config );
  -            if( configuration != null ) props.addProperties( m_root, 
configuration);
  -            return (ORB) ORB.init( args, props );
  +            return (ORB) ORB.init( args, properties );
           }
           catch ( Throwable e )
           {
  @@ -270,5 +286,4 @@
               throw new ConfigurationException("Unexpected excetion while 
loading configration.", e );
           }
       }
  -
   }
  
  
  
  1.2       +2 -58     
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBFactory.xml
  
  Index: DefaultORBFactory.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBFactory.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultORBFactory.xml     19 Feb 2002 14:49:39 -0000      1.1
  +++ DefaultORBFactory.xml     22 Feb 2002 16:29:35 -0000      1.2
  @@ -12,67 +12,11 @@
   -->
   
   <!--
  -ORB Factory default configuration.
  +ORB Factory configuration.
   -->
   
   <config>
       
  -   <!--
  -   The following properties constitute default properties that will be 
  -   added to the Properties instance supplied as an argument to the ORB init 
  -   function.
  -   -->
  -
  -   <property name="openorb.ORBLoader" 
value="org.apache.orb.CORBA.kernel.DefaultLoader" />
  -   <property name="openorb.debug" value="0" />
  -   <property name="openorb.debug.ShowStackTrace" value="false"/>
  -
  -   <property name="openorb.defaultInitRef" 
value="corbaname:rir:#InitialReferences" />
  -   <property name="openorb.server.enable" value="true"/>
  -   <property name="openorb.server.alias" value=""/>
  -   <property name="openorb.server.maxQueueSize" value="0x7FFFFFFF" />
  -   <property name="openorb.server.maxManagerHeldRequests" value="0x7FFFFFFF" 
/>
  -   <property name="openorb.server.minThreadPoolSize" value="2"/>
  -   <property name="openorb.server.maxThreadPoolSize" value="10"/>
  -   <property name="openorb.server.reapCloseDelay" value="600000"/>
  -   <property name="openorb.server.serverManagerClass" 
value="org.openorb.net.ServerManagerImpl"/>
  -
  -   <property name="openorb.client.reapPauseDelay" value="120000"/>
  -   <property name="openorb.client.enable" value="true"/>
  -   <property name="openorb.client.clientManagerClass" 
value="org.openorb.net.ClientManagerImpl"/>
  -
  -   <property name="openorb.pi.ORBInitInfoClass" 
value="org.openorb.PI.OpenORBInitInfo" />
  -   <property name="openorb.pi. ServerManagerClass" 
value="org.openorb.PI.SimpleServerManager" />
  -   <property name="openorb.pi.ClientManagerClass" 
value="org.openorb.PI.SimpleClientManager" />
  -   <property name="openorb.pi.IORManagerClass" 
value="org.openorb.PI.SimpleIORManager" />
  -
  -   <property name="openorb.dynany.enable" value="true" />
  -   <property name="openorb.kernel.ORBConnectorClass" 
value="org.openorb.CORBA.kernel.OpenORBConnector" />
  -   <property name="openorb.defaultInitRef" value=""/>
  -   <property name="openorb.debug" value="0"/>
  -   <property name="openorb.useStaticThreadGroup" value="false"/>
  -
  -   <property name="iiop.hostname" value=""/>
  -   <property name="iiop.publishIP" value="auto"/>
  -   <property name="iiop.listenAddress" value="0.0.0.0"/>
  -   <property name="iiop.port" value="0"/>
  -   <property name="iiop.allowBidir" value="true"/>
  -   <property name="iiop.biDirOnlyServer" value="false"/>
  -   <property name="iiop.CDRInputStreamClass" 
value="org.openorb.iiop.CDRInputStream"/>
  -   <property name="iiop.CDROutputStreamClass" 
value="org.openorb.iiop.CDROutputStream"/>
  -   <property name="iiop.IIOPTransportServerInitializerClass" 
  -         value="org.openorb.iiop.IIOPTransportServerInitializer"/>
  -   <property name="iiop.TransportClientInitializerClass" 
  -         value="org.openorb.iiop.IIOPTransportClientInitializer"/>
  -
  -   <!--
  -   The following initializer elements define the logging sub-catagory to be 
  -   be assigned for the initalization object. If the initalizer implements 
the 
  -   Composable interace, the element will be passed as a Configuration 
instance
  -   under the compose operation.
  -   -->
  -
  -   <initializer class="org.openorb.iiop.IIOPProtocolInitializer" 
name="iiop"/>
  -   <initializer class="org.openorb.adapter.poa.POAInitializer" name="poa"/>
  +   <logging channel="orb"/>
   
   </config>
  
  
  
  1.3       +8 -19     
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORB.java
  
  Index: ORB.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORB.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ORB.java  11 Feb 2002 14:52:41 -0000      1.2
  +++ ORB.java  22 Feb 2002 16:29:35 -0000      1.3
  @@ -190,28 +190,17 @@
           //
   
           Properties p = new Properties();
  -        ORBInitContext props = new ORBInitContext( p, getLogger(), 
m_context, m_config );
  +
  +        
p.setProperty("openorb.ORBLoader","org.apache.orb.CORBA.kernel.DefaultLoader");
  +        p.setProperty("org.omg.CORBA.ORBClass", "org.openorb.CORBA.ORB" );
  +       p.setProperty("org.omg.CORBA.ORBSingletonClass", 
"org.openorb.CORBA.ORBSingleton" );
  +        p.put( "CONFIGURATION", m_config );
  +        p.put( "LOGGER", getLogger().getChildLogger("orb") );
  +        p.put( "CONTEXT", m_context );
   
           try
           {
  -
  -            //
  -            // set the default ORB implemetation classes
  -            //
  -
  -           props.setProperty("org.omg.CORBA.ORBClass", DEFAULT_ORB_CLASS );
  -           props.setProperty("org.omg.CORBA.ORBSingletonClass", 
DEFAULT_ORB_SINGLETON );
  -
  -            //
  -            // set the ORB loader to be the Avalon based loader that 
understands things 
  -            // like logging, context and configurations
  -            //
  -
  -            if( System.getProperty("openorb.loader") != null )
  -              
props.setProperty("openorb.loader","org.apache.orb.CORBA.kernel.DefaultLoader");
  -            props.addProperties( m_root, m_config );
  -
  -            set_parameters( new String[0], props );
  +            set_parameters( new String[0], p );
           }
           catch ( Throwable e )
           {
  
  
  
  1.2       +1 -1      
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/package.html
  
  Index: package.html
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/package.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- package.html      2 Feb 2002 10:28:38 -0000       1.1
  +++ package.html      22 Feb 2002 16:29:35 -0000      1.2
  @@ -1,4 +1,4 @@
   
   <body>
  -<p>AN ORB Block that can be used as a formal Phoenix server block or 
embedded component.</p>
  +<p>An ORB Factory Block that can be used as a formal Phoenix server block or 
embedded component.</p>
   </body>
  
  
  
  1.5       +388 -144  
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel/DefaultLoader.java
  
  Index: DefaultLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel/DefaultLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultLoader.java        19 Feb 2002 14:49:39 -0000      1.4
  +++ DefaultLoader.java        22 Feb 2002 16:29:35 -0000      1.5
  @@ -1,35 +1,48 @@
   
   package org.apache.orb.CORBA.kernel;
   
  +import java.io.InputStream;
  +import java.io.IOException;
  +import java.io.File;
   import java.util.ArrayList;
   import java.util.Iterator;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import java.util.MissingResourceException;
  +import java.lang.reflect.Method;
   import java.net.URL;
   
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.CascadingRuntimeException;
  +import org.apache.avalon.framework.CascadingException;
   
  -import org.apache.orb.ORBInitContext;
  +import org.apache.orb.CascadingConfiguration;
   
   import org.omg.PortableInterceptor.ORBInitializer;
  +import org.omg.CORBA.CompletionStatus;
  +import org.omg.CORBA.INITIALIZE;
   
   import org.openorb.PI.ORBInitInfo;
   import org.openorb.PI.FeatureInitializer;
   import org.openorb.CORBA.MinorCodes;
  -import org.omg.CORBA.CompletionStatus;
   import org.openorb.CORBA.kernel.ORBLoader;
   import org.openorb.CORBA.kernel.Properties;
   import org.openorb.CORBA.kernel.Property;
   import org.openorb.CORBA.kernel.PropertyNotFoundException;
   import org.openorb.CORBA.kernel.Configurator;
   import org.openorb.CORBA.kernel.ORBConnector;
  -import org.openorb.CORBA.kernel.ORBBootstrapHelper;
  +
  +import org.xml.sax.SAXException;
   
   /**
    * Experimental ORB loader. 
  @@ -44,26 +57,21 @@
   
       private static final String ORBSingletonClassKey = 
"org.omg.CORBA.ORBSingletonClass";
       private static final String defaultORBSingleton = 
"org.openorb.CORBA.ORBSingleton";
  -
  +    private static java.util.Properties m_default_properties;
  +    private static Configuration m_defaults;
   
       
//=========================================================================
       // state
       
//=========================================================================
   
  -    private Properties _properties = null;
  -    private org.openorb.CORBA.ORB _orb;
       private Logger m_logger;
  -
  -    
//=========================================================================
  -    // constructor
  -    
//=========================================================================
  -
  -    /**
  -     * Constructor
  -     */
  -    public DefaultLoader()
  -    {
  -    }
  +    private Configuration m_config;
  +    private Context m_context;
  +    private Hashtable m_table = new Hashtable();
  +
  +    private Properties _properties;
  +    private File m_base;
  +    private org.openorb.CORBA.ORB m_orb;
   
       
//=========================================================================
       // implementation
  @@ -72,24 +80,27 @@
       /**
        * ORB Initialization.
        */
  -    public void init( String [] args, java.util.Properties properties, 
org.openorb.CORBA.ORB orb )
  +    public void init( String [] args, java.util.Properties props, 
org.openorb.CORBA.ORB orb )
       {
  -        // ensure this is the only time.
  -        if ( _orb != null )
  -            throw new org.omg.CORBA.INITIALIZE( "Illegal attempt to 
reinitialize the ORB." );
   
  -        _orb = orb;
  +        //
  +        // make sure this operation is not being invoked on a previously 
initalized ORB
  +        //
  +
  +        if ( m_orb != null ) throw new INITIALIZE( "Illegal attempt to 
reinitialize the ORB." );
  +
  +        m_orb = orb;
   
  +        //
           // ensure the correct singleton orb is used.
  +        //
  +
           try
           {
               System.setProperty( ORBSingletonClassKey, defaultORBSingleton );
           }
  -        catch ( SecurityException ex )
  -        {}
  -
  +        catch ( SecurityException ex ){}
           org.omg.CORBA.ORB singleton = org.omg.CORBA.ORB.init();
  -
           if ( !( singleton instanceof org.openorb.CORBA.ORBSingleton ) )
              throw new org.omg.CORBA.INITIALIZE( 
                "Unable to complete init orb singleton is not openorb 
singleton.\n" 
  @@ -97,30 +108,144 @@
                + defaultORBSingleton + "\");\n" 
                + "As the first statement in your application." );
   
  -        // Store the loader
  -        _orb.setFeature( "ORBLoader", this );
  +        //
  +        // Validate the logger.
  +        //
  +
  +        if( props != null ) m_logger = (Logger) props.get("LOGGER");
  +        if( m_logger == null ) m_logger = org.openorb.util.Trace.getLogger();
   
           //
  -        // Enable logging on the ORB
  +        // Validate the configuration and build an initializer element 
lookup table.
           //
   
  -        if(( properties != null ) && ( properties instanceof Context ))
  +        try
           {
  -            try
  +             if( m_defaults == null ) m_defaults = 
loadDefaultConfiguration();
  +        }
  +        catch( Throwable e )
  +        {
  +             throw new CascadingRuntimeException(
  +               "Internal error while attempting to resolve default 
configuration.", e );
  +        }
  +
  +        Configuration config = null;
  +        if( props != null ) config = (Configuration) 
props.get("CONFIGURATION");
  +        if( config == null ) config = new DefaultConfiguration( "default", 
null );
  +        m_config = new CascadingConfiguration( config, m_defaults );
  +        Configuration[] inits = m_config.getChildren("initializer");
  +        try
  +        {
  +            for( int i=0; i<inits.length; i++ )
               {
  -                m_logger = (Logger) ((Context)properties).get("LOGGER");
  +                m_table.put( inits[i].getAttribute("class"), inits[i] );
               }
  -            catch( Throwable e )
  +        }
  +        catch( Throwable e )
  +        {
  +            throw new CascadingRuntimeException( 
  +             "Internal error while attempt to read initalizer 
configurations.", e );
  +        }
  +
  +        //
  +        // Validate the context object.
  +        //
  +
  +        if( props != null ) m_context = (Context) props.get("CONTEXT");
  +        try
  +        {
  +            m_context.get("APP_DIR");
  +        }
  +        catch( Throwable e )
  +        {
  +            // context is null or context supplied without a base directory
  +            DefaultContext context = new DefaultContext( m_context );
  +            context.put( "APP_DIR", new File( System.getProperty("user.dir") 
) );
  +            context.makeReadOnly();
  +            m_context = context;
  +        }
  +
  +        //
  +        // get the base directory from which any property declarations that
  +        // use file attributes can be resolved
  +        //
  + 
  +        try
  +        {
  +            m_base = (File) m_context.get("APP_DIR");
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Unresolved base directory.";
  +            throw new CascadingRuntimeException( error, e );
  +        }
  +
  +        //
  +        // Create the properties argument using the default ORB properties 
as 
  +        // defaults.
  +        //
  +
  +        if( m_default_properties == null ) m_default_properties = 
getDefaultProperties(); 
  +        java.util.Properties properties = new java.util.Properties( 
m_default_properties );
  +
  +        //
  +        // Add any "initializer" element are included in the configuration 
as 
  +        // properties.
  +        //
  +
  +        Enumeration names = m_table.keys();
  +        while( names.hasMoreElements() )
  +        {
  +            String name = (String) names.nextElement();
  +            String pname = 
"org.omg.PortableInterceptor.ORBInitializerClass." + name;
  +            properties.setProperty( pname, "" );
  +        }
  +
  +        //
  +        // Add any "property" elements that are included in the supplied 
configuration
  +        //
  +
  +        try
  +        {
  +            mergeProperties( m_base, m_config, properties );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Unexpected exception while attempting to 
merge properties.";
  +            throw new CascadingRuntimeException( error, e );
  +        }
  +        
  +        //
  +        // overwrite default values with the supplied properties argument
  +        //
  +
  +        if( props != null )
  +        {
  +            Enumeration enum = props.propertyNames();
  +            while( enum.hasMoreElements() )
               {
  -                // ignore and apply default logger
  +                String name = (String) enum.nextElement();
  +                properties.setProperty( name, props.getProperty( name, "" ) 
);
               }
           }
   
  -        if( m_logger == null ) m_logger = org.openorb.util.Trace.getLogger();
  -        _orb.enableLogging( m_logger.getChildLogger( "" + 
System.identityHashCode( this ) ) );
  +        //
  +        // apply the logger to the ORB
  +        //
  +
  +        m_orb.enableLogging( m_logger );
           m_logger.debug("loading orb");
   
  +        //
  +        // Store the loader
  +        //
  +
  +        m_orb.setFeature( "ORBLoader", this );
  +
  +        //
           // create the orb init info.
  +        //
  +
           ORBInitInfo init_info;
   
           try
  @@ -132,23 +257,9 @@
               cargs[ 1 ] = orb;
               targs[ 1 ] = org.openorb.CORBA.ORB.class;
   
  -            if( properties instanceof ORBInitContext )
  -            {
  -                //load_initializers( cargs, conf.getInitializers(), 
(ORBInitContext)properties );
  -
  -                ORBInitContext context = (ORBInitContext) properties;
  -                Configuration c = context.getConfiguration();
  -                Configurator conf = new Configurator( args, 
getPropertiesFromConfiguration( c ) );
  -                _properties = conf.getProperties();
  -                load_initializers( cargs, conf.getInitializers(), context );
  -            }
  -            else
  -            {
  -                // load the properties and the list of initializers
  -                Configurator conf = new Configurator( args, properties );
  -                _properties = conf.getProperties();
  -                load_initializers( cargs, conf.getInitializers() );
  -            }
  +            Configurator conf = new Configurator( args, properties );
  +            _properties = conf.getProperties();
  +            load_initializers( cargs, conf.getInitializers() );
   
               targs[ 2 ] = ORBInitializer[].class;
               targs[ 3 ] = FeatureInitializer[].class;
  @@ -164,12 +275,15 @@
   
           init_info.pre_init();
   
  +        // set the stack trace option
  +        org.openorb.util.Trace.setShowStackTrace( 
  +          _properties.getBooleanProperty( "openorb.debug.ShowStackTrace", 
false ) );
  +
           try
           {
               ORBConnector orb_connector = ( ORBConnector ) constructClass( 
                "openorb.kernel.ORBConnectorClass", 
"org.openorb.CORBA.kernel.OpenORBConnector", null );
  -
  -            orb_connector.load_kernel( _orb, this );
  +            orb_connector.load_kernel( m_orb, this );
           }
           catch ( Throwable ex )
           {
  @@ -181,30 +295,6 @@
           init_info.post_init();
       }
   
  -    private java.util.Properties getPropertiesFromConfiguration( 
Configuration config )
  -    throws ConfigurationException
  -    {
  -        java.util.Properties p = new java.util.Properties();
  -
  -        Configuration[] props = config.getChildren("property");
  -        for( int i=0; i<props.length; i++ )
  -        {
  -            Configuration property = props[i];
  -            p.setProperty( property.getAttribute("name"), 
property.getAttribute("value") );
  -        }
  -
  -        Configuration[] inits = config.getChildren("initializer");
  -        for( int i=0; i<inits.length; i++ )
  -        {
  -            Configuration init = inits[i];
  -            String name = init.getAttribute("class");
  -            p.setProperty( 
  -              "org.omg.PortableInterceptor.ORBInitializerClass." + name, 
name );
  -        }
  -
  -        return p;
  -    }
  -
       /**
        * This operation is used to display an OpenORB configuration.
        */
  @@ -242,10 +332,10 @@
           {
               m_logger.debug(
                   
"\n----------------------------------------------------------------------------------------"
  -              + "OpenORB debugging session "
  -              + "Session : Intra verbose mode"
  -              + 
"----------------------------------------------------------------------------------------"
  -              + "Current configuration :"
  +              + "\nOpenORB debugging session "
  +              + "\nSession : Intra verbose mode"
  +              + 
"\n----------------------------------------------------------------------------------------"
  +              + "\nCurrent configuration :"
               );
               display_configuration( m_logger );
               m_logger.debug(
  @@ -501,24 +591,11 @@
   
       private void load_initializers( Object [] args, String [] cls_names )
       {
  -        load_initializers( args, cls_names, null );
  -    }
  -
  -    private void load_initializers( Object [] args, String [] cls_names, 
ORBInitContext context )
  -    {
           ArrayList orbInits = new ArrayList( cls_names.length );
           ArrayList openOrbInits = new ArrayList( cls_names.length );
           
  -        Logger logger = null;
  -        Context base = null;
  -
  -        if( context != null )
  -        {
  -            logger = context.getBaseLogger();
  -            base = context.getBaseContext();
  -            if( logger != null ) if( logger.isDebugEnabled() ) logger.debug(
  +        if( m_logger.isDebugEnabled() ) m_logger.debug(
                 "handling " + cls_names.length + " initializers" );
  -        }
   
           for ( int i = 0; i < cls_names.length; ++i )
           {
  @@ -527,10 +604,8 @@
               try
               {
                   instance = Class.forName( cls_names[ i ] ).newInstance();
  -                if( logger != null ) if( logger.isDebugEnabled() ) 
logger.debug(
  -                   "loading initializer: " + cls_names[i] );
               }
  -            catch ( Exception ex )
  +            catch ( Throwable ex )
               {
                   final String error = "Unable to load initializer class: " +  
cls_names[ i ];
                   throw new CascadingRuntimeException( error, ex );
  @@ -538,61 +613,62 @@
   
               boolean ok = false;
   
  -            Configuration config = null;
  -            if( context != null )
  -            {
  -                config = context.getConfigurationByClassName( cls_names[i] );
  -                final String name = config.getAttribute("name", null );
  +            Configuration config = (Configuration) m_table.get( cls_names[i] 
);
  +            if( config == null ) config = new DefaultConfiguration( "-", 
null );
   
  -                //
  -                // provide the initalizer with a logger
  -                //
  +            final String name = config.getAttribute("name", "initializer-" 
  +              + System.identityHashCode( instance ) );
   
  -                if( instance instanceof LogEnabled )
  +            if( m_logger.isDebugEnabled() ) m_logger.debug(
  +                   "loading initializer: " + cls_names[i] + " (catagory: " + 
name + ")");
  +
  +            //
  +            // provide the initalizer with a logger
  +            //
  +
  +            if( instance instanceof LogEnabled )
  +            {
  +                if( name != null )
                   {
  -                    if( name != null )
  -                    {
  -                        ((LogEnabled)instance).enableLogging( 
logger.getChildLogger( name ) );
  -                    }
  -                    else
  -                    {
  -                        ((LogEnabled)instance).enableLogging( logger );
  -                    }
  +                    ((LogEnabled)instance).enableLogging( 
m_logger.getChildLogger( name ) );
                   }
  -
  +                else
  +                {
  +                    ((LogEnabled)instance).enableLogging( m_logger );
  +                }
  +            }
    
  -                //
  -                // contextualize the initalizer
  -                //
  +            //
  +            // contextualize the initalizer
  +            //
   
  -                if( instance instanceof Contextualizable )
  +            if( instance instanceof Contextualizable )
  +            {
  +                try
                   {
  -                    try
  -                    {
  -                        ((Contextualizable)instance).contextualize( base );
  -                    }
  -                    catch( Exception e )
  -                    {
  -                        final String error = "Unexpected exeption while 
contextualizing interceptor.";
  -                        throw new CascadingRuntimeException( error, e ); 
  -                    }
  +                    ((Contextualizable)instance).contextualize( m_context );
                   }
  +                catch( Throwable e )
  +                {
  +                    final String error = "Unexpected exeption while 
contextualizing interceptor.";
  +                    throw new CascadingRuntimeException( error, e ); 
  +                }
  +            }
   
  -                //
  -                // configure the initalizer
  -                //
  +            //
  +            // configure the initalizer
  +            //
   
  -                if( instance instanceof Configurable )
  +            if( instance instanceof Configurable )
  +            {
  +                try
                   {
  -                    try
  -                    {
  -                        ((Configurable)instance).configure( config );
  -                    }
  -                    catch( Exception e )
  -                    {
  -                        final String error = "Unexpected exeption while 
configuring interceptor.";
  -                        throw new CascadingRuntimeException( error, e );
  -                    }
  +                    ((Configurable)instance).configure( config );
  +                }
  +                catch( Throwable e )
  +                {
  +                    final String error = "Unexpected exeption while 
configuring interceptor.";
  +                    throw new CascadingRuntimeException( error, e );
                   }
               }
   
  @@ -621,4 +697,172 @@
           openOrbInits.toArray( ( Object[] ) args[ 3 ] );
       }
   
  +    
//============================================================================
  +    // static methods to load default ORB properties
  +    
//============================================================================
  +
  +   /**
  +    * Returns the default ORB properties 
  +    */
  +    public static java.util.Properties getDefaultProperties( ) 
  +    {
  +        final String path = "org/apache/orb/CORBA/kernel/orb.properties";
  +        java.util.Properties properties = new java.util.Properties();
  +        try
  +        {
  +            InputStream is = 
DefaultLoader.class.getClassLoader().getResourceAsStream( path ); 
  +            if( is == null ) throw new RuntimeException( 
  +               "Could not find the default 'orb.properties' resource from 
path: " + path ); 
  +            properties.load( is );
  +        }
  +        catch( Throwable e )
  +        {
  +            throw new CascadingRuntimeException("Unexpected exception while 
loading configration.", e );
  +        }
  +        finally
  +        {
  +            return properties;
  +        }
  +    }
  +
  +   /**
  +    * Returns the default configuration resource. 
  +    */
  +    private static Configuration loadDefaultConfiguration( ) 
  +        throws MissingResourceException, ConfigurationException
  +    {
  +        try
  +        {
  +            InputStream is = 
DefaultLoader.class.getClassLoader().getResourceAsStream( 
  +              "org/apache/orb/CORBA/kernel/DefaultLoader.xml" ); 
  +            if( is != null )
  +            {
  +                DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder( );
  +                return builder.build( is );
  +            }
  +            else
  +            {
  +                throw new MissingResourceException(
  +                  "Null input stream.", DefaultLoader.class.getName(), 
  +                  "org/apache/orb/CORBA/kernel/DefaultLoader.xml"  );
  +            }
  +        }
  +        catch( SAXException e )
  +        {
  +            throw new CascadingRuntimeException(
  +              "Internal SAX exception while attempting to load 
configuration.", e );
  +        }
  +        catch( IOException e )
  +        {
  +            throw new CascadingRuntimeException(
  +              "Internal IO exception while attempting to load 
configuration.", e );
  +        }
  +    }
  +
  +   /**
  +    * Adds property declarations to the supplied Properties argument from 
the 
  +    * supplied configuration.  
  +    * Any configuration elements of the following form will be translated 
  +    * to property values and added to the property set.
  +    *
  +    * <pre>
  +    *   &lt;any-containing-element&gt;
  +    *      &lt;property name="myProperty" value="someValue"/&gt;
  +    *      &lt;property name="info" file="eggs.xml"/&gt;
  +    *   &lt;/any-containing-element&gt;
  +    * </pre>
  +    *
  +    * @param root the file path to be used in resolution of property 
  +    *   element in the configuration that contain 'file' attributes as 
  +    *   the property value
  +    * @param configuration a configuration containing 'property' element 
declarations
  +    */
  +    public void mergeProperties( File root, Configuration config, 
java.util.Properties properties ) throws Exception 
  +    {
  +       Configuration[] props = config.getChildren("property");
  +       for( int i = 0; i< props.length; i++ )
  +        {
  +             Configuration child = props[i];
  +
  +             //
  +             // every property must have a name
  +             //
  +
  +             String name = "";
  +             try
  +             {
  +                 name = child.getAttribute("name");
  +             }
  +             catch( ConfigurationException noName )
  +           {
  +                 final String error = "encountered a property without a 
name";
  +                 throw new CascadingException ( error, noName );
  +             }
  +
  +             //
  +             // The value of a property is either declared directly under a 
value attribute, 
  +             // or indirectory under a 'file' attribute.  In the case of 
'file' attributes
  +             // we need to resolve this relative to this file before setting 
the 
  +             // property value.
  +             //
  +
  +             String value = "";
  +             try
  +             {
  +                 value = child.getAttribute("value");
  +             }
  +             catch( ConfigurationException noValueAttribute )
  +           {
  +                 try
  +                 {
  +                     final String s = child.getAttribute("file");
  +                       File f = new File( root, s );
  +                       value = f.getAbsolutePath();
  +                 }
  +                 catch( ConfigurationException noFileAttribute )
  +                 {
  +                       String s = null;
  +                       try
  +                       {
  +                         s = child.getAttribute("url");
  +                       }
  +                       catch( Exception noURL )
  +                       {
  +                             final String error = "Found a property without 
a 'value', 'file' or 'url' attribute";
  +                         throw new CascadingException( error, noURL );
  +                       }
  +                       if( s.startsWith("file:"))
  +                    {
  +                           try
  +                           {
  +                                 URL base = root.toURL();
  +                               URL url = new URL( base, s );
  +                               value = url.toString();
  +                           }
  +                           catch( Exception unknown )
  +                           {
  +                                 final String error = "Unexpected exception 
while creating file:// URL value.";
  +                             throw new Exception( error, unknown );
  +                             }
  +                       }
  +                       else
  +                       {
  +                           try
  +                           {
  +                               URL url = new URL( s );
  +                               value = url.toString();
  +                           }
  +                           catch( Exception unknown )
  +                           {
  +                                 final String error = "Unexpected exception 
while creating URL value.";
  +                             throw new Exception( error 
  +                                     + "\n" + "cause: " + 
unknown.getClass().getName() + ", " 
  +                                     + "\n" + unknown.getMessage(), unknown 
);
  +                             }
  +                       }
  +                 }
  +             }
  +             properties.setProperty( name, value );
  +        }
  +    }
   }
  
  
  
  1.1                  
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel/DefaultLoader.xml
  
  Index: DefaultLoader.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
  DefaultLoader.xml
  -->
  
  <config>
        
     <!--
     The following initializer elements define the logging sub-catagory to be 
     be assigned for the initalization object.
     -->
  
     <initializer class="org.openorb.iiop.IIOPProtocolInitializer" name="iiop"/>
     <initializer class="org.openorb.adapter.poa.POAInitializer" name="poa"/>
  
  </config>
  
  
  
  1.1                  
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel/orb.properties
  
  Index: orb.properties
  ===================================================================
  
  #
  # Default property table used by the ORB loader.  These property 
  # declarations consititute default values that may be overriden or
  # supplimented by any property or initializer declarations in
  # DefaultLoder.xml or properties and/or configuration supplied as 
  # arguments to the orb load init method.
  #
  
  openorb.ORBLoader=org.apache.orb.CORBA.kernel.DefaultLoader
  
  org.omg.CORBA.ORBClass=org.apache.orb.ORB
  org.omg.CORBA.ORBSingletonClass=org.openorb.CORBA.ORBSingleton
  
  openorb.debug=0
  openorb.debug.ShowStackTrace=false
  
  openorb.defaultInitRef=corbaname:rir:#InitialReferences
  openorb.server.enable=true
  openorb.server.maxQueueSize=0x7FFFFFFF
  openorb.server.maxManagerHeldRequests=0x7FFFFFFF
  openorb.server.minThreadPoolSize=2
  openorb.server.maxThreadPoolSize=10
  openorb.server.reapCloseDelay=600000
  openorb.server.serverManagerClass=org.openorb.net.ServerManagerImpl
  
  openorb.client.reapPauseDelay=120000
  openorb.client.enable=true
  openorb.client.clientManagerClass=org.openorb.net.ClientManagerImpl
  
  openorb.pi.ORBInitInfoClass=org.openorb.PI.OpenORBInitInfo
  openorb.pi.ServerManagerClass=org.openorb.PI.SimpleServerManager
  openorb.pi.ClientManagerClass=org.openorb.PI.SimpleClientManager
  openorb.pi.IORManagerClass=org.openorb.PI.SimpleIORManager
  
  openorb.dynany.enable=true
  openorb.kernel.ORBConnectorClass=org.openorb.CORBA.kernel.OpenORBConnector
  openorb.debug=0
  openorb.useStaticThreadGroup=false
  
  iiop.publishIP=auto
  iiop.listenAddress=0.0.0.0
  iiop.port=0
  iiop.allowBidir=true
  iiop.biDirOnlyServer=false
  iiop.CDRInputStreamClass=org.openorb.iiop.CDRInputStream
  iiop.CDROutputStreamClass=org.openorb.iiop.CDROutputStream
  
iiop.IIOPTransportServerInitializerClass=org.openorb.iiop.IIOPTransportServerInitializer
  
iiop.TransportClientInitializerClass=org.openorb.iiop.IIOPTransportClientInitializer
  
  
org.omg.PortableInterceptor.ORBInitializerClass.org.openorb.iiop.IIOPProtocolInitializer=iiop
  
org.omg.PortableInterceptor.ORBInitializerClass.org.openorb.adapter.poa.POAInitializer=poa
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to