mcconnell 02/02/06 01:13:37
Modified: apps/enterprise/orb/lib openorb-1.2.2.jar
openorb_tools-1.2.2.jar
apps/enterprise/orb/src/java/org/apache/orb
DefaultFactory.java FactoryService.java
apps/enterprise/pss/dist pss-2.0.1.jar
apps/enterprise/pss/src/java/org/apache/pss Initializer.java
Log:
rationalization of sources synchronized with support inside the ORB for
LogEnabled on the ORB and initalizer activation.
Revision Changes Path
1.2 +8124
-5876jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb-1.2.2.jar
<<Binary file>>
1.2 +1223 -839
jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb_tools-1.2.2.jar
<<Binary file>>
1.4 +48 -143
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/DefaultFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultFactory.java 4 Feb 2002 14:17:48 -0000 1.3
+++ DefaultFactory.java 6 Feb 2002 09:13:37 -0000 1.4
@@ -85,7 +85,7 @@
/**
* The static configuration for the factory.
*/
- private Configuration m_configuration;
+ private Configuration m_config;
/**
* Runtime context supplied to the factory.
@@ -97,11 +97,6 @@
* file values are resolved.
*/
private File m_root;
-
- /**
- * Factory context.
- */
- private Properties m_defaults;
//=================================================================
// Contextualizable
@@ -131,7 +126,7 @@
public void configure( final Configuration config )
throws ConfigurationException
{
- this.m_configuration = config;
+ this.m_config = config;
}
//=================================================================
@@ -145,17 +140,6 @@
public void initialize()
throws Exception
{
- // Create the default Properties instance.
-
- try
- {
- m_defaults = createFactoryContext( m_context, m_configuration,
m_root );
- }
- catch (Exception e)
- {
- final String error = "Failed to establish ORB properties in ";
- throw new ConfigurationException( error +
m_root.getAbsolutePath(), e);
- }
}
//=================================================================
@@ -173,8 +157,11 @@
}
/**
- * Creation of a new ORB instance based on the supplied properties.
- * @param props initialization 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 props the supplimentary ORB initialization properties
*/
public ORB createORB( java.util.Properties properties )
{
@@ -183,17 +170,52 @@
/**
* Creation of a new ORB instance based on the supplied properties.
- * @param args common line arguments
- * @param props initialization 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 )
{
- final String pre = "ORB creation";
- if( getLogger().isDebugEnabled() ) getLogger().debug( pre );
+ 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;
+ ORBContext props = new ORBContext( properties, log, ctx,
configuration, m_config );
try
{
- return (ORB) ORB.init( args, new Properties( properties,
m_defaults ) );
+ props.setProperty("org.omg.CORBA.ORBClass", DEFAULT_ORB_CLASS );
+ props.setProperty("org.omg.CORBA.ORBSingletonClass",
DEFAULT_ORB_SINGLETON );
+ props.addProperties( m_config, m_root );
+ if( configuration != null ) props.addProperties( configuration,
m_root );
+ return (ORB) ORB.init( args, props );
}
catch ( Throwable e )
{
@@ -211,126 +233,9 @@
*/
public void dispose()
{
- m_configuration = null;
+ m_config = null;
m_context = null;
m_root = null;
- m_defaults = null;
- }
-
- //=================================================================
- // internal
- //=================================================================
-
- /**
- * Return a Properties instance that implements the Context interface.
- * The return value is suitable for passing to an ORB.init() method as a
- * <code>java.util.Properties</code> instance.
- * @parent the parent context (may be null)
- * @param configuration a configuration containing 'property' elements
- * @param root the file path to be used in resolution of property
- * element in the configuration that contain 'file' attributes as
- * the property value
- * @return Properties a Context derived by java.util.Properties
- */
- private Properties createFactoryContext(
- Context parent, Configuration configuration, File root ) throws
Exception
- {
- Properties p = new Properties( parent );
- String orbClass =
configuration.getAttribute("org.omg.CORBA.ORBClass", DEFAULT_ORB_CLASS );
- String orbSingleton =
configuration.getAttribute("org.omg.CORBA.ORBSingletonClass",
DEFAULT_ORB_SINGLETON );
- p.setProperty("org.omg.CORBA.ORBClass", orbClass );
- p.setProperty("org.omg.CORBA.ORBSingletonClass", orbSingleton );
-
- //
- // resolve any ORB specific properties
- //
-
- 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
);
- }
- }
- }
- }
- p.setProperty( name, value );
- }
- return p;
}
}
1.2 +45 -3
jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/FactoryService.java
Index: FactoryService.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/FactoryService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FactoryService.java 4 Feb 2002 10:21:21 -0000 1.1
+++ FactoryService.java 6 Feb 2002 09:13:37 -0000 1.2
@@ -9,6 +9,9 @@
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;
import org.omg.CORBA_2_3.ORB;
/**
@@ -21,11 +24,50 @@
{
/**
- * Returns a ORB based on the supplied context.
- * @return ORB a portable CORBA Object Request Broker (ORB)
+ * 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( Properties 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.5 +155 -158
jakarta-avalon-cornerstone/apps/enterprise/pss/dist/pss-2.0.1.jar
<<Binary file>>
1.6 +71 -77
jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/Initializer.java
Index: Initializer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/Initializer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Initializer.java 4 Feb 2002 17:32:09 -0000 1.5
+++ Initializer.java 6 Feb 2002 09:13:37 -0000 1.6
@@ -36,13 +36,6 @@
import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName;
import org.omg.PortableInterceptor.ORBInitializer;
-// the remaining org.openorb dependencies will dissapear once logging is in
place
-
-import org.openorb.CORBA.ORB;
-import org.openorb.CORBA.kernel.ORBLoader;
-import org.openorb.PI.OpenORBInitInfo;
-import org.openorb.ots.Verbose;
-
import org.apache.pss.connector.ConnectorBase;
import org.apache.pss.connector.database.DatabaseConnector;
import org.apache.pss.connector.database.DatabaseSessionManager;
@@ -97,6 +90,8 @@
private static final String PSS = "PSS:";
+ private static final String VENDOR = "APACHE:";
+
private final static String DEFAULT_FORMAT =
"%{time} [%7.7{priority}] (%{category}): %{message}\\n%{throwable}";
@@ -112,6 +107,8 @@
private Configuration m_config;
+ private Configuration m_bootstrap_config;
+
//==========================================================================
// constructor
//==========================================================================
@@ -131,6 +128,7 @@
*/
public void enableLogging( Logger logger )
{
+ System.out.println("PSS LOGING");
m_logger = logger;
}
@@ -140,6 +138,9 @@
*/
protected Logger getLogger()
{
+ if( null != m_logger ) return m_logger;
+ m_logger = getBootstrapLogger( getBootstrapConfiguration() );
+ if( m_logger.isDebugEnabled() ) m_logger.debug("bootstrap logging
enabled");
return m_logger;
}
@@ -152,10 +153,20 @@
*/
public void configure( Configuration config )
{
- if( getLogger().isDebugEnabled() )
getLogger().debug("configuration");
+ System.out.println("PSS CONFIG");
this.m_config = config;
}
+ /**
+ * Returns the configuration resource.
+ */
+ private Configuration getConfiguration()
+ {
+ if( m_config != null ) return m_config;
+ m_config = getBootstrapConfiguration();
+ return m_config;
+ }
+
//==========================================================================
// ORBInitializer
//==========================================================================
@@ -170,74 +181,22 @@
*/
public void pre_init( ORBInitInfo orbinitinfo )
{
-
- if( getLogger() != null ) if( getLogger().isDebugEnabled() )
getLogger().debug("pre_init");
+ System.out.println("PSS PRE-INIT");
+ if( getLogger().isDebugEnabled() ) getLogger().debug("pre_init");
PIDFactory.info = orbinitinfo;
//
- // get the implmentation default configuration
- //
-
- Configuration defaults = null;
- String vendor = "NULL";
- try
- {
- defaults = getConfiguration( "org/apache/pss/config.xml" );
- vendor = defaults.getAttribute("vendor","APACHE") + ":" ;
- }
- catch ( Throwable e )
- {
- final String error = "Could not load default configuration.";
- throw new CascadingRuntimeException( error, e );
- }
-
- //
- // if a logging channel has not been declared then bootstrap
- // a channel now
- //
-
- String loggingPath = "";
- if( getLogger() == null ) try
- {
- loggingPath = defaults.getChild("logging").getAttribute("file");
- String loggingPriority =
defaults.getChild("logging").getAttribute("priority", "INFO" );
- m_logger = createLogger( loggingPath, loggingPriority );
- }
- catch ( Throwable e )
- {
- final String error = "Could not create logger on path: " +
loggingPath;
- throw new CascadingRuntimeException( error, e );
- }
-
- //
- // if this instance has been configured, use the supplied
configuration
- // for the remainder fo the operations, otherwise use the defautlt
- // configuration
- //
-
- Configuration config = m_config;
- if( config == null )
- {
- if( getLogger().isDebugEnabled() ) getLogger().debug("bootstrap
configuration");
- config = defaults;
- }
- else
- {
- if( getLogger().isDebugEnabled() ) getLogger().debug("managed
configuration");
- }
-
- //
// create a singleton file connector
//
try
{
- Configuration c = config.getChild("connector").getChild("file");
+ Configuration c =
getConfiguration().getChild("connector").getChild("file");
final FileConnector connector = new FileConnector( c,
orbinitinfo );
connector.enableLogging( getLogger().getChildLogger("file") );
orbinitinfo.register_initial_reference(
- PSS + vendor + "file", connector );
+ PSS + VENDOR + "file", connector );
}
catch ( Throwable e )
{
@@ -251,11 +210,11 @@
try
{
- Configuration c =
config.getChild("connector").getChild("database");
+ Configuration c =
getConfiguration().getChild("connector").getChild("database");
final DatabaseConnector connector = new DatabaseConnector( c,
orbinitinfo );
connector.enableLogging( getLogger().getChildLogger("db") );
orbinitinfo.register_initial_reference(
- PSS + vendor + "database", connector );
+ PSS + VENDOR + "database", connector );
}
catch ( Throwable e )
{
@@ -265,11 +224,11 @@
try
{
- Configuration c =
config.getChild("connector").getChild("memory");
+ Configuration c =
getConfiguration().getChild("connector").getChild("memory");
final MemoryConnector connector = new MemoryConnector( c,
orbinitinfo );
connector.enableLogging( getLogger().getChildLogger("memory") );
orbinitinfo.register_initial_reference(
- PSS + vendor + "memory", connector );
+ PSS + VENDOR + "memory", connector );
}
catch ( Throwable e )
{
@@ -277,7 +236,7 @@
throw new CascadingRuntimeException( error, e );
}
- if( config.getChild("ots").getAttributeAsBoolean("boot", false) )
+ if( getConfiguration().getChild("ots").getAttributeAsBoolean("boot",
false) )
{
org.openorb.ots.Initializer initializer = new
org.openorb.ots.Initializer();
initializer.pre_init( orbinitinfo );
@@ -286,8 +245,9 @@
try
{
m_file_session_manager = new FileSessionManager( orbinitinfo );
- m_database_session_manager = new DatabaseSessionManager(
orbinitinfo );
orbinitinfo.add_server_request_interceptor(
getFileSessionManager() );
+
+ m_database_session_manager = new DatabaseSessionManager(
orbinitinfo );
orbinitinfo.add_server_request_interceptor(
getDatabaseSessionManager() );
}
catch ( DuplicateName duplicateName )
@@ -303,8 +263,7 @@
}
/**
- *
- *
+ * Post initalization of the interceptor.
* @param orbinitinfo
*/
public void post_init( ORBInitInfo orbinitinfo ) { }
@@ -317,14 +276,49 @@
/**
* Returns the configuration resource.
*/
- private Configuration getConfiguration( String path ) throws Exception
+ private Configuration getBootstrapConfiguration( )
{
- DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder( );
- InputStream is =
this.getClass().getClassLoader().getResourceAsStream( path );
- if( is == null ) throw new Exception(
+ if( m_bootstrap_config != null ) return m_bootstrap_config;
+ m_bootstrap_config = getBootstrapConfiguration(
"org/apache/pss/config.xml" );
+ return m_bootstrap_config;
+ }
+
+ /**
+ * Returns the configuration resource.
+ */
+ private Configuration getBootstrapConfiguration( String path )
+ {
+ try
+ {
+ DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder( );
+ InputStream is =
this.getClass().getClassLoader().getResourceAsStream( path );
+ if( is == null ) throw new Exception(
"Could not find the configuration resource \"" + path +
"\"" );
- return builder.build( is );
+ return builder.build( is );
+ }
+ catch( Throwable e )
+ {
+ final String error = "Could not build the bootstrap
configuration.";
+ throw new CascadingRuntimeException( error, e );
+ }
}
+
+ private Logger getBootstrapLogger( Configuration bootstrap )
+ {
+ String loggingPath = "";
+ try
+ {
+ loggingPath = bootstrap.getChild("logging").getAttribute("file");
+ String loggingPriority =
bootstrap.getChild("logging").getAttribute("priority", "INFO" );
+ return createLogger( loggingPath, loggingPriority );
+ }
+ catch ( Throwable e )
+ {
+ final String error = "Could not create bootstrap logger on path:
'" + loggingPath + "'.";
+ throw new CascadingRuntimeException( error, e );
+ }
+ }
+
private Logger createLogger( final String filename, String priority )
{
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>