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/12 00:58:16 UTC
cvs commit: jakarta-avalon-cornerstone/apps/enterprise/pss/src/java/org/apache/pss/connector ConnectorBase.java
mcconnell 02/02/11 15:58:16
Modified: apps/enterprise/pss/src/java/org/apache/pss/connector
ConnectorBase.java
Log:
simplified bootstrap mechanisms if running under non-Avalon manager
Revision Changes Path
1.4 +38 -7 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConnectorBase.java 11 Feb 2002 21:56:34 -0000 1.3
+++ ConnectorBase.java 11 Feb 2002 23:58:16 -0000 1.4
@@ -46,6 +46,11 @@
// static
//======================================================================
+ /**
+ * Context key for the base directory.
+ */
+ public static final String APP_HOME_DIR = "app.home";
+
private static final int STORAGE_HOME_MODE = 0;
private static final int STORAGE_TYPE_MODE = 1;
private static final String STORAGE_HOME_KEY = "home";
@@ -499,17 +504,43 @@
+ value + input.substring( j+1, input.length() ));
}
+ /**
+ * Normally the Initilizer will be initialized as part of an ORB loading
+ * process during which it would be supplied with a BlockContext. To
+ * circumvent dependencies on Pheonix, the application base directory
+ * from which file based persistence paths are resolved it established
+ * by looking for a file under the context key of APP_HOME_DIR. If that
+ * fails, the implementation will attempt to resolve the base directory
+ * by invoking a method named <code>getBaseDirectory</code> if it exists
+ * on the supplied context. As a last resort, the implementation returns
+ * a <code>File</code> based on the "user.dir" System property.
+ *
+ * @return File the base directory
+ */
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 )
+ if( m_context != null )
{
+ try
+ {
+ Object object = m_context.get( APP_HOME_DIR );
+ if( object instanceof File ) return (File) object;
+ if( object instanceof String ) return new File( (String) object );
+ }
+ catch( Throwable e )
+ {
+ // no keyed value
+ }
+ try
+ {
+ Method method = m_context.getClass().getMethod( "getBaseDirectory", new Class[0] );
+ return (File) method.invoke( m_context, new Object[0] );
+ }
+ catch( Throwable e )
+ {
+ // no equivalent method
+ }
}
return new File( System.getProperty("user.dir") );
}
-
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>