avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel DefaultLoader.java
Date Mon, 11 Feb 2002 14:47:16 GMT
mcconnell    02/02/11 06:47:16

  Modified:    apps/enterprise/orb/lib openorb-1.2.2.jar
                        openorb_tools-1.2.2.jar
               apps/enterprise/orb/src/java/org/apache/orb ORBContext.java
               apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel
                        DefaultLoader.java
  Added:       apps/enterprise/orb/src/java/org/apache/orb
                        CascadingConfiguration.java DefaultORBContext.java
                        DefaultORBFactory.java DefaultORBFactory.xinfo
                        ORB.java ORB.xinfo ORBFactoryService.java
                        ORBInitContext.java
  Removed:     apps/enterprise/orb/src/java/org/apache/orb
                        DefaultFactory.java DefaultFactory.xinfo
                        FactoryService.java
  Log:
  no message
  
  Revision  Changes    Path
  1.3       +417 -439  jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb-1.2.2.jar
  
  	<<Binary file>>
  
  
  1.3       +47 -61    jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb_tools-1.2.2.jar
  
  	<<Binary file>>
  
  
  1.3       +13 -368   jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORBContext.java
  
  Index: ORBContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORBContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ORBContext.java	6 Feb 2002 09:46:43 -0000	1.2
  +++ ORBContext.java	11 Feb 2002 14:47:15 -0000	1.3
  @@ -7,383 +7,28 @@
   
   package org.apache.orb;
   
  -import java.util.Map;
  -import java.io.InputStream;
  -import java.io.IOException;
  -import java.io.File;
  -import java.net.URL;
  -
  +import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.DefaultContext;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
  -import org.apache.avalon.framework.CascadingRuntimeException;
  -import org.apache.avalon.framework.logger.Logger;
  +
  +import org.omg.CORBA_2_3.ORB;
   
   /**
  - * The ORBContext is an interface facilitating access to the runtime ORB.  The
  - * ORB instance exposed by the <code>getOrb</code> operation is an ORB supporting
  - * the CORBA 2.3 portability specification.
  - * @author Stephen McConnell <mcconnell@osm.net>
  + * The <code>ORBContext</code> interface defines a <code>Context</code> type that 
  + * holds an ORB instance.
  + *
  + * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
    */
  -public class ORBContext extends java.util.Properties implements Context
  -{
  -    //=============================================================================
  -    // state
  -    //=============================================================================
  -
  -    private final Context m_parent;
  -    private boolean m_readOnly = false;
  -    private Configuration m_config;
  -    private Configuration m_default_config;
  -    private Logger m_logger;
  -
  -    //=============================================================================
  -    // constructors
  -    //=============================================================================
  -
  -    /**
  -     * Create a Context with specified data and parent.
  -     *
  -     * @param data the initial context data
  -     * @param logger the logger to be used for ORB logging
  -     * @param context the context to be used during contextualization of 
  -     *   ORB subsystems
  -     * @param config optional configuration argument containing initializer 
  -     *   configuation information (may be null)
  -     * @param defaults optional fallback configuration argument containing initializer 
  -     *   configuation information (may be null)
  -     */
  -    public ORBContext( final java.util.Properties data, final Logger logger, 
  -      final Context context, final Configuration config, final Configuration defaults )
  -    {
  -        super( data );
  -        m_logger = logger;
  -        m_parent = context;
  -        m_config = config;
  -        m_default_config = defaults;
  -    }
  -
  -    //=============================================================================
  -    // ORBContext
  -    //=============================================================================
  -
  -   /**
  -    * Returns the logger to be used for ORB logging and 
  -    * log enablement of ORB subsytems.
  -    */
  -    public Logger getBaseLogger()
  -    {
  -        return m_logger;
  -    }
  -
  -   /**
  -    * Returns a Context object to be applied during the contextualization 
  -    * phase of ORB subsytems.
  -    *
  -    * @param name the name of the initalizer class
  -    */
  -    public Context getBaseContext()
  -    {
  -        return m_parent;
  -    }
  -
  -   /**
  -    * Returns an initializer configuration based on a supplied 
  -    * initializer class name.
  -    * @param name the name of the initalizer class
  -    */
  -    public Configuration getConfigurationByClassName( String name )
  -    {
  -        return getConfigurationByClassName( name, true );
  -    }
  -
  -   /**
  -    * Returns an initializer configuration based on a supplied 
  -    * initializer class name.
  -    * @param name the name of the initalizer class
  -    * @param policy if no initializer configaration 
  -    *   matching the supplied name can be found, and the policy argument
  -    *   is TRUE (the default), an non-null empty configuration will be 
  -    *   returned, otherwise if policy is FALSE implementation will return 
  -    *   a null value
  -    */
  -    public Configuration getConfigurationByClassName( String name, boolean policy )
  -    {
  -        if( m_config != null )
  -        {
  -            Configuration config = getByClassName( m_config, name );
  -            if( config != null ) return config;
  -        }
  -
  -        if( m_default_config != null )
  -        {
  -            Configuration def = getByClassName( m_default_config, name );
  -            if( def != null ) return def;
  -        }
  -
  -        if( policy ) return new DefaultConfiguration( name, "-" );
  -        return null;
  -    }
  -
  -   /**
  -    * Locate an initializer element based on a supplied class name.
  -    */
  -    private Configuration getByClassName( Configuration config, String name )
  -    {
  -        Configuration[] children = config.getChildren("initializer");
  -        for( int i=0; i<children.length; i++ )
  -        {
  -            try
  -            {
  -                if( children[i].getAttribute("class").equals( name ) ) return children[i];
  -            }
  -            catch( Exception e )
  -            {
  -                final String error = "Configuration " + m_config.getName() 
  -                 + " contains an initializer element with a missing 'class' attribute.";
  -                throw new CascadingRuntimeException( error, e );
  -            }
  -        }
  -        return null;
  -    }
  -
   
  -    //=============================================================================
  -    // Context
  -    //=============================================================================
  -
  -    /**
  -     * Retrieve an item from the Context.
  -     *
  -     * @param key the key of item
  -     * @return the item stored in context
  -     * @exception ContextException if item not present
  -     */
  -    public Object get( final Object key )
  -    {
  -
  -        // handle special keys
  -
  -        if( key instanceof String ) 
  -        {
  -            final String name = ((String)key);
  -            if( name.equalsIgnoreCase("LOGGER") ) return m_logger;
  -            if( name.equalsIgnoreCase("CONTEXT") ) return m_parent;
  -            if( name.equalsIgnoreCase("CONFIGURATION") ) return m_config;
  -        }
  -
  -        // handle general keys
  -
  -        final Object data = super.get( key );
  -        if( null != data ) return data;
  -
  -        // check the parent
  -
  -        if( null == m_parent ) return null;
  -        try
  -        {
  -            return m_parent.get( key );
  -        }
  -        catch( Exception e )
  -        {
  -            return null;
  -        }
  -    }
  -
  -    //=============================================================================
  -    // implementation
  -    //=============================================================================
  -
  -    /**
  -     * Helper method for adding items to Context.
  -     *
  -     * @param key the items key
  -     * @param value the item
  -     * @exception IllegalStateException if context is read only
  -     * @exception IllegalArgumentException if the key is a string with 
  -     *   conflicting with the reserved names "LOGGER", "CONTEXT" or 
  -     *   "CONFIGURATION"
  -     */
  -    public Object put( final Object key, final Object value )
  -        throws IllegalStateException
  -    {
  -        if( key instanceof String ) 
  -        {
  -            final String name = ((String)key);
  -            if(( name.equalsIgnoreCase("LOGGER") ) || ( name.equalsIgnoreCase("CONTEXT") )
  -              || ( name.equalsIgnoreCase("CONFIGURATION") ) ) throw new IllegalArgumentException(
  -                "Cannot put value under reserved key: " + key );
  -        }
  -        checkWriteable();
  -        return put( key, value );
  -    }
  -
  -    /**
  -     * Make the context read-only.
  -     * Any attempt to write to the context via put()
  -     * will result in an IllegalStateException.
  -     */
  -    public void makeReadOnly()
  -    {
  -        m_readOnly = true;
  -    }
  +public interface ORBContext extends Context, Component
  +{
   
  -    /**
  -     * Utility method to check if context is writeable and if not throw exception.
  -     *
  -     * @exception IllegalStateException if context is read only
  -     */
  -    protected final void checkWriteable()
  -        throws IllegalStateException
  -    {
  -        if( m_readOnly )
  -        {
  -            throw new IllegalStateException( "Context is read only and can not be modified" );
  -        }
  -    }
  +    public static final String ORB_KEY = "ORB";
   
      /**
  -    * Add properties to the instance based on a supplied configuration.  Property 
  -    * declarations with a file attribute will be expanded relative to the current
  -    * working directory.
  -    *
  -    * @see #addProperties( Configuration, File )
  -    * @param configuration a configuration containing 'property' element declarations
  +    * Returns the ORB.
  +    * @return ORB the object request broker
       */
  -    public void addProperties( Configuration configuration ) throws Exception 
  -    {
  -        addProperties( configuration, new File( System.getProperty("user.work")) );
  -    }
  -
  -   /**
  -    * Add properties to the instance based on a supplied configuration.  
  -    * Any configuration elements of the following form will be translated 
  -    * to property values and added to the property set.
  -    *
  -    * <pre>
  -    *   
  -    *    <property name="myProperty" value="the-property-value"/>
  -    *    <property name="info" file="eggs.xml"/>
  -    * 
  -    * </pre>
  -    *
  -    * The return value is suitable for passing to an ORB.init() method as a 
  -    * <code>java.util.Properties</code> instance.
  -    *
  -    * @param configuration a configuration containing 'property' element declarations
  -    * @param root the file path to be used in resolution of property 
  -    *   element in the configuration that contain 'file' attributes as 
  -    *   the property value
  -    */
  -    public void addProperties( Configuration configuration, File root ) throws Exception 
  -    {
  -	  Configuration[] props = configuration.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 Exception ( 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 Exception( 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 );
  -				}
  -			  }
  -		    }
  -		}
  -		setProperty( name, value );
  -        }
  -    }
  -
  -
  -    //=============================================================================
  -    // override properties operations
  -    //=============================================================================
  -
  -    public void load(InputStream input ) throws IOException
  -    {
  -        checkWriteable();
  -        super.load( input );
  -    }
  -
  -    public synchronized Object setProperty(String key, String value) {
  -        checkWriteable();
  -        return super.put(key, value);
  -    }
  +    public ORB getORB( );
   
   }
  -
  -
  -
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CascadingConfiguration.java
  
  Index: CascadingConfiguration.java
  ===================================================================
  /**
   * File: CascadingConfiguration.java
   * License: etc/LICENSE.TXT
   * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   * Copyright: OSM SARL 2001-2002, All Rights Reserved.
   */
  
  package org.apache.orb;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  
  /**
   * The CascadingConfiguration is a classic Configuration backed by parent 
   * Configuration.  Operations such as getChild return a CascadingConfiguration
   * encapsulating both a primary and parent configuration.  Requests for attribute
   * values are resolved against the base configuration initially.  If the result
   * of the resolution is unsucessful, the request is applied against the parent
   * configuration.  As a parent may also be a CascadingConfiguration, the evaluation
   * will be applied until a value is resolved against a class parent Configuration.
   * @author Stephen McConnell <mcconnell@osm.net>
   */
  public class CascadingConfiguration implements Configuration
  {
      //=============================================================================
      // state
      //=============================================================================
  
      private final Configuration m_base;
      private final Configuration m_parent;
  
      //=============================================================================
      // constructors
      //=============================================================================
  
      /**
       * Create a CascadingConfiguration with specified parent.  The base
       * configuration shall override a parent configuration on request for 
       * attribute values and configuration body values.  Unresolved request
       * are redirected up the parent chain until a classic configuration is
       * reached.  Request for child configurations will return a 
       * new CascadingConfiguration referencing the child of the base and 
       * the child of the primary (i.e. a child configuration chain).
       *
       * @param base the base Configuration
       * @param parent the parent Configuration 
       */
      public CascadingConfiguration( final Configuration base , final Configuration parent )
      {
          if( base == null ) 
          {
              m_base = new DefaultConfiguration( "-", null );
          }
          else
          {
              m_base = base;
          }
          if( parent == null ) 
          {
              m_parent = new DefaultConfiguration( "-", null );
          }
          else
          {
              m_parent = parent;
          }
      }
  
      //=============================================================================
      // Configuration
      //=============================================================================
  
      /**
       * Return the name of the base node.
       * @return name of the <code>Configuration</code> node.
       */
      public String getName()
      {
          return m_base.getName();
      }
  
      /**
       * Return a string describing location of the base Configuration.
       * Location can be different for different mediums (ie "file:line" for normal XML files or
       * "table:primary-key" for DB based configurations);
       *
       * @return a string describing location of Configuration
       */
      public String getLocation()
      {
          return m_base.getLocation();
      }
  
      /**
       * Returns the namespace the main Configuration node
       * belongs to.
       * @since 4.1
       * @return a Namespace identifying the namespace of this Configuration.
       */
      public String getNamespace() throws ConfigurationException
      {
          return m_base.getNamespace();
      }
  
      /**
       * Return a new <code>CascadingConfiguration</code> instance encapsulating the
       * specified child node of the base and parent node.
       *
       * @param child The name of the child node.
       * @return Configuration
       */
      public Configuration getChild( String child )
      {
          return new CascadingConfiguration( m_base.getChild( child ), m_parent.getChild( child ) );
      }
  
      /**
       * Return a <code>Configuration</code> instance encapsulating the specified
       * child node.
       *
       * @param child The name of the child node.
       * @param createNew If <code>true</code>, a new <code>Configuration</code>
       * will be created and returned if the specified child does not exist in either
       * the base or parent configuratioin. If <code>false</code>, <code>null</code> 
       * will be returned when the specified child doesn't exist in either the base or 
       * the parent.
       * @return Configuration
       */
      public Configuration getChild( String child, boolean createNew )
      {
          if( createNew ) return getChild( child );
          Configuration c = m_base.getChild( child, false );
          if( child != null ) return c;
          return m_parent.getChild( child, false );
      }
  
      /**
       * Return an <code>Array</code> of <code>Configuration</code>
       * elements containing all node children of both base and parent configurations. 
       * The array order will reflect the order in the source config file, commencing
       * with the base configuration.
       *
       * @return All child nodes 
       */
      public Configuration[] getChildren()
      {
          Configuration[] b = m_base.getChildren( );
          Configuration[] p = m_parent.getChildren( );
          Configuration[] result = new Configuration[ b.length + p.length ];
          System.arraycopy(b, 0, result, 0, b.length );
          System.arraycopy(p, 0, result, b.length, p.length );
          return result;
      }
  
      /**
       * Return an <code>Array</code> of <code>Configuration</code>
       * elements containing all node children with the specified name from 
       * both base and parent configurations. The array
       * order will reflect the order in the source config file commencing 
       * with the base configuration.
       *
       * @param name The name of the children to get.
       * @return The child nodes with name <code>name</code>
       */
      public Configuration[] getChildren( String name )
      {
          Configuration[] b = m_base.getChildren( name );
          Configuration[] p = m_parent.getChildren( name );
          Configuration[] result = new Configuration[ b.length + p.length ];
          System.arraycopy(b, 0, result, 0, b.length );
          System.arraycopy(p, 0, result, b.length, p.length );
          return result;
      }
  
      /**
       * Return an array of all attribute names in both base and parent.
       * <p>
       * <em>The order of attributes in this array can not be relied on.</em> As
       * with XML, a <code>Configuration</code>'s attributes are an
       * <em>unordered</em> set. If your code relies on order, eg
       * <tt>conf.getAttributeNames()[0]</tt>, then it is liable to break if a
       * different XML parser is used.
       * </p>
       */
      public String[] getAttributeNames()
      {
          java.util.Vector vector = new java.util.Vector();
          String[] names = m_base.getAttributeNames();
          String[] names2 = m_parent.getAttributeNames();
          for( int i=0; i<names.length; i++ )
          {
              vector.add( names[i] );
          }
          for( int i=0; i<names2.length; i++ )
          {
              if( vector.indexOf( names2[i] ) < 0 ) vector.add( names2[i] );
          }
          return (String[]) vector.toArray( new String[0] );
      }
  
      /**
       * Return the value of specified attribute.  If the base configuration
       * does not contain the attribute, the equivialent operation is applied to 
       * the parent configuration.
       *
       * @param paramName The name of the parameter you ask the value of.
       * @return String value of attribute.
       * @exception ConfigurationException If no attribute with that name exists.
       */
      public String getAttribute( String paramName ) throws ConfigurationException
      {
          try
          {
              return m_base.getAttribute( paramName );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttribute( paramName );
          }
      }
  
      /**
       * Return the <code>int</code> value of the specified attribute contained
       * in this node or the parent.
       * @param paramName The name of the parameter you ask the value of.
       * @return int value of attribute
       * @exception ConfigurationException If no parameter with that name exists.
       *                                   or if conversion to <code>int</code> fails.
       */
      public int getAttributeAsInteger( String paramName ) throws ConfigurationException
      {
          try
          {
              return m_base.getAttributeAsInteger( paramName );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsInteger( paramName );
          }
      }
  
      /**
       * Returns the value of the attribute specified by its name as a
       * <code>long</code>.
       *
       * @param paramName The name of the parameter you ask the value of.
       * @return long value of attribute
       * @exception ConfigurationException If no parameter with that name exists.
       *                                   or if conversion to <code>long</code> fails.
       */
      public long getAttributeAsLong( String name ) throws ConfigurationException
      {
          try
          {
              return m_base.getAttributeAsLong( name );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsLong( name );
          }
      }
  
  
      /**
       * Return the <code>float</code> value of the specified parameter contained
       * in this node.
       * @param paramName The name of the parameter you ask the value of.
       * @return float value of attribute
       * @exception ConfigurationException If no parameter with that name exists.
       *                                   or if conversion to <code>float</code> fails.
       */
      public float getAttributeAsFloat( String paramName ) throws ConfigurationException
      {
          try
          {
              return m_base.getAttributeAsFloat( paramName );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsFloat( paramName );
          }
      }
  
  
      /**
       * Return the <code>boolean</code> value of the specified parameter contained
       * in this node.<br>
       *
       * @param paramName The name of the parameter you ask the value of.
       * @return boolean value of attribute
       * @exception ConfigurationException If no parameter with that name exists.
       *                                   or if conversion to <code>boolean</code> fails.
       */
      public boolean getAttributeAsBoolean( String paramName ) throws ConfigurationException
      {
          try
          {
              return m_base.getAttributeAsBoolean( paramName );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsBoolean( paramName );
          }
      }
  
      /**
       * Return the <code>String</code> value of the node.
       *
       * @return the value of the node.
       */
      public String getValue() throws ConfigurationException
      {
          try
          {
              return m_base.getValue();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValue();
          }
      }
  
  
      /**
       * Return the <code>int</code> value of the node.
       *
       * @exception ConfigurationException If conversion to <code>int</code> fails.
       */
      public int getValueAsInteger() throws ConfigurationException
      {
          try
          {
              return m_base.getValueAsInteger();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsInteger();
          }
      }
  
      /**
       * Return the <code>float</code> value of the node.
       *
       * @return the value of the node.
       * @exception ConfigurationException If conversion to <code>float</code> fails.
       */
      public float getValueAsFloat() throws ConfigurationException
      {
          try
          {
              return m_base.getValueAsFloat();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsFloat();
          }
      }
  
      /**
       * Return the <code>boolean</code> value of the node.
       *
       * @return the value of the node.
       * @exception ConfigurationException If conversion to <code>boolean</code> fails.
       */
      public boolean getValueAsBoolean() throws ConfigurationException
      {
          try
          {
              return m_base.getValueAsBoolean();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsBoolean();
          }
      }
  
      /**
       * Return the <code>long</code> value of the node.<br>
       *
       * @return the value of the node.
       * @exception ConfigurationException If conversion to <code>long</code> fails.
       */
      public long getValueAsLong() throws ConfigurationException
      {
          try
          {
              return m_base.getValueAsLong();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsLong();
          }
      }
  
      /**
       * Returns the value of the configuration element as a <code>String</code>.
       * If the configuration value is not set, the default value will be
       * used.
       *
       * @param defaultValue The default value desired.
       * @return String value of the <code>Configuration</code>, or default
       *          if none specified.
       */
      public String getValue( String defaultValue )
      {
          try
          {
              return m_base.getValue();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValue( defaultValue );
          }
      }
  
  
      /**
       * Returns the value of the configuration element as an <code>int</code>.
       * If the configuration value is not set, the default value will be
       * used.
       *
       * @param defaultValue The default value desired.
       * @return int value of the <code>Configuration</code>, or default
       *          if none specified.
       */
      public int getValueAsInteger( int defaultValue )
      {
          try
          {
              return m_base.getValueAsInteger();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsInteger( defaultValue );
          }
      }
  
  
      /**
       * Returns the value of the configuration element as a <code>long</code>.
       * If the configuration value is not set, the default value will be
       * used.
       *
       * @param defaultValue The default value desired.
       * @return long value of the <code>Configuration</code>, or default
       *          if none specified.
       */
      public long getValueAsLong( long defaultValue )
      {
          try
          {
              return m_base.getValueAsLong();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsLong( defaultValue );
          }
      }
  
  
      /**
       * Returns the value of the configuration element as a <code>float</code>.
       * If the configuration value is not set, the default value will be
       * used.
       *
       * @param defaultValue The default value desired.
       * @return float value of the <code>Configuration</code>, or default
       *          if none specified.
       */
      public float getValueAsFloat( float defaultValue )
      {
          try
          {
              return m_base.getValueAsFloat();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsFloat( defaultValue );
          }
      }
  
  
      /**
       * Returns the value of the configuration element as a <code>boolean</code>.
       * If the configuration value is not set, the default value will be
       * used.
       *
       * @param defaultValue The default value desired.
       * @return boolean value of the <code>Configuration</code>, or default
       *          if none specified.
       */
      public boolean getValueAsBoolean( boolean defaultValue )
      {
          try
          {
              return m_base.getValueAsBoolean();
          }
          catch( ConfigurationException e )
          {
              return m_parent.getValueAsBoolean( defaultValue );
          }
      }
  
  
      /**
       * Returns the value of the attribute specified by its name as a
       * <code>String</code>, or the default value if no attribute by
       * that name exists or is empty.
       *
       * @param name The name of the attribute you ask the value of.
       * @param defaultValue The default value desired.
       * @return String value of attribute. It will return the default
       *         value if the named attribute does not exist, or if
       *         the value is not set.
       */
      public String getAttribute( String name, String defaultValue )
      {
          try
          {
              return m_base.getAttribute( name );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttribute( name, defaultValue );
          }
      }
  
      /**
       * Returns the value of the attribute specified by its name as a
       * <code>int</code>, or the default value if no attribute by
       * that name exists or is empty.
       *
       * @param name The name of the attribute you ask the value of.
       * @param defaultValue The default value desired.
       * @return int value of attribute. It will return the default
       *         value if the named attribute does not exist, or if
       *         the value is not set.
       */
      public int getAttributeAsInteger( String name, int defaultValue )
      {
          try
          {
              return m_base.getAttributeAsInteger( name );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsInteger( name, defaultValue );
          }
      }
  
      /**
       * Returns the value of the attribute specified by its name as a
       * <code>long</code>, or the default value if no attribute by
       * that name exists or is empty.
       *
       * @param name The name of the attribute you ask the value of.
       * @param defaultValue The default value desired.
       * @return long value of attribute. It will return the default
       *          value if the named attribute does not exist, or if
       *          the value is not set.
       */
      public long getAttributeAsLong( String name, long defaultValue )
      {
          try
          {
              return m_base.getAttributeAsLong( name );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsLong( name, defaultValue );
          }
      }
  
      /**
       * Returns the value of the attribute specified by its name as a
       * <code>float</code>, or the default value if no attribute by
       * that name exists or is empty.
       *
       * @param name The name of the attribute you ask the value of.
       * @param defaultValue The default value desired.
       * @return float value of attribute. It will return the default
       *          value if the named attribute does not exist, or if
       *          the value is not set.
       */
      public float getAttributeAsFloat( String name, float defaultValue )
      {
          try
          {
              return m_base.getAttributeAsFloat( name );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsFloat( name, defaultValue );
          }
      }
  
      /**
       * Returns the value of the attribute specified by its name as a
       * <code>boolean</code>, or the default value if no attribute by
       * that name exists or is empty.
       *
       * @param name The name of the attribute you ask the value of.
       * @param defaultValue The default value desired.
       * @return boolean value of attribute. It will return the default
       *         value if the named attribute does not exist, or if
       *         the value is not set.
       */
      public boolean getAttributeAsBoolean( String name, boolean defaultValue )
      {
          try
          {
              return m_base.getAttributeAsBoolean( name );
          }
          catch( ConfigurationException e )
          {
              return m_parent.getAttributeAsBoolean( name, defaultValue );
          }
      }
  }
  
  
  
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBContext.java
  
  Index: DefaultORBContext.java
  ===================================================================
  /**
   * File: DefaultORBContext.java
   * License: etc/LICENSE.TXT
   * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   * Copyright: OSM SARL 2001-2002, All Rights Reserved.
   */
  
  package org.apache.orb;
  
  import java.io.File;
  import java.net.URL;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.CascadingRuntimeException;
  
  import org.omg.CORBA_2_3.ORB;
  
  /**
   * The <code>DefaultORBContext</code> class is Context class that 
   * holds an ORB instance.
   *
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  
  public class DefaultORBContext extends DefaultContext
  implements ORBContext
  {
  
      //=================================================================
      // constructor
      //=================================================================
      
     /**
      * Creation of a new DefaultORBContext.
      * @param orb the ORB
      */
      public DefaultORBContext( ORB orb )
      {
          put( ORBContext.ORB_KEY, orb );
      }
  
      //=================================================================
      // ORBContext
      //=================================================================
  
     /**
      * Returns the ORB.
      * @return ORB the object request broker
      * @exception ContextException if the ORB reference has not been set
      */
      public ORB getORB( )
      {    
          try
          {
              return (ORB) get( ORBContext.ORB_KEY );
          }
          catch( ContextException e )
          {
              // will not happen
              throw new CascadingRuntimeException("Unexpeted context error while retrieving ORB value.", e );
          }
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBFactory.java
  
  Index: DefaultORBFactory.java
  ===================================================================
  /**
   * File: DefaultORBFactory.java
   * License: etc/LICENSE.TXT
   * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   * Copyright: OSM SARL 2001-2002, All Rights Reserved.
   */
  
  package org.apache.orb;
  
  import java.io.File;
  import java.net.URL;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.CascadingRuntimeException;
  import org.apache.avalon.phoenix.Block;
  import org.apache.avalon.phoenix.BlockContext;
  
  /**
   * The <code>ORBServer</code> class is an Component that provides support for the
   * creation of an new ORB instance.
   * 
   * <p><table border="1" cellpadding="3" cellspacing="0" width="100%">
   * <tr bgcolor="#ccccff">
   * <td colspan="2"><b><code>DefaultORBFactory</code>Lifecycle Phases</b></td>
   * <tr><td width="20%"></td><td><b>Description</b></td></tr>
   * <tr>
   * <td width="20%"><b>Contextualizable</b></td>
   * <td>
   * The <code>Context</code> value passed to the <code>ORBFactory</code> during this phase
   * provides the runtime execution context including the root application directory.</td></tr>
   * <tr>
   * <td width="20%"><b>Configurable</b></td>
   * <td>
   * The configuration phase handles the internalization of a static configuration data 
   * including ORB bootstrap properties.
   * </td></tr>
   * <tr><td width="20%"><b>Initalizable</b></td>
   * <td>
   * Signals completion of the Contextualization and Configuration phases.
   * </td></tr>
   * <tr><td width="20%"><b>Disposable</b></td>
   * <td>
   * Local cleanup of state memebers.
   * </td></tr>
   * </table>
   *
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  
  public class DefaultORBFactory extends AbstractLogEnabled
  implements Block, Contextualizable, Configurable, Initializable, Disposable, ORBFactoryService
  {
  
      //=================================================================
      // static
      //=================================================================
  
     /**
      * The default ORB class.
      */
      public static final String DEFAULT_ORB_CLASS  = "org.apache.orb.ORB";
  
     /**
      * The default ORB Singleton class.
      */
      public static final String DEFAULT_ORB_SINGLETON = "org.openorb.CORBA.ORBSingleton";
  
      //=================================================================
      // state
      //=================================================================
  
     /**
      * The static configuration for the factory.
      */
      private Configuration m_config;
  
     /**
      * Runtime context supplied to the factory.
      */
      private Context m_context;
  
     /**
      * Base directory from where default property statements containing 
      * file values are resolved.
      */
      private File m_root;
      
      //=================================================================
      // Contextualizable
      //=================================================================
  
      public void contextualize( Context context ) throws ContextException
      {
          this.m_context = context;
          if( context instanceof BlockContext )
          {
              m_root = ((BlockContext)context).getBaseDirectory();
          }
      }
  
      //==========================================================================
      // Configurable
      //==========================================================================
      
     /**
      * Configuration of the runtime environment based on a supplied Configuration arguments
      * which contains the general arguments for ORB initalization, PSS subsystem initialization, 
      * PSDL type to class mappings, preferences and debug information.
      *
      * @param config Configuration representing an internalized model of the assembly.xml file.
      * @exception ConfigurationException if the supplied configuration is incomplete or badly formed.
      */
      public void configure( final Configuration config )
      throws ConfigurationException
      {
          this.m_config = config;
      }
  
      //=================================================================
      // Initializable
      //=================================================================
      
     /**
      * Initialization is invoked by the framework following configuration,
      * following which the factory can support ORB creation.
      */
      public void initialize()
      throws Exception
      {
          // TODO: add validation that the minimum set of initalizers and
          // properties are declared
      }
      
      //=================================================================
      // DefaultFactory
      //=================================================================
  
     /**
      * Creation of a new ORB instance based on the supplied properties.
      * NOTE: Semantic of this interface are under discussion.
      * @param props initialization properties
      */
      public ORB createORB( )
      {    
          return createORB( new String[0], null );
      }
  
     /**
      * Creation of a new ORB instance based on the supplied properties.  
      * The properties supplied to the ORB init function will be supplimented
      * with default properties declared under the factory configuration.
      *
      * @param props the supplimentary ORB initialization properties
      */
      public ORB createORB( java.util.Properties properties )
      {    
          return createORB( new String[0], properties );
      }
  
     /**
      * Creation of a new ORB instance based on the supplied properties.
      * The properties supplied to the ORB init function will be supplimented
      * with default properties declared under the factory configuration.
      *
      * @param the ORB init argument array
      * @param props the supplimentary ORB initialization properties
      */
      public ORB createORB( String[] args, java.util.Properties properties )
      {    
          return createORB( args, properties, null, null, null );
      }
  
     /**
      * Creation of a new ORB instance based on a supplied logger, 
      * configuration and context.  The implementation handles the 
      * the creation of an appropriate Properties argument based on 
      * property declarations in the supplied configuration.  Default
      * properties declared under the factory configuration will be 
      * added to the generated ORB properties, followed by addition 
      * of any properties declared in the supplied configuration 
      * argument (enabling modification of default values).
      * @param the ORB init argument array
      * @param properties the supplimentary ORB initialization properties
      * @param logger the logging channel to be used by the orb during 
      *   initalization
      * @param context optional context to be applied to orb subsytems
      * @param configuration optional orb configuration
      * @return ORB a portable CORBA Object Request Broker (ORB)
      */
      public ORB createORB( String[] args, java.util.Properties properties, 
        Logger logger, Context context, Configuration configuration )
      {
  
          Logger log = logger;
          if( log == null ) log = getLogger();
  
          Context ctx = context;
          if( ctx == null ) ctx = m_context;
  
          CascadingConfiguration config = new CascadingConfiguration( configuration, m_config );
          ORBInitContext props = new ORBInitContext( properties, log, ctx, config );
  
          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 );
          }
          catch ( Throwable e )
          {
  		final String error = "ORB initialization failure.";
              throw new CascadingRuntimeException( error, e );
          }
      }
  
      //=================================================================
      // Disposable
      //=================================================================
  
     /**
      * Disposal of this component.
      */ 
      public void dispose()
      {
          m_config = null;
          m_context = null;
          m_root = null;
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultORBFactory.xinfo
  
  Index: DefaultORBFactory.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
   File: ORBServer.xinfo
   License: etc/LICENSE.TXT
   Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   Copyright: OSM SARL 2001-2002, All Rights Reserved.  
   @author  Stephen McConnell
   @version 1.0 12/03/2001
  -->
  
  <blockinfo>
  
    <block>
      <version>1.0</version>
    </block>
  
    <!--
    services that are offered by this block 
    -->
  
    <services>
        <service name="org.apache.orb.ORBFactoryService" version="1.0" />
    </services>
  
  </blockinfo>
  
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORB.java
  
  Index: ORB.java
  ===================================================================
  /**
   * File: ORB.java
   * License: etc/LICENSE.TXT
   * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   * Copyright: OSM SARL 2001-2002, All Rights Reserved.
   */
  
  package org.apache.orb;
  
  import java.io.File;
  import java.net.URL;
  import java.util.Properties;
  
  import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.CascadingRuntimeException;
  import org.apache.avalon.phoenix.Block;
  import org.apache.avalon.phoenix.BlockContext;
  
  import org.apache.orb.util.ComponentHolder;
  
  import org.omg.CORBA.ORBPackage.InvalidName;
  
  /**
   * The <code>ORB</code> class.
   * 
   * <p><table border="1" cellpadding="3" cellspacing="0" width="100%">
   * <tr bgcolor="#ccccff">
   * <td colspan="2"><b>ORB Lifecycle Phases</b></td>
   * <tr><td width="20%"><b>Phase</b></td><td><b>Description</b></td></tr>
   * <tr>
   * <td width="20%" valign="top">Configurable</td>
   * <td>
   * The configuration contains the default ORB bootstrap properties including
   * property and initalizer declarations.  The implementation looks for child
   * property and initalizer elements in the following form: 
   * <pre>
   *   &lt;orb&gt;
   *     &lt;property name="propertyName" value="propertyValue"&gt;
   *     &lt;property name="propertyName" file="fileName"&gt;
   *     &lt;initializer class="org.apache.pss.Initializer" name="pss"&gt;
   *   &lt;orb&gt;
   * </pre>
   * </td></tr>
   * <tr>
   * <td width="20%" valign="top">Contextualizable</td>
   * <td>
   * The <code>Context</code> value passed to the <code>ORB</code> that
   * provides the runtime execution context.  The home directory shall be 
   * declared under the context key of ORB_HOME_DIR.</td></tr>
   * <tr><td width="20%">Initalizable</td>
   * <td>
   * Initates the ORB parameterization phase during which Interceptors 
   * and pluggable Features are instantiated. 
   * </td></tr>
   * <tr><td width="20%" valign="top">Startable</td>
   * <td>
   * Provides support starting and stopping the ORB.
   * </td></tr>
   * <tr><td width="20%" valign="top">Disposable</td>
   * <td>
   * Cleanup and disposal of state members.
   * </td></tr>
   * </table>
   *
   * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
   */
  
  public class ORB extends org.openorb.CORBA.ORB
  implements Component, Configurable, Contextualizable, Initializable, Startable, Disposable
  {
  
      //=================================================================
      // static
      //=================================================================
  
     /**
      * The default ORB class.
      */
      public static final String DEFAULT_ORB_CLASS  = "org.apache.orb.ORB";
  
     /**
      * The default ORB Singleton class.
      */
      public static final String DEFAULT_ORB_SINGLETON = "org.openorb.CORBA.ORBSingleton";
  
      //=================================================================
      // state
      //=================================================================
  
     /**
      * Logging channel.
      */
      private Logger m_logger;
  
     /**
      * The static configuration for the factory.
      */
      private Configuration m_config;
  
     /**
      * Runtime context supplied to the factory.
      */
      private Context m_context;
  
     /**
      * Base directory from where default property statements containing 
      * file based attributes are resolved.
      */
      private File m_root;
  
      private Thread m_thread;
  
      private ORB orb; // self
  
      //=================================================================
      // constructor
      //=================================================================
      
     /**
      * Default constuctor.
      */
      public ORB()
      {
          orb = this;
      }
  
      //=================================================================
      // Contextualizable
      //=================================================================
  
     /**
      * Declaration of a runtime context.
      */
      public void contextualize( Context context ) throws ContextException
      {
          this.m_context = context;
          if( context instanceof BlockContext )
          {
              m_root = ((BlockContext)context).getBaseDirectory();
          }
      }
  
      //==========================================================================
      // Configurable
      //==========================================================================
      
     /**
      * Configuration of the runtime environment based on a supplied Configuration arguments
      * which contains the general arguments for ORB initalization.
      *
      * @param config a Configuration containing property and initialization elements.
      * @exception ConfigurationException if the supplied configuration is incomplete or badly formed.
      */
      public void configure( final Configuration config )
      throws ConfigurationException
      {
          this.m_config = config;
      }
  
      //=================================================================
      // Initializable
      //=================================================================
      
     /**
      * Notification may a manager to commence parameterization of the ORB
      * based on the configuration and supplied context.  The implmentation
      * creates an <code>ORBInitContext</code> value that is used as an 
      * argument to the ORB.init funtion.  The implementation directs ORB 
      * loading to the org.apache.orb.CORBA.kernel.DefaultLoader class.
      * @see org.apache.orb.CORBA.kernel.DefaultLoader
      * @exception Exception if an error occurs during initalization
      */
      public void initialize()
      throws Exception
      {
  
          //
          // create an ORBInitContext that will be used as the properties argument
          // when parameterizing the ORB
          //
  
          Properties p = new Properties();
          ORBInitContext props = new ORBInitContext( p, getLogger(), m_context, m_config );
  
          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 );
          }
          catch ( Throwable e )
          {
  		final String error = "ORB initialization failure.";
              throw new CascadingRuntimeException( error, e );
          }
       }
      
      //=================================================================
      // Startable
      //=================================================================
      
     /**
      * The start operation is invoked by a manager following completion of the 
      * initialization phase, during which a new thread is created for the execution
      * of the ORB.
      */
      public void start()
      throws Exception
      {
          final String status = "start";
          m_thread = new Thread(
            new Runnable() {
              public void run()
              {
                  if( getLogger().isDebugEnabled() ) getLogger().debug( status );
                  try
                  {
                      orb.run();
                  }
                  catch (Exception e)
                  {
  			  final String error = "unexpected exception raised by the ORB";
                      if( getLogger().isErrorEnabled() ) getLogger().error( error, e );
                      throw new CascadingRuntimeException( error, e );
                  }
              }
            }
          );
          m_thread.start();
  	  final String debug = "startup complete";
          if( getLogger().isDebugEnabled() ) getLogger().debug( debug );
      }
      
      /**
       * Stop the ORB.
       */
      public void stop()
      throws Exception
      {
          if( getLogger().isDebugEnabled() ) getLogger().debug( "stop" );
  	  try
  	  {
              shutdown( true );
  	  }
  	  catch( Throwable e )
  	  {
  	      final String warning = "Internal error while shutting down the ORB.";
              if( getLogger().isWarnEnabled() ) getLogger().warn( warning, e );
          }
      }
  
      //=================================================================
      // Disposable
      //=================================================================
  
     /**
      * Disposal of this component.
      */ 
      public void dispose()
      {
          m_config = null;
          m_context = null;
          m_root = null;
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORB.xinfo
  
  Index: ORB.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
   File: ORB.xinfo
   License: etc/LICENSE.TXT
   Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   Copyright: OSM SARL 2001-2002, All Rights Reserved.  
   @author  Stephen McConnell
   @version 1.0 12/03/2001
  -->
  
  <blockinfo>
  
    <block>
      <version>1.0</version>
    </block>
  
    <!--
    services that are offered by this block 
    -->
  
    <services>
        <service name="org.apache.orb.ORBServicesProvider" version="2.4" />
    </services>
  
  </blockinfo>
  
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORBFactoryService.java
  
  Index: ORBFactoryService.java
  ===================================================================
  /**
   * File: ORBServicesProvider.java
   * License: etc/LICENSE.TXT
   * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   * Copyright: OSM SARL 2001-2002, All Rights Reserved.
   */
  
  package org.apache.orb;
  
  import java.util.Properties;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * The FactoryService is an interface facilitating access to 
   * an ORB factory.
   *
   * @author Stephen McConnell <mcconnell@osm.net>
   */
  public interface ORBFactoryService extends Component
  {
  
     /**
      * Creation of a new ORB instance based on the supplied properties.
      * NOTE: Semantic of this interface are under discussion.
      * @param props initialization properties
      */
      public ORB createORB( );
  
     /**
      * Creation of a new ORB instance based on the supplied properties.  
      * The properties supplied to the ORB init function will be supplimented
      * with default properties declared under the factory configuration.
      *
      * @param props the supplimentary ORB initialization properties
      */
      public ORB createORB( java.util.Properties properties );
  
     /**
      * Creation of a new ORB instance based on the supplied properties.
      * The properties supplied to the ORB init function will be supplimented
      * with default properties declared under the factory configuration.
      *
      * @param the ORB init argument array
      * @param props the supplimentary ORB initialization properties
      */
      public ORB createORB( String[] args, java.util.Properties properties );
  
     /**
      * Creation of a new ORB instance based on a supplied logger, 
      * configuration and context.  The implementation handles the 
      * the creation of an appropriate Properties argument based on 
      * property declarations in the supplied configuration.  Default
      * properties declared under the factory configuration will be 
      * added to the generated ORB properties, followed by addition 
      * of any properties declared in the supplied configuration 
      * argument (enabling modification of default values).
      * @param the ORB init argument array
      * @param properties the supplimentary ORB initialization properties
      * @param logger the logging channel to be used by the orb during 
      *   initalization
      * @param context optional context to be applied to orb subsytems
      * @param configuration optional orb configuration
      * @return ORB a portable CORBA Object Request Broker (ORB)
      */
      public ORB createORB( String[] args, java.util.Properties properties, 
        Logger logger, Context context, Configuration configuration );
  }
  
  
  
  
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/ORBInitContext.java
  
  Index: ORBInitContext.java
  ===================================================================
  /**
   * File: ORBInitializationContext.java
   * License: etc/LICENSE.TXT
   * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved.
   * Copyright: OSM SARL 2001-2002, All Rights Reserved.
   */
  
  package org.apache.orb;
  
  import java.util.Map;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.File;
  import java.net.URL;
  import java.lang.reflect.Method;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  import org.apache.avalon.framework.CascadingRuntimeException;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * The ORBInitContext is a context supporting the creation of a new ORB instance.
   * This class supports interoperability between the Avalon component model and 
   * the initialization model specified for an ORB. Avalon <code>Logger</code>,
   * <code>Context</code> and <code>Configuration</code> are passed as named values
   * that are recognized by the <code>DefaultLoader</code> implementation.
   *
   * @author Stephen McConnell <mcconnell@osm.net>
   */
  public class ORBInitContext extends java.util.Properties implements Context
  {
  
      //=============================================================================
      // static
      //=============================================================================
  
     /**
      * Context key for the base logger.
      */
      public static final String LOGGER_KEY = "LOGGER";
  
     /**
      * Context key for the base context.
      */
      public static final String CONTEXT_KEY = "CONTEXT";
  
     /**
      * Context key for the base configuration.
      */
      public static final String CONFIGURATION_KEY = "CONFIGURATION";
  
  
      //=============================================================================
      // state
      //=============================================================================
  
      private final Context m_context;
      private boolean m_readOnly = false;
      private Configuration m_config;
      private Logger m_logger;
  
      //=============================================================================
      // constructors
      //=============================================================================
  
      /**
       * Create a Context with specified data and parent.
       *
       * @param data the initial context data
       * @param logger the logger to be used for ORB logging
       * @param context the context to be used during contextualization of 
       *   ORB subsystems
       * @param config optional configuration argument containing initializer 
       *   configuation information
       */
      public ORBInitContext( final java.util.Properties data, final Logger logger, 
        final Context context, final Configuration config )
      {
          super( data );
          m_logger = logger;
          m_context = context;
          if( config == null ) 
          {
              m_config = new DefaultConfiguration( "-", null );
          }
          else
          {
              m_config = config;
          }
      }
  
      //=============================================================================
      // ORBInitContext
      //=============================================================================
  
     /**
      * Returns the logger to be used for ORB logging and 
      * log enablement of ORB subsytems.
      */
      public Logger getBaseLogger()
      {
          return m_logger;
      }
  
     /**
      * Returns a Context object to be applied during the contextualization 
      * phase of ORB subsytems.
      *
      * @param name the name of the initalizer class
      */
      public Context getBaseContext()
      {
          return m_context;
      }
  
     /**
      * Returns an initializer configuration based on a supplied 
      * initializer class name.
      * @param name the name of the initalizer class
      */
      public Configuration getConfigurationByClassName( String name )
      {
          return getConfigurationByClassName( name, true );
      }
  
     /**
      * Returns an initializer configuration based on a supplied 
      * initializer class name.
      * @param name the name of the initalizer class
      * @param policy if no initializer configaration 
      *   matching the supplied name can be found, and the policy argument
      *   is TRUE (the default), an non-null empty configuration will be 
      *   returned, otherwise if policy is FALSE implementation will return 
      *   a null value
      */
      public Configuration getConfigurationByClassName( String name, boolean policy )
      {
          if( m_config != null )
          {
              Configuration config = getByClassName( m_config, name );
              if( config != null ) return config;
          }
  
          if( policy ) return new DefaultConfiguration( name, "-" );
          return null;
      }
  
     /**
      * Locate an initializer element based on a supplied class name.
      */
      private Configuration getByClassName( Configuration config, String name )
      {
          Configuration[] children = config.getChildren("initializer");
          for( int i=0; i<children.length; i++ )
          {
              try
              {
                  if( children[i].getAttribute("class").equals( name ) ) return children[i];
              }
              catch( Exception e )
              {
                  final String error = "Configuration " + m_config.getName() 
                   + " contains an initializer element with a missing 'class' attribute.";
                  throw new CascadingRuntimeException( error, e );
              }
          }
          return null;
      }
  
  
      //=============================================================================
      // Context
      //=============================================================================
  
      /**
       * Retrieve an item from the Context.
       *
       * @param key the key of item
       * @return the item stored in context
       * @exception ContextException if item not present
       */
      public Object get( final Object key )
      {
  
          // handle special keys
  
          if( key instanceof String ) 
          {
              final String name = ((String)key);
              if( name.equalsIgnoreCase( LOGGER_KEY ) ) return m_logger;
              if( name.equalsIgnoreCase( CONTEXT_KEY ) ) return m_context;
              if( name.equalsIgnoreCase( CONFIGURATION_KEY ) ) return m_config;
          }
  
          // handle general keys
  
          final Object data = super.get( key );
          if( null != data ) return data;
  
          // check the parent
  
          if( null == m_context ) return null;
          try
          {
              return m_context.get( key );
          }
          catch( Exception e )
          {
              return null;
          }
      }
  
      //=============================================================================
      // implementation
      //=============================================================================
  
      /**
       * Helper method for adding items to Context.
       *
       * @param key the items key
       * @param value the item
       * @exception IllegalStateException if context is read only
       * @exception IllegalArgumentException if the key is a string with 
       *   conflicting with the reserved names LOGGER_KEY, CONTEXT_KEY or 
       *   CONFIGURATION_KEY
       */
      public Object put( final Object key, final Object value )
          throws IllegalStateException
      {
          if( key instanceof String ) 
          {
              final String name = ((String)key);
              if(( name.equalsIgnoreCase(LOGGER_KEY) ) || ( name.equalsIgnoreCase(CONTEXT_KEY) )
                || ( name.equalsIgnoreCase(CONFIGURATION_KEY) ) ) throw new IllegalArgumentException(
                  "Cannot put value under reserved key: " + key );
          }
          checkWriteable();
          return put( key, value );
      }
  
      /**
       * Make the context read-only.
       * Any attempt to write to the context via put()
       * will result in an IllegalStateException.
       */
      public void makeReadOnly()
      {
          m_readOnly = true;
      }
  
      /**
       * Utility method to check if context is writeable and if not throw exception.
       *
       * @exception IllegalStateException if context is read only
       */
      protected final void checkWriteable()
          throws IllegalStateException
      {
          if( m_readOnly )
          {
              throw new IllegalStateException( "Context is read only and can not be modified" );
          }
      }
  
     /**
      * Add properties to the instance based on a supplied configuration.  
      * Any configuration elements of the following form will be translated 
      * to property values and added to the property set.  Property 
      * declarations with a file attribute will be expanded relative to the current
      * working directory.
      *
      * <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>
      *
      * @see #addProperties( File, Configuration )
      * @param configuration a configuration containing 'property' element declarations
      */
      public void addProperties( Configuration configuration ) throws Exception 
      {
          addProperties( getBaseDirectory(), configuration );
      }
  
     /**
      * Add properties to the instance based on a 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 addProperties( File root, Configuration configuration ) throws Exception 
      {
  	  Configuration[] props = configuration.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 Exception ( 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 Exception( 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 );
  				}
  			  }
  		    }
  		}
  		setProperty( name, value );
          }
      }
  
  
      //=============================================================================
      // override properties operations
      //=============================================================================
  
     /**
      * Loads properties from an input stream.
      * @exception IllegalStateException if context is read only
      */
      public void load(InputStream input ) throws IOException
      {
          checkWriteable();
          super.load( input );
      }
  
     /**
      * Set a property value.
      * @param key the property key
      * @param value the property value
      * @return Object
      * @exception IllegalStateException if context is read only
      */
      public synchronized Object setProperty(String key, String value) {
          checkWriteable();
          return super.put(key, value);
      }
  
      //=============================================================================
      // internals
      //=============================================================================
  
      private File getBaseDirectory()
      {
          if( m_context != null ) try
          {
              Method method = m_context.getClass().getMethod( "getBaseDirectory", new Class[0] );
              return (File) method.invoke( m_context, new Object[0] );
          }
          catch( Throwable e )
          {
          }
          return new File( System.getProperty("user.dir") );
      }
  
  }
  
  
  
  
  
  
  1.3       +48 -7     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultLoader.java	6 Feb 2002 09:46:43 -0000	1.2
  +++ DefaultLoader.java	11 Feb 2002 14:47:15 -0000	1.3
  @@ -15,7 +15,7 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.CascadingRuntimeException;
   
  -import org.apache.orb.ORBContext;
  +import org.apache.orb.ORBInitContext;
   
   import org.omg.PortableInterceptor.ORBInitializer;
   
  @@ -116,9 +116,8 @@
               }
           }
   
  -        if( m_logger == null ) m_logger = ORBBootstrapHelper.getRootLogger().getChildLogger( 
  -           "" + System.identityHashCode( this ) ) ;
  -        _orb.enableLogging( m_logger );
  +        if( m_logger == null ) m_logger = org.openorb.util.Trace.getLogger();
  +        _orb.enableLogging( m_logger.getChildLogger( "" + System.identityHashCode( this ) ) );
           m_logger.debug("loading orb");
   
           // load the properties and the list of initializers
  @@ -138,9 +137,9 @@
               cargs[ 1 ] = orb;
               targs[ 1 ] = org.openorb.CORBA.ORB.class;
   
  -            if( properties instanceof ORBContext )
  +            if( properties instanceof ORBInitContext )
               {
  -                load_initializers( cargs, conf.getInitializers(), (ORBContext)properties );
  +                load_initializers( cargs, conf.getInitializers(), (ORBInitContext)properties );
               }
               else
               {
  @@ -174,6 +173,7 @@
                 "Exception during construction of ORBConnectorClass", ex );
           }
   
  +        enableTrace();
           init_info.post_init();
       }
   
  @@ -185,6 +185,47 @@
           _properties.display( out );
       }
   
  +    /**
  +     * This operation is used to display an OpenORB configuration.
  +     */
  +    public void display_configuration( Logger logger )
  +    {
  +        _properties.display( logger );
  +    }
  +
  +    /**
  +     * Activate a default trace mode
  +     */
  +    private void enableTrace()
  +    {
  +        int traceLevel;
  +
  +        try
  +        {
  +            traceLevel = getIntProperty( "Verbose" );
  +        }
  +        catch ( org.openorb.CORBA.kernel.PropertyNotFoundException ex )
  +        {
  +            traceLevel = getIntProperty( "openorb.debug", 0 );
  +        }
  +
  +        if ( traceLevel != 0 ) org.openorb.util.Trace.setTraceLevel( traceLevel );
  +        if ( traceLevel > 4 )
  +        {
  +            m_logger.debug(
  +                "\n----------------------------------------------------------------------------------------"
  +              + "OpenORB debugging session "
  +              + "Session : Intra verbose mode"
  +              + "----------------------------------------------------------------------------------------"
  +              + "Current configuration :"
  +            );
  +            display_configuration( m_logger );
  +            m_logger.debug(
  +                "\n----------------------------------------------------------------------------------------" 
  +            );
  +        }
  +    }
  +
       // ---------------------------------------------------------------------
       //
       // The following operations return properties stored into a profile
  @@ -435,7 +476,7 @@
           load_initializers( args, cls_names, null );
       }
   
  -    private void load_initializers( Object [] args, String [] cls_names, ORBContext context )
  +    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 );
  
  
  

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