You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/02/11 22:56:34 UTC
cvs commit: jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/memory MemoryConnector.java MemorySession.java
mcconnell 02/02/11 13:56:34
Modified: apps/enterprise/pss/src/java/org/apache/pss Initializer.java
config.xml
apps/enterprise/pss/src/java/org/apache/pss/connector
AbstractCatalog.java ConnectorBase.java
apps/enterprise/pss/src/java/org/apache/pss/connector/database
DatabaseConnector.java DatabaseSession.java
apps/enterprise/pss/src/java/org/apache/pss/connector/file
FileConnector.java FileSession.java
apps/enterprise/pss/src/java/org/apache/pss/connector/memory
MemoryConnector.java MemorySession.java
Added: apps/enterprise/pss/src/java/org/apache/pss Connector.java
ConnectorContext.java DefaultConnectorContext.java
DefaultSessionContext.java Session.java
SessionContext.java
Log:
no message
Revision Changes Path
1.7 +49 -7 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Initializer.java 6 Feb 2002 09:13:37 -0000 1.6
+++ Initializer.java 11 Feb 2002 21:56:34 -0000 1.7
@@ -17,6 +17,7 @@
import java.io.PrintStream;
import java.io.InputStream;
import java.io.File;
+import java.lang.reflect.Method;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
@@ -25,6 +26,9 @@
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+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.CascadingRuntimeException;
import org.apache.log.output.io.FileTarget;
import org.apache.log.Hierarchy;
@@ -67,7 +71,7 @@
* </pre>
*/
public class Initializer extends LocalObject
- implements ORBInitializer, LogEnabled, Configurable
+ implements ORBInitializer, LogEnabled, Contextualizable, Configurable
{
//==========================================================================
@@ -109,6 +113,10 @@
private Configuration m_bootstrap_config;
+ private Context m_context;
+
+ private File m_root;
+
//==========================================================================
// constructor
//==========================================================================
@@ -128,7 +136,6 @@
*/
public void enableLogging( Logger logger )
{
- System.out.println("PSS LOGING");
m_logger = logger;
}
@@ -145,6 +152,19 @@
}
//==========================================================================
+ // Contextualizable
+ //==========================================================================
+
+ /**
+ * Set the execution context.
+ */
+ public void contextualize( Context context )
+ {
+ if( getLogger().isDebugEnabled() ) getLogger().debug("contetualization");
+ this.m_context = context;
+ }
+
+ //==========================================================================
// Configurable
//==========================================================================
@@ -153,7 +173,7 @@
*/
public void configure( Configuration config )
{
- System.out.println("PSS CONFIG");
+ if( getLogger().isDebugEnabled() ) getLogger().debug("configure");
this.m_config = config;
}
@@ -163,7 +183,7 @@
private Configuration getConfiguration()
{
if( m_config != null ) return m_config;
- m_config = getBootstrapConfiguration();
+ m_config = new DefaultContiguration( "-", null );
return m_config;
}
@@ -186,14 +206,17 @@
PIDFactory.info = orbinitinfo;
+ if( m_root == null ) m_root = getBaseDirectory();
+
//
// create a singleton file connector
//
try
{
+ if( getLogger().isDebugEnabled() ) getLogger().debug("creating singleton file connector");
Configuration c = getConfiguration().getChild("connector").getChild("file");
- final FileConnector connector = new FileConnector( c, orbinitinfo );
+ final FileConnector connector = new FileConnector( m_context, c, orbinitinfo );
connector.enableLogging( getLogger().getChildLogger("file") );
orbinitinfo.register_initial_reference(
PSS + VENDOR + "file", connector );
@@ -210,8 +233,9 @@
try
{
+ if( getLogger().isDebugEnabled() ) getLogger().debug("creating singleton database connector");
Configuration c = getConfiguration().getChild("connector").getChild("database");
- final DatabaseConnector connector = new DatabaseConnector( c, orbinitinfo );
+ final DatabaseConnector connector = new DatabaseConnector( m_context, c, orbinitinfo );
connector.enableLogging( getLogger().getChildLogger("db") );
orbinitinfo.register_initial_reference(
PSS + VENDOR + "database", connector );
@@ -224,8 +248,9 @@
try
{
+ if( getLogger().isDebugEnabled() ) getLogger().debug("creating singleton memory connector");
Configuration c = getConfiguration().getChild("connector").getChild("memory");
- final MemoryConnector connector = new MemoryConnector( c, orbinitinfo );
+ final MemoryConnector connector = new MemoryConnector( m_context, c, orbinitinfo );
connector.enableLogging( getLogger().getChildLogger("memory") );
orbinitinfo.register_initial_reference(
PSS + VENDOR + "memory", connector );
@@ -260,6 +285,9 @@
final String error = "Unexpected error while attempting to register an interceptor.";
throw new CascadingRuntimeException( error, e );
}
+
+ if( getLogger().isDebugEnabled() ) getLogger().debug("pre-init cycle completed");
+
}
/**
@@ -335,4 +363,18 @@
throw new RuntimeException("Failed to establish logger.",e);
}
}
+
+ 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.2 +17 -32 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/config.xml
Index: config.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/config.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- config.xml 1 Feb 2002 22:35:11 -0000 1.1
+++ config.xml 11 Feb 2002 21:56:34 -0000 1.2
@@ -1,18 +1,14 @@
<?xml version="1.0"?>
<!--
-This configuration file contains default values for connector and
-session properties. Some of these values may be overriden by a deployment
-configuration. The vendor attribute is used in conjuction with a connector
-name to resolve inital reference in the form 'PSS:' + <vendor> + ':' <name>.
-The 'title' element is the name under which the service will be published
-in logging files.
+This configuration file contains default values for the PSS connector
+profiles.
-->
-<pss vendor="APACHE" title="Persistent State Service (PSS)">
+<pss title="Persistent State Service (PSS)" >
<!--
- Declaration of the default logging setup if logging has not
+ Declaration of the falback logging setup if logging has not
been enabled by a manager.
-->
@@ -21,54 +17,43 @@
<!--
The 'ots' element contains the 'boot' attribute value. The value may be
'true' or 'false' and declares the policy concerning the bootstrapping
- of the OTS service by the PSS service. If ots is true the PSS service
- will initate the boot of the OTS service.
+ of the OTS service by the PSS service. If ots boot is true, the PSS
+ service will initate the boot of the OTS service initializer.
-->
<ots boot="false"/>
<!--
- The connector configuration declares the default connector.
- The value may be one of 'memory', 'file' or 'database'. If
- the 'database is set as the default mode, deployment of the PSS
- system must include a JDBC driver, database implementation and
- a workable default JDBC URL value.
+ Declaration of the configuration of persistence profiles for the
+ database, file and memory conectors.
-->
- <connector default="memory">
+ <connector>
<!--
The file element will be applied to the singleton
file connection created by the PSS initalizer. The 'flush'
attribute controls the default period for periodic cache flush
- request. The name element is the name that the connector
- will be published under in the ORB initial references.
- -->
+ request.
+ -->
- <file name="file" flush="30" />
+ <file flush="30" />
<!--
The database element will be applied to the singleton
- database connection created by the PSS initalizer. The 'driver'
- attribute declares the default JDBC driver class name. The
- 'url' attribute declares the default JDBC URL value. The driver
- and url values are used in conjunction with the optional username
- and password session properties to establish the database session.
- The 'flush' attribute controls the default period for periodic cache
- flush request. The name element is the name that the connector
- will be published under in the ORB initial references.
+ database connection created by the PSS initalizer.
+ The 'flush' attribute controls the default period for
+ periodic cache flush request.
-->
- <database name="database" flush="30" driver="" url="" />
+ <database flush="30" />
<!--
The memory element will be applied to the singleton
memory connection created by the PSS initalizer.
- The name element is the name that the connector
- will be published under in the ORB initial references.
-->
- <memory name="memory" />
+ <memory/>
</connector>
1.1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/Connector.java
Index: Connector.java
===================================================================
/**
* File: Connector.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.pss;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configuration;
/**
* The Connector interface exposed a PSS connection as a managable component.
*
* @author Stephen McConnell <mc...@osm.net>
*/
public interface Connector extends org.omg.CosPersistentState.Connector, Component
{
/**
* Register implementations for PSDL storage types and home with
* the connector using a configuration argument.
* @param config a configuration instance containing home and storage
* mapping betweeen PSDL identifiers and implementation classes
*/
public void register( Configuration config );
/**
* Creation of a basic session.
* @param config a configuration containing session parameter declarations.
* @return <code>Session</code> the PSS basic session
*/
public Session createBasicSession( Configuration config );
}
1.1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/ConnectorContext.java
Index: ConnectorContext.java
===================================================================
/**
* File: ConnectorContext.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.pss;
import org.apache.orb.ORBContext;
import org.apache.avalon.framework.context.ContextException;
import org.omg.CORBA_2_3.ORB;
/**
* The <code>ConnectorContext</code> interface defines a utility context
* used to hold a PSS connection.
*
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
public interface ConnectorContext extends ORBContext
{
//=================================================================
// static
//=================================================================
public static final String CONNECTOR_KEY = "CONNECTOR";
//=================================================================
// ConnectorContext
//=================================================================
/**
* Returns the PSS Connector.
* @return <code>Connector</code> the PSS persistentence system connector
* @exception ContextException if the connector reference has not been set
*/
public Connector getConnector( ) throws ContextException;
}
1.1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/DefaultConnectorContext.java
Index: DefaultConnectorContext.java
===================================================================
/**
* File: DefaultConnectorContext.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.pss;
import org.apache.orb.DefaultORBContext;
import org.apache.avalon.framework.context.ContextException;
import org.omg.CosPersistentState.Parameter;
import org.omg.CORBA_2_3.ORB;
/**
* The <code>DefaultConnectorContext</code> class is Context class that
* holds an PSS Connector instance.
*
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
public class DefaultConnectorContext extends DefaultORBContext
implements ConnectorContext
{
//=================================================================
// constructor
//=================================================================
/**
* Creation of a new DefaultConnectorContext.
*/
public DefaultConnectorContext( ORB orb, Connector connector )
{
super( orb );
put( ConnectorContext.CONNECTOR_KEY, connector );
}
//=================================================================
// ConnectorContext
//=================================================================
/**
* Returns the PSS Connector.
* @return <code>Connector</code> the PSS persistentence system connector
* @exception ContextException if the connector reference has not been set
*/
public Connector getConnector( ) throws ContextException
{
return (Connector) get( ConnectorContext.CONNECTOR_KEY );
}
}
1.1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/DefaultSessionContext.java
Index: DefaultSessionContext.java
===================================================================
/**
* File: DefaultSessionContext.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.pss;
import org.apache.orb.DefaultORBContext;
import org.apache.avalon.framework.context.ContextException;
import org.omg.CosPersistentState.Parameter;
import org.omg.CORBA_2_3.ORB;
/**
* The <code>DefaultConnectorContext</code> class is Context class that
* holds an PSS Session instance.
*
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
public class DefaultSessionContext extends DefaultConnectorContext
implements SessionContext
{
//=================================================================
// constructor
//=================================================================
/**
* Creation of a new DefaultConnectorContext.
*/
public DefaultSessionContext( ORB orb, Connector connector, Session session )
{
super( orb, connector );
put( SessionContext.SESSION_KEY, session );
}
//=================================================================
// ConnectorContext
//=================================================================
/**
* Returns a PSS session.
* @return <code>Session</code> the PSS session
* @exception ContextException if the session reference has not been set
*/
public Session getSession( ) throws ContextException
{
return (Session) get( SessionContext.SESSION_KEY );
}
}
1.1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/Session.java
Index: Session.java
===================================================================
/**
* File: Session.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.pss;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.activity.Startable;
/**
* The Session interface exposed a PSS session as a managable component.
*
* @author Stephen McConnell <mc...@osm.net>
*/
public interface Session extends org.omg.CosPersistentState.Session, Component, Startable
{
}
1.1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/SessionContext.java
Index: SessionContext.java
===================================================================
/**
* File: SessionContext.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.pss;
import org.apache.orb.ORBContext;
import org.apache.avalon.framework.context.ContextException;
import org.omg.CORBA_2_3.ORB;
/**
* The <code>SessionContext</code> interface defines a utility context
* used to hold a PSS session.
*
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
public interface SessionContext extends ConnectorContext
{
//=================================================================
// static
//=================================================================
public static final String SESSION_KEY = "SESSION";
//=================================================================
// SessionContext
//=================================================================
/**
* Returns a PSS session.
* @return <code>Session</code> the PSS session
* @exception ContextException if the session reference has not been set
*/
public Session getSession( ) throws ContextException;
}
1.3 +42 -8 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/AbstractCatalog.java
Index: AbstractCatalog.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/AbstractCatalog.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractCatalog.java 2 Feb 2002 01:19:58 -0000 1.2
+++ AbstractCatalog.java 11 Feb 2002 21:56:34 -0000 1.3
@@ -13,6 +13,14 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.pss.connector.PID;
+import org.apache.pss.connector.PIDFactory;
+import org.apache.pss.connector.Iterator;
+import org.apache.pss.connector.ExtendedCatalog;
+import org.apache.pss.connector.PersistenceException;
+import org.apache.pss.connector.PIDFactory;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.LocalObject;
@@ -23,21 +31,15 @@
import org.omg.CosPersistentState.Parameter;
import org.omg.CosPersistentState.Connector;
import org.omg.PortableInterceptor.ORBInitInfo;
-import org.apache.pss.connector.PID;
-import org.apache.pss.connector.PIDFactory;
-import org.apache.pss.connector.Iterator;
-import org.apache.pss.connector.ExtendedCatalog;
-import org.apache.pss.connector.PersistenceException;
-import org.apache.pss.connector.PIDFactory;
+
/**
* Abstract impementation of a catalog.
*/
public abstract class AbstractCatalog extends LocalObject
-implements CatalogBase, ExtendedCatalog, LogEnabled
+implements CatalogBase, ExtendedCatalog, LogEnabled, Startable
{
-
/**
* Set of home incarnations.
*/
@@ -81,6 +83,38 @@
public Logger getLogger()
{
return m_log;
+ }
+
+ //=================================================================
+ // Startable
+ //=================================================================
+
+ /**
+ * Empty implementation.
+ */
+ public void start()
+ throws Exception
+ {
+ }
+
+ /**
+ * The stop operation is invoked by a manager causing closure of
+ * the persistent session.
+ */
+ public void stop()
+ throws Exception
+ {
+ if( getLogger().isDebugEnabled() ) getLogger().debug( "stop" );
+ try
+ {
+ flush();
+ close();
+ }
+ catch( Throwable e )
+ {
+ final String error = "Internal error (ignored) while stopping PSS";
+ if( getLogger().isErrorEnabled() ) getLogger().error( error, e );
+ }
}
//======================================================================
1.3 +231 -4 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/ConnectorBase.java
Index: ConnectorBase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/ConnectorBase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConnectorBase.java 2 Feb 2002 01:19:58 -0000 1.2
+++ ConnectorBase.java 11 Feb 2002 21:56:34 -0000 1.3
@@ -8,13 +8,30 @@
package org.apache.pss.connector;
+import java.io.File;
+import java.util.Hashtable;
+import java.lang.reflect.Method;
+
+import org.apache.pss.Connector;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.context.Context;
-import java.util.Hashtable;
+import org.omg.CORBA.ORB;
import org.omg.CORBA.LocalObject;
-import org.omg.CosPersistentState.*;
+import org.omg.CosPersistentState.EndOfAssociationCallback;
+import org.omg.CosPersistentState.TransactionalSession;
+import org.omg.CosPersistentState.SessionPool;
+import org.omg.CosPersistentState.Parameter;
+import org.omg.CosPersistentState.StorageHomeBase;
+import org.omg.CosPersistentState.StorageObject;
+import org.omg.CosPersistentState.Session;
+
import org.omg.CosTransactions.Coordinator;
/**
@@ -25,8 +42,23 @@
implements Connector, LogEnabled
{
+ //======================================================================
+ // static
+ //======================================================================
+
+ private static final int STORAGE_HOME_MODE = 0;
+ private static final int STORAGE_TYPE_MODE = 1;
+ private static final String STORAGE_HOME_KEY = "home";
+ private static final String STORAGE_TYPE_KEY = "storage";
+
public static final String flushAttributeName = "flush";
+ //======================================================================
+ // state
+ //======================================================================
+
+ private Context m_context;
+
private Logger m_log;
private Configuration m_defaults;
@@ -56,15 +88,20 @@
*/
protected Hashtable _session_pool_factories;
+ //======================================================================
+ // constructor
+ //======================================================================
/**
* Constructor for the ConnectorBase object.
+ * @param context application context
* @param defaults static connector configuration information
* @param identifier the connector impementation id
*/
- public ConnectorBase( Configuration defaults, String identifier )
+ public ConnectorBase( Context context, Configuration defaults, String identifier )
{
m_defaults = defaults;
+ m_context = context;
_id = identifier;
_object_factories = new Hashtable();
@@ -88,7 +125,7 @@
}
//======================================================================
- // implementation
+ // ConnectorBase
//======================================================================
/**
@@ -100,6 +137,97 @@
return m_defaults;
}
+ /**
+ * Register storage type and home PSDL to implementation declarations
+ * with the connector.
+ * @param config a configuration instance containing home and storage
+ * mapping betweeen PSDL identifiers and implementation classes
+ */
+ public void register( Configuration config )
+ {
+ register( config, STORAGE_HOME_MODE );
+ register( config, STORAGE_TYPE_MODE );
+ }
+
+ /**
+ * Creation of a basic session. The implementation will extract
+ * parameter declarations from the configuration based on the following
+ * declaration model:
+ *
+ * <pre>
+ *
+ * <any-root-element>
+ *
+ * <!--
+ * A parameter declaration must have a name attribute and
+ * either a file or value attribute. Attributes of the type
+ * file will be resolved relative to the application base directory.
+ * -->
+ *
+ * <parameter name="someName" value="someValue" />
+ * <parameter name="color" value="red" />
+ * <parameter name="color" file="./data" />
+ *
+ * </any-root-element>
+ *
+ * </pre>
+ *
+ * @param config a configuration containing session parameter declarations
+ * @return <code>Session</code> a PSS basic session
+ */
+ public org.apache.pss.Session createBasicSession( Configuration config )
+ {
+
+ File base = getBaseDirectory();
+
+ try
+ {
+ Configuration[] params = config.getChildren("parameter");
+ Parameter[] parameters = new Parameter[ params.length ];
+ for( int i=0; i<params.length; i++ )
+ {
+ final Parameter p = new Parameter();
+ p.name = params[i].getAttribute("name");
+ p.val = ORB.init().create_any();
+ try
+ {
+ p.val.insert_string( parseValue( params[i].getAttribute("value") ));
+ parameters[i] = p;
+ }
+ catch( Throwable x )
+ {
+ try
+ {
+ final String value = params[i].getAttribute("file");
+ final String s = parseValue( value );
+ final File f = new File( base, s );
+ final String path = f.getAbsolutePath();
+ p.val.insert_string( path );
+ parameters[i] = p;
+ }
+ catch( Throwable fileError )
+ {
+ final String error = "Could not resolve a 'value' or 'file' attribute on "
+ + "property named '" + params[i].getAttribute("name") + "'.";
+ throw new ConfigurationException( error, fileError );
+ }
+ }
+ }
+
+ return (org.apache.pss.Session) create_basic_session(
+ org.omg.CosPersistentState.READ_WRITE.value, parameters );
+ }
+ catch( Throwable e )
+ {
+ final String error = "Internal error while attempting to create a PSS basic session";
+ throw new CascadingRuntimeException( error, e );
+ }
+ }
+
+ //======================================================================
+ // Connector
+ //======================================================================
+
/**
* Returns the persistent object identifier of the supplied storage object.
* @param obj the storage object instance
@@ -285,4 +413,103 @@
return clazz;
}
+
+ //=================================================================
+ // internals
+ //=================================================================
+
+ private void register( Configuration config, int mode )
+ {
+ try
+ {
+ String key = "";
+ Configuration[] children = null;
+ if( mode == STORAGE_HOME_MODE )
+ {
+ children = config.getChildren( STORAGE_HOME_KEY );
+ }
+ else
+ {
+ children = config.getChildren( STORAGE_TYPE_KEY );
+ }
+
+ for( int i = 0; i< children.length; i++ )
+ {
+ String psdl = "";
+ String value = "";
+ Configuration c = children[i];
+ try
+ {
+ psdl = c.getAttribute( "psdl" );
+ }
+ catch (ConfigurationException e)
+ {
+ final String error = "missing 'psdl' attribute";
+ throw new ConfigurationException( error, e );
+ }
+
+ try
+ {
+ value = c.getAttribute( "class" );
+ }
+ catch (ConfigurationException e)
+ {
+ final String error = "missing 'class' attribute";
+ throw new ConfigurationException( error, e );
+ }
+
+ if( mode == STORAGE_HOME_MODE )
+ {
+ register_storage_home_factory( psdl, Class.forName( value ) );
+ }
+ else
+ {
+ register_storage_object_factory( psdl, Class.forName( value ) );
+ }
+ }
+ }
+ catch( Throwable throwable )
+ {
+ final String error = "Unexpected exception while processing PSS for ";
+ if( mode == STORAGE_HOME_MODE )
+ {
+ throw new CascadingRuntimeException( error + STORAGE_HOME_KEY, throwable );
+ }
+ else
+ {
+ throw new CascadingRuntimeException( error + STORAGE_TYPE_KEY, throwable );
+ }
+ }
+ }
+
+
+ /**
+ * Parse a string value and replace occurances of "${<name>}" with the
+ * corresponding system property value. If a system property is undefined,
+ * throw a runtime exception with context message.
+ */
+ private static String parseValue( String input )
+ {
+ int i = input.indexOf("${");
+ if( i < 0 ) return input;
+ int j = input.indexOf("}",i);
+ String key = input.substring( i+2, j );
+ String value = System.getProperty( key );
+ return parseValue( input.substring( 0, i )
+ + value + input.substring( j+1, input.length() ));
+ }
+
+ 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.5 +6 -4 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/database/DatabaseConnector.java
Index: DatabaseConnector.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/database/DatabaseConnector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DatabaseConnector.java 2 Feb 2002 10:29:54 -0000 1.4
+++ DatabaseConnector.java 11 Feb 2002 21:56:34 -0000 1.5
@@ -18,6 +18,7 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.PERSIST_STORE;
@@ -41,7 +42,7 @@
// static
//======================================================================
- public static final String IMPLEMENTATION_ID = "PSS:APACHE:database";
+ public static final String IMPLEMENTATION_ID = "database";
public static FlushManager manager;
@@ -50,12 +51,13 @@
/**
* Constructor for the DatabaseConnector object
- * @param orbinitinfo the initial ORB interceptor info
+ * @param context the application context
* @param defaults static file connector configuration information
+ * @param orbinitinfo the initial ORB interceptor info
*/
- public DatabaseConnector( Configuration defaults, ORBInitInfo orbinitinfo )
+ public DatabaseConnector( Context context, Configuration defaults, ORBInitInfo orbinitinfo )
{
- super( defaults, IMPLEMENTATION_ID );
+ super( context, defaults, IMPLEMENTATION_ID );
_info = orbinitinfo;
manager = new FlushManager(
getDefaultsConfiguration().getAttributeAsInteger( flushAttributeName, 40 ) );
1.4 +1 -1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/database/DatabaseSession.java
Index: DatabaseSession.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/database/DatabaseSession.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DatabaseSession.java 2 Feb 2002 03:04:45 -0000 1.3
+++ DatabaseSession.java 11 Feb 2002 21:56:34 -0000 1.4
@@ -32,7 +32,6 @@
import org.omg.CORBA.INITIALIZE;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
-import org.omg.CosPersistentState.Session;
import org.omg.CosPersistentState.Parameter;
import org.omg.CosPersistentState.StorageHomeBase;
import org.omg.CosPersistentState.StorageObject;
@@ -40,6 +39,7 @@
import org.openorb.iiop.CDROutputStream;
+import org.apache.pss.Session;
import org.apache.pss.connector.PID;
import org.apache.pss.connector.BasePID;
import org.apache.pss.connector.PIDFactory;
1.4 +4 -3 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/file/FileConnector.java
Index: FileConnector.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/file/FileConnector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileConnector.java 2 Feb 2002 10:29:54 -0000 1.3
+++ FileConnector.java 11 Feb 2002 21:56:34 -0000 1.4
@@ -18,6 +18,7 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.PERSIST_STORE;
@@ -40,7 +41,7 @@
// static
//======================================================================
- public static final String IMPLEMENTATION_ID = "PSS:APACHE:file";
+ public static final String IMPLEMENTATION_ID = "file";
//======================================================================
// state
@@ -63,9 +64,9 @@
* @param defaults static file connector configuration information
* @param info interceptor orb init info
*/
- public FileConnector( Configuration defaults, ORBInitInfo info )
+ public FileConnector( Context context, Configuration defaults, ORBInitInfo info )
{
- super( defaults, IMPLEMENTATION_ID );
+ super( context, defaults, IMPLEMENTATION_ID );
_info = info;
_sessions = new Vector();
1.5 +4 -1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/file/FileSession.java
Index: FileSession.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/file/FileSession.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FileSession.java 2 Feb 2002 10:29:54 -0000 1.4
+++ FileSession.java 11 Feb 2002 21:56:34 -0000 1.5
@@ -28,7 +28,9 @@
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
-import org.omg.CosPersistentState.*;
+import org.omg.CosPersistentState.Parameter;
+import org.omg.CosPersistentState.StorageHomeBase;
+import org.omg.CosPersistentState.StorageObject;
import org.omg.GIOP.Version;
import org.omg.PortableInterceptor.ORBInitInfo;
@@ -40,6 +42,7 @@
import org.openorb.io.MarshalBuffer;
import org.openorb.io.StorageBuffer;
+import org.apache.pss.Session;
import org.apache.pss.connector.PID;
import org.apache.pss.connector.BasePID;
import org.apache.pss.connector.PersistenceException;
1.4 +4 -3 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/memory/MemoryConnector.java
Index: MemoryConnector.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/memory/MemoryConnector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MemoryConnector.java 2 Feb 2002 10:29:54 -0000 1.3
+++ MemoryConnector.java 11 Feb 2002 21:56:34 -0000 1.4
@@ -16,15 +16,16 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
import org.omg.CORBA.PERSIST_STORE;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CosPersistentState.TransactionalSession;
-import org.omg.CosPersistentState.Session;
import org.omg.CosPersistentState.Parameter;
import org.omg.CosPersistentState.EndOfAssociationCallback;
import org.omg.CosPersistentState.SessionPool;
+import org.omg.CosPersistentState.Session;
import org.omg.CosTransactions.Coordinator;
import org.omg.PortableInterceptor.ORBInitInfo;
@@ -61,9 +62,9 @@
*
* @param info
*/
- public MemoryConnector( Configuration defaults, ORBInitInfo info )
+ public MemoryConnector( Context context, Configuration defaults, ORBInitInfo info )
{
- super( defaults, IMPLEMENTATION_ID );
+ super( context, defaults, IMPLEMENTATION_ID );
_info = info;
}
1.5 +4 -1 jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/memory/MemorySession.java
Index: MemorySession.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector/memory/MemorySession.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MemorySession.java 2 Feb 2002 10:29:54 -0000 1.4
+++ MemorySession.java 11 Feb 2002 21:56:34 -0000 1.5
@@ -19,9 +19,12 @@
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.PERSIST_STORE;
-import org.omg.CosPersistentState.*;
+import org.omg.CosPersistentState.Parameter;
+import org.omg.CosPersistentState.StorageHomeBase;
+import org.omg.CosPersistentState.StorageObject;
import org.omg.PortableInterceptor.ORBInitInfo;
+import org.apache.pss.Session;
import org.apache.pss.connector.PID;
import org.apache.pss.connector.BasePID;
import org.apache.pss.connector.PIDFactory;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>