Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 58433 invoked from network); 11 Feb 2002 14:47:23 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 11 Feb 2002 14:47:23 -0000 Received: (qmail 18063 invoked by uid 97); 11 Feb 2002 14:47:22 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 18010 invoked by uid 97); 11 Feb 2002 14:47:22 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 17999 invoked by uid 97); 11 Feb 2002 14:47:21 -0000 Date: 11 Feb 2002 14:47:16 -0000 Message-ID: <20020211144716.51298.qmail@icarus.apache.org> From: mcconnell@apache.org To: jakarta-avalon-cornerstone-cvs@apache.org Subject: cvs commit: jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel DefaultLoader.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 <> 1.3 +47 -61 jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb_tools-1.2.2.jar <> 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 getOrb operation is an ORB supporting - * the CORBA 2.3 portability specification. - * @author Stephen McConnell + * The ORBContext interface defines a Context type that + * holds an ORB instance. + * + * @author Stephen McConnell */ -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 - * - * - * - * - * - * - * The return value is suitable for passing to an ORB.init() method as a - * java.util.Properties 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 */ 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 Configuration 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 CascadingConfiguration 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 Configuration instance encapsulating the specified * child node. * * @param child The name of the child node. * @param createNew If true, a new Configuration * will be created and returned if the specified child does not exist in either * the base or parent configuratioin. If false, null * 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 Array of Configuration * 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 Array of Configuration * 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 name */ 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. *

* The order of attributes in this array can not be relied on. As * with XML, a Configuration's attributes are an * unordered set. If your code relies on order, eg * conf.getAttributeNames()[0], then it is liable to break if a * different XML parser is used. *

*/ 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; iint 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 int 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 * long. * * @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 long fails. */ public long getAttributeAsLong( String name ) throws ConfigurationException { try { return m_base.getAttributeAsLong( name ); } catch( ConfigurationException e ) { return m_parent.getAttributeAsLong( name ); } } /** * Return the float 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 float fails. */ public float getAttributeAsFloat( String paramName ) throws ConfigurationException { try { return m_base.getAttributeAsFloat( paramName ); } catch( ConfigurationException e ) { return m_parent.getAttributeAsFloat( paramName ); } } /** * Return the boolean value of the specified parameter contained * in this node.
* * @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 boolean fails. */ public boolean getAttributeAsBoolean( String paramName ) throws ConfigurationException { try { return m_base.getAttributeAsBoolean( paramName ); } catch( ConfigurationException e ) { return m_parent.getAttributeAsBoolean( paramName ); } } /** * Return the String 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 int value of the node. * * @exception ConfigurationException If conversion to int fails. */ public int getValueAsInteger() throws ConfigurationException { try { return m_base.getValueAsInteger(); } catch( ConfigurationException e ) { return m_parent.getValueAsInteger(); } } /** * Return the float value of the node. * * @return the value of the node. * @exception ConfigurationException If conversion to float fails. */ public float getValueAsFloat() throws ConfigurationException { try { return m_base.getValueAsFloat(); } catch( ConfigurationException e ) { return m_parent.getValueAsFloat(); } } /** * Return the boolean value of the node. * * @return the value of the node. * @exception ConfigurationException If conversion to boolean fails. */ public boolean getValueAsBoolean() throws ConfigurationException { try { return m_base.getValueAsBoolean(); } catch( ConfigurationException e ) { return m_parent.getValueAsBoolean(); } } /** * Return the long value of the node.
* * @return the value of the node. * @exception ConfigurationException If conversion to long 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 String. * If the configuration value is not set, the default value will be * used. * * @param defaultValue The default value desired. * @return String value of the Configuration, 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 int. * If the configuration value is not set, the default value will be * used. * * @param defaultValue The default value desired. * @return int value of the Configuration, 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 long. * If the configuration value is not set, the default value will be * used. * * @param defaultValue The default value desired. * @return long value of the Configuration, 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 float. * If the configuration value is not set, the default value will be * used. * * @param defaultValue The default value desired. * @return float value of the Configuration, 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 boolean. * If the configuration value is not set, the default value will be * used. * * @param defaultValue The default value desired. * @return boolean value of the Configuration, 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 * String, 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 * int, 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 * long, 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 * float, 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 * boolean, 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 DefaultORBContext class is Context class that * holds an ORB instance. * * @author Stephen McConnell */ 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 ORBServer class is an Component that provides support for the * creation of an new ORB instance. * *

* * * * * * * * * * * * * *
DefaultORBFactoryLifecycle Phases
Description
Contextualizable * The Context value passed to the ORBFactory during this phase * provides the runtime execution context including the root application directory.
Configurable * The configuration phase handles the internalization of a static configuration data * including ORB bootstrap properties. *
Initalizable * Signals completion of the Contextualization and Configuration phases. *
Disposable * Local cleanup of state memebers. *
* * @author Stephen McConnell */ 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 =================================================================== 1.0 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 ORB class. * *

* * * * * * * * * * * * * * * *
ORB Lifecycle Phases
PhaseDescription
Configurable * 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: *
   *   <orb>
   *     <property name="propertyName" value="propertyValue">
   *     <property name="propertyName" file="fileName">
   *     <initializer class="org.apache.pss.Initializer" name="pss">
   *   <orb>
   * 
*
Contextualizable * The Context value passed to the ORB that * provides the runtime execution context. The home directory shall be * declared under the context key of ORB_HOME_DIR.
Initalizable * Initates the ORB parameterization phase during which Interceptors * and pluggable Features are instantiated. *
Startable * Provides support starting and stopping the ORB. *
Disposable * Cleanup and disposal of state members. *
* * @author Stephen McConnell */ 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 ORBInitContext 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 =================================================================== 1.0 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 */ 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 Logger, * Context and Configuration are passed as named values * that are recognized by the DefaultLoader implementation. * * @author Stephen McConnell */ 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 * <any-containing-element> * <property name="myProperty" value="someValue"/> * <property name="info" file="eggs.xml"/> * </any-containing-element> * * * @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. * *

      *   <any-containing-element>
      *      <property name="myProperty" value="someValue"/>
      *      <property name="info" file="eggs.xml"/>
      *   </any-containing-element>
      * 
* * @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: For additional commands, e-mail: