## org.apache.orb.CORBA.kernel
Class DefaultLoader

    java.lang.Object
      |
      +--org.apache.orb.CORBA.kernel.DefaultLoader

All Implemented Interfaces:
  org.apache.avalon.framework.activity.Disposable, ORBLoader

public class DefaultLoader
extends java.lang.Object
implements ORBLoader, org.apache.avalon.framework.activity.Disposable

The `DefaultLoader` provides support for the configuration of a new ORB instance based on default and supplied properties, and lifecycle processing of pluggable `Initializer`s encountered during the configuration process. The implementation also handles the decommissioning of initializers as part of loader disposal.

#### Property Management

The property set profile for an ORB instance is created based on command line arguments, supplied properties, and an optional embedded configuration.

Property resolution.
Source | Description
args | Property declarations supplied under the init method take precedence. The args array is passed to the `Configuration` for resolution.
properties | The `properties` argument to the init method is the second source of property declarations. The `DefaultLoader` uses the properties argument to establish a new <code<Properties instance that is populated with additional properties based on the `DefaultLoader` default properties resource, and properties declared under an embedded configuration value.

configuration

A `Configuration` value may be embeded in the supplied `Properties` value under the `"CONFIGURATION"` key. Properties declared in the configuration instance that are recognized by the loader are detailed here.

         <property name="propertyName" value="propertyValue"/>
         <property name="propertyName" file="fileName"/>
         <initializer class="org.apache.pss.Initializer" name="pss"/>

defaults | A set of static default properties are used to suppliment the user defined properties. Default properties are contained in the `org/apache/orb/CORBA/kernel/orb.properties` and `org/apache/orb/CORBA/kernel/DefaultLoader.xml` configuration resources bundeled in the distribution jar file.

#### Embedded Resources

Resources required to manage pluggable component lifecycle handling are provided to the loader using special keyed values. Keys and the associated values are described in the following table.

Embedded Avalon Resources.
Key | Description
`LOGGER` | The logging channel to be assigned to the ORB. The logger is used as the relative root when creatiing and assigning logging channels to pluggable initializers.
`CONFIGURATION` | A configuration instance that may be used to supply supplimentary property declarations and initializers configuration blocks. Initializers that implement the Avalon `Cascading` interface will be supplied with its configuration during initializer loading.
`CONTEXT` | The `Context` is an application context that will be supplied to any initializers that implement the `Contextualizable` interface.

#### Logging Catagory Management

The logger supplied to the loader under the embedded properties `LOGGER` key is assigned as the root logging catagory for the ORB. Catagores for initializers are created as child catagories. If the supplied logger has the catagory name of `demo.orb`, an initializer catagory for PSS would be `demo.orb.pss`. Initializer sub-catagores are resolved from the supplied configuration. The `DefaultLoader` locates an initializer declaration based on an initilizer element with a `class` attribute value matching that initializer implementation class name. The `name` attribute value is used as the logging channel sub-catagory name.

         <initializer class="org.apache.pss.Initializer" name="pss"/>

#### Example Usage

The following code fragment demonstrates the creation of a new ORB instance using embedded resources and the `DefaultLoader` class.

           Properties properties = new Properties();

           // declare the ORB and Singleton implementations

           properties.setProperty( "org.omg.CORBA.ORBClass",
             "org.openorb.CORBA.ORB" );
           properties.setProperty("org.omg.CORBA.ORBSingletonClass",
             "org.openorb.CORBA.ORBSingleton" );

              // declare the loader that will be instatiated by the ORB

           properties.setProperty("openorb.ORBLoader",
             "org.apache.orb.CORBA.kernel.DefaultLoader");

             // add the embedded configuration, logger and context resources

           properties.put( "CONFIGURATION", m_config );
           properties.put( "LOGGER", getLogger().getChildLogger("orb") );
           properties.put( "CONTEXT", m_context );

           // create the ORB

           orb = ORB.init( m_args, properties );

Author:
  Stephen McConnell

Constructor Summary
`DefaultLoader()`

Method Summary
`java.lang.reflect.Constructor` `classConstructor(java.lang.String key, java.lang.String defl, java.lang.Class[] args)` Creation of a class constructor.
`java.lang.Object` `constructClass(java.lang.String prop_key, java.lang.String defl, java.lang.Object[] args)` This operation is used to load a class with the given property name and default class name.
`java.lang.Object` `constructClass(java.lang.String prop_key, java.lang.String defl, java.lang.Object[] args, java.lang.Class[] args_t)` This operation is used to load a class with the given property name and default class name.
`void` `display_configuration()` This operation is used to display an OpenORB configuration.
`void` `display_configuration(org.apache.avalon.framework.logger.Logger logger)` This operation is used to display an OpenORB configuration.
`void` `dispose()` Called by the ORB during shutdown enabling the initalizer to clean up.
`boolean` `getBooleanProperty(java.lang.String name)` Get the boolean property with the given name.
`boolean` `getBooleanProperty(java.lang.String name, boolean defl)` Get the boolean property with the given name.
`java.lang.Class` `getClassProperty(java.lang.String name)` Get the integer property with the given name.
`java.lang.Class` `getClassProperty(java.lang.String name, java.lang.Class defl)` Get the Class object property with the given name.
`java.lang.Class` `getClassProperty(java.lang.String name, java.lang.String defl)` Get the Class object property with the given name.
`static java.util.Properties` `getDefaultProperties()` Returns the system wide default ORB properties
`int` `getIntProperty(java.lang.String name)` Get the integer property with the given name.
`int` `getIntProperty(java.lang.String name, int defl)` Get the integer property with the given name.
`Property` `getProperty(java.lang.String name)` Get the Property object with the given name.
`java.lang.String` `getStringProperty(java.lang.String name)` Get the string property with the given name.
`java.lang.String` `getStringProperty(java.lang.String name, java.lang.String defl)` Get the string property with the given name.
`java.net.URL` `getURLProperty(java.lang.String name)` Get the URL property with the given name.
`java.net.URL` `getURLProperty(java.lang.String name, java.net.URL defl)` Get the URL property with the given name.
`void` `init(java.lang.String[] args, java.util.Properties props, ORB orb)` ORB Initialization.
`void` `load_kernel()` This operation is used to load the OpenORB kernel.
`void` `mergeProperties(java.io.File root, org.apache.avalon.framework.configuration.Configuration config, java.util.Properties properties)` Adds property declarations to the supplied Properties argument from the supplied configuration.
`java.util.Iterator` `properties(java.lang.String name)` Iterate over property values with the specified prefix.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultLoader

    public DefaultLoader()

Method Detail

### load_kernel

    public void load_kernel()

  This operation is used to load the OpenORB kernel.

  Depending on the property openorb.server.enable ( default true ) and openorb.client.enable ( default true ) this method instantiates the ServerCPCManager and the ClientCPCMamager. This instantiation is pluggable as it is driven by properties:

  - openorb.server.ServerManagerClass ( default org.openorb.net.ServerManagerImpl )
  - openorb.client.ClientManagerClass ( default org.openorb.net.ClientManagerImpl )
  The interface of the ServerCPCManager is defined by the org.openorb.net.ServerManager interface and by the org.openorb.net.ClientManager interface for the ClientCPCManager respectively.

  The property openorb.dynany.enable (default true) allows to avoid loading the DynAnyFactory if it is not used by the application. This can save you some amount memory.

  The property openorb.client.enable also decides whether to load the initiali references ORBPolicyManager and PolicyCurrent into the ORB.

### init

    public void init(java.lang.String[] args,
                     java.util.Properties props,
                     ORB orb)

  ORB Initialization.
  Specified by:
    `init` in interface `ORBLoader`
  Parameters:
    `args` - command line arguments
    `props` - properties argument
    `orb` - the ORB instance

### display_configuration

    public void display_configuration()

  This operation is used to display an OpenORB configuration.
  Specified by:
    `display_configuration` in interface `ORBLoader`

### display_configuration

    public void display_configuration(org.apache.avalon.framework.logger.Logger logger)

  This operation is used to display an OpenORB configuration.
  Parameters:
    `logger` - the logging channel to direct display of properties

### properties

    public java.util.Iterator properties(java.lang.String name)

  Iterate over property values with the specified prefix.

  Specified by:
    `properties` in interface `ORBLoader`
  Parameters:
    `name` - parent of properties. Properies of the form name + "." + xxx are returned, where xxx can be anything. May be null to iterate over all properies.
  Returns:
    unmodifiable iterator over the name's decendants. This iterator returns objects of type Property.

### getProperty

    public Property getProperty(java.lang.String name)

  Get the Property object with the given name.
  Specified by:
    `getProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
  Returns:
    Property the named property

### getStringProperty

    public java.lang.String getStringProperty(java.lang.String name,
                                              java.lang.String defl)

  Get the string property with the given name.
  Specified by:
    `getStringProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
    `defl` - default value to use if property not found.
  Returns:
    String the property value

### getStringProperty

    public java.lang.String getStringProperty(java.lang.String name)
                                       throws PropertyNotFoundException

  Get the string property with the given name.
  Specified by:
    `getStringProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
  Returns:
    String the property value
  Throws:
    `PropertyNotFoundException` - the property cannot be found.

### getIntProperty

    public int getIntProperty(java.lang.String name,
                              int defl)

  Get the integer property with the given name.
  Specified by:
    `getIntProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
    `defl` - default value to use if property not found.
  Returns:
    int the property value

### getIntProperty

    public int getIntProperty(java.lang.String name)
                       throws PropertyNotFoundException

  Get the integer property with the given name.
  Specified by:
    `getIntProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
  Returns:
    int the property value
  Throws:
    `PropertyNotFoundException` - the property cannot be found.

### getBooleanProperty

    public boolean getBooleanProperty(java.lang.String name,
                                      boolean defl)

  Get the boolean property with the given name.
  Specified by:
    `getBooleanProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
    `defl` - default value to use if property not found.
  Returns:
    boolean the property value

### getBooleanProperty

    public boolean getBooleanProperty(java.lang.String name)
                               throws PropertyNotFoundException

  Get the boolean property with the given name.
  Specified by:
    `getBooleanProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
  Returns:
    boolean the property value
  Throws:
    `PropertyNotFoundException` - the property cannot be found.

### getURLProperty

    public java.net.URL getURLProperty(java.lang.String name,
                                       java.net.URL defl)

  Get the URL property with the given name.
  Specified by:
    `getURLProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
    `defl` - default value to use if property not found.
  Returns:
    URL the property value

### getURLProperty

    public java.net.URL getURLProperty(java.lang.String name)
                                throws PropertyNotFoundException

  Get the URL property with the given name.
  Specified by:
    `getURLProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
  Returns:
    URL the property value
  Throws:
    `PropertyNotFoundException` - the property cannot be found.

### getClassProperty

    public java.lang.Class getClassProperty(java.lang.String name,
                                            java.lang.Class defl)

  Get the Class object property with the given name.
  Specified by:
    `getClassProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
    `defl` - default value to use if property not found.
  Returns:
    Class the property value

### getClassProperty

    public java.lang.Class getClassProperty(java.lang.String name,
                                            java.lang.String defl)

  Get the Class object property with the given name.
  Specified by:
    `getClassProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
    `defl` - String name of default value to use if property not found.
  Returns:
    Class the property value

### getClassProperty

    public java.lang.Class getClassProperty(java.lang.String name)
                                     throws PropertyNotFoundException

  Get the integer property with the given name.
  Specified by:
    `getClassProperty` in interface `ORBLoader`
  Parameters:
    `name` - the property name.
  Returns:
    Class the property value
  Throws:
    `PropertyNotFoundException` - the property cannot be found.

### constructClass

    public java.lang.Object constructClass(java.lang.String prop_key,
                                           java.lang.String defl,
                                           java.lang.Object[] args)
                                    throws java.lang.reflect.InvocationTargetException

  This operation is used to load a class with the given property name and default class name.
  Specified by:
    `constructClass` in interface `ORBLoader`
  Parameters:
    `prop_key` - Property name, this string property holds the name of the class. May be null if no property is used.
    `defl` - Default class name. Used if the named property is not found. May be null to indicate no load should be performed if property is missing.
    `args` - arguments to constructor. If any constructor arguments are primitive types then the four argument version of this function must be used.
  Returns:
    the newly constructed object, or null if the property value is set to the empty string.
  Throws:
    `java.lang.reflect.InvocationTargetException` - an exception occoured in the constructor.

### constructClass

    public java.lang.Object constructClass(java.lang.String prop_key,
                                           java.lang.String defl,
                                           java.lang.Object[] args,
                                           java.lang.Class[] args_t)
                                    throws java.lang.reflect.InvocationTargetException

  This operation is used to load a class with the given property name and default class name.
  Specified by:
    `constructClass` in interface `ORBLoader`
  Parameters:
    `prop_key` - Property name, this string property holds the name of the class. May be null if no property is used.
    `defl` - Default class name. Used if the named property is not found. May be null to indicate no load should be performed if property is missing.
    `args` - arguments to constructor. If any constructor arguments are primitive types then the four argument version of this function must be used.
    `args_t` - types of onstructor arguments. If any of these are null they will be determined from getClass on the matching arg. Length must match length of args.
  Returns:
    the newly constructed object, or null if the property value is set to the empty string.
  Throws:
    `java.lang.reflect.InvocationTargetException` - an exception occoured in the constructor.

### classConstructor

    public java.lang.reflect.Constructor classConstructor(java.lang.String key,
                                                          java.lang.String defl,
                                                          java.lang.Class[] args)

  Creation of a class constructor.
  Specified by:
    `classConstructor` in interface `ORBLoader`
  Parameters:
    `key` - property key
    `defl` - default value
    `args` - constructor arguments
  Returns:
    java.lang.reflect.Constructor the constructor

### getDefaultProperties

    public static java.util.Properties getDefaultProperties()

  Returns the system wide default ORB properties
  Returns:
    java.util.Properties default properties

### mergeProperties

    public void mergeProperties(java.io.File root,
                                org.apache.avalon.framework.configuration.Configuration config,
                                java.util.Properties properties)
                         throws java.lang.Exception

  Adds property declarations to the supplied Properties argument from the supplied configuration. Any configuration elements of the following form will be translated to property values and added to the property set.

         <any-containing-element>
            <property name="myProperty" value="someValue"/>
            <property name="info" file="eggs.xml"/>
         </any-containing-element>

  Parameters:
    `root` - the file path to be used in resolution of property element in the configuration that contain 'file' attributes as the property value
    `config` - a configuration containing 'property' element declarations
    `properties` - the properties to merge
  Throws:
    `java.lang.Exception` - if an merge error occurs

### dispose

    public void dispose()

  Called by the ORB during shutdown enabling the initalizer to clean up.
  Specified by:
    `dispose` in interface `org.apache.avalon.framework.activity.Disposable`