notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1906 - in development/main/transit/core: handler handler/etc/main handler/src/main/net/dpml/transit handler/src/main/net/dpml/transit/artifact plugin/etc/bin
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1906 - in development/main/transit/core: handler handler/etc/main handler/src/main/net/dpml/transit handler/src/main/net/dpml/transit/artifact plugin/etc/bin
- Date: Fri, 25 Feb 2005 22:26:04 +0100
Author: mcconnell
Date: Fri Feb 25 22:26:03 2005
New Revision: 1906
Added:
development/main/transit/core/handler/etc/main/
Modified:
development/main/transit/core/handler/build.xml
development/main/transit/core/handler/src/main/net/dpml/transit/Main.java
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/CacheHandler.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/StandardResourceManager.java
development/main/transit/core/plugin/etc/bin/transit.bat
Log:
Work in progress!
It ain't as easy as it seems to be.
Modified: development/main/transit/core/handler/build.xml
==============================================================================
--- development/main/transit/core/handler/build.xml (original)
+++ development/main/transit/core/handler/build.xml Fri Feb 25 22:26:03
2005
@@ -40,6 +40,10 @@
</copy>
</target>
+ <target name="build" depends="standard.build">
+ <rmic base="${basedir}/target/classes"
includes="**/FileCacheHandler*.class"/>
+ </target>
+
<target name="package" depends="build">
<mkdir dir="${target.deliverables.jars.dir}"/>
<jar destfile="${target.deliverables.jars.dir}/${project.filename}"
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/Main.java
==============================================================================
--- development/main/transit/core/handler/src/main/net/dpml/transit/Main.java
(original)
+++ development/main/transit/core/handler/src/main/net/dpml/transit/Main.java
Fri Feb 25 22:26:03 2005
@@ -32,6 +32,7 @@
import net.dpml.transit.adapter.NetworkMonitorAdapter;
import net.dpml.transit.adapter.ConsoleAdapter;
import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.artifact.ResourceManager;
import net.dpml.transit.monitors.Monitor;
import net.dpml.transit.monitors.RepositoryMonitor;
import net.dpml.transit.monitors.CacheMonitor;
@@ -122,14 +123,33 @@
}
}
+ if( debug )
+ {
+ System.getProperties().list( System.out );
+ }
+ ConsoleMonitor console = new ConsoleMonitor( debug );
+ SystemMonitor monitor = new SystemMonitor( console );
+
+ //
+ // setup server mode
+ //
+
+ boolean server = false;
+ for( int i=0; i < args.length; i++ )
+ {
+ String arg = args[i];
+ if( arg.equals( "-Xserver" ) )
+ {
+ server = true;
+ }
+ }
+
//
// setup transit
//
- ConsoleMonitor console = new ConsoleMonitor( debug );
- SystemMonitor monitor = new SystemMonitor( console );
+ Transit transit = Transit.getInstance( server, monitor );
- Transit transit = Transit.getInstance( monitor );
Adapter adapter = new ConsoleAdapter( debug );
RepositoryMonitor repoMonitor = new RepositoryMonitorAdapter(
adapter );
CacheMonitor cacheMonitor = new CacheMonitorAdapter( adapter );
@@ -203,7 +223,7 @@
adapter.debug( "Starting transit." );
adapter.debug( uri.toString() );
- Transit.getInstance().start( uri, params );
+ transit.start( uri, params );
}
/**
@@ -225,6 +245,10 @@
{
final boolean ignorable = true;
}
+ else if( arg.startsWith( "-Xmanager=" ) )
+ {
+ final boolean ignorable = true;
+ }
else
{
list.add( arg );
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
Fri Feb 25 22:26:03 2005
@@ -161,12 +161,13 @@
public static Transit getInstance()
throws TransitException
{
- return Transit.getInstance( new SystemMonitor() );
+ return Transit.getInstance( false, new SystemMonitor() );
}
/**
* Returns the singleton instance of the transit system. If this method
- * has already been invoked the monitor argument will be ignored.
+ * has already been invoked the server and monitor argument will be
ignored.
+ * @param server JNDI server address
* @param monitor the bootstrap monitor
* @return the singleton transit instance
* @exception TransitException if an error occurs during establishment
@@ -175,6 +176,21 @@
public static Transit getInstance( SystemMonitor monitor )
throws TransitException, NullArgumentException
{
+ return Transit.getInstance( false, new SystemMonitor() );
+ }
+
+ /**
+ * Returns the singleton instance of the transit system. If this method
+ * has already been invoked the monitor argument will be ignored.
+ * @param server the server mode
+ * @param monitor the bootstrap monitor
+ * @return the singleton transit instance
+ * @exception TransitException if an error occurs during establishment
+ * @exception NullArgumentException if the monitor argument is null.
+ */
+ public static Transit getInstance( boolean server, SystemMonitor monitor
)
+ throws TransitException, NullArgumentException
+ {
if( null == monitor )
{
throw new NullArgumentException( "monitor" );
@@ -183,7 +199,7 @@
{
if( m_INSTANCE == null )
{
- m_INSTANCE = new Transit( monitor );
+ m_INSTANCE = new Transit( server, monitor );
}
return m_INSTANCE;
}
@@ -194,7 +210,19 @@
* @param monitor the bootstrap monitor
* @exception TransitException if an establishment error occurs
*/
- private Transit( SystemMonitor monitor )
+ public Transit( SystemMonitor monitor )
+ throws TransitException
+ {
+ this( false, monitor );
+ }
+
+ /**
+ * Private constructor of a transit instance.
+ * @param server the server mode
+ * @param monitor the bootstrap monitor
+ * @exception TransitException if an establishment error occurs
+ */
+ private Transit( boolean server, SystemMonitor monitor )
throws TransitException
{
try
@@ -203,7 +231,8 @@
{
monitor.trace( "creating transit instance" );
}
- SecuredTransitContext.create( monitor ); // Ensure secured
environment.
+
+ SecuredTransitContext.create( server, monitor ); // Ensure
secured environment.
m_repositoryMonitor = new RepositoryMonitorRouter( monitor );
m_cacheMonitor = new CacheMonitorRouter( monitor );
m_networkMonitor = new NetworkMonitorRouter( monitor );
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/CacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/CacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/CacheHandler.java
Fri Feb 25 22:26:03 2005
@@ -23,6 +23,8 @@
import java.io.IOException;
import java.util.Map;
+import java.rmi.Remote;
+
import net.dpml.transit.TransitException;
/**
@@ -33,7 +35,7 @@
* Selection of a cache manager is defined under the transit cache
configuration
* properties.
*/
-public interface CacheHandler
+public interface CacheHandler extends Remote
{
/**
* The domain identifier.
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/FileCacheHandler.java
Fri Feb 25 22:26:03 2005
@@ -99,7 +99,7 @@
*
* @return the feature collection
*/
- void setLocalCacheDirectory( File file )
+ protected void setLocalCacheDirectory( File file )
{
synchronized( m_cacheDir )
{
@@ -112,7 +112,7 @@
*
* @return the feature collection
*/
- File getLocalCacheDirectory()
+ protected File getLocalCacheDirectory()
{
return m_cacheDir;
}
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
Fri Feb 25 22:26:03 2005
@@ -30,8 +30,14 @@
import java.net.URL;
import java.net.UnknownHostException;
+import java.rmi.registry.Registry;
+import java.rmi.registry.LocateRegistry;
+
import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import net.dpml.lang.NullArgumentException;
import net.dpml.transit.Transit;
@@ -122,6 +128,11 @@
*/
private static final String DEFAULT_REMOTE_AUTHORITY =
"http://repository.dpml.net";
+ /**
+ * Transt cahce handler service JNDI name.
+ */
+ private static final String TRANSIT_JNDI_NAME =
"rmi://localhost:1099/dpml/transit";
+
//------------------------------------------------------------------
// state
//------------------------------------------------------------------
@@ -160,7 +171,7 @@
public static SecuredTransitContext create()
throws TransitException
{
- return SecuredTransitContext.create( new SystemMonitor() );
+ return SecuredTransitContext.create( false, new SystemMonitor() );
}
/**
@@ -168,13 +179,14 @@
* been established the method returns the singeton context otherwise a
new context
* is created relative to the authoritve url and returned.
*
+ * @param server the server mode
* @param monitor the bootstrap monitor
* @return the secured transit context
* @exception TransitException if an error occurs during context creation
* @exception NullArgumentException if the supplied monitor is null and
an instance
* of this class has not been created already.
*/
- public static SecuredTransitContext create( final SystemMonitor monitor )
+ public static SecuredTransitContext create( boolean server, final
SystemMonitor monitor )
throws TransitException, NullArgumentException
{
if( m_CONTEXT != null )
@@ -189,6 +201,31 @@
{
monitor.trace( "creating secure transit context" );
}
+
+ if( !server )
+ {
+ // if the cache service is available on localhost then use it
otherwise
+ // use the classic per jvm approach
+
+ try
+ {
+ InitialContext context = new InitialContext();
+ CacheHandler handler = (CacheHandler) context.lookup(
TRANSIT_JNDI_NAME );
+ if( monitor.isTraceEnabled() )
+ {
+ monitor.trace( "binding to shared cache handler" );
+ }
+ m_CONTEXT = new SecuredTransitContext( handler );
+ return m_CONTEXT;
+ }
+ catch( NamingException ne )
+ {
+ boolean ignorable = true; // for checkstyle
+ }
+ }
+
+ // proceed with context establishment
+
try
{
URL authorative = establishAuthority( monitor );
@@ -199,13 +236,31 @@
CacheHandler ch = manager.createCacheHandler();
monitor.notifyCacheHandlerCreation( ch );
m_CONTEXT = new SecuredTransitContext( authorative, ch, props );
- return m_CONTEXT;
}
catch( IOException e )
{
String error = "Unable to establish the SecuredTransitContext.";
throw new TransitException( error, e );
}
+
+ if( server )
+ {
+ // publish the cache handler as a remotely accessible service on
localhost
+ // (need to fix this with Nicals)
+
+ try
+ {
+ LocateRegistry.getRegistry().bind( TRANSIT_JNDI_NAME,
m_CONTEXT.getCacheHandler() );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not establish the cache handloer as a remotely
accessible service.";
+ throw new TransitException( error, e );
+ }
+ }
+
+ return m_CONTEXT;
}
/**
@@ -253,12 +308,29 @@
*/
private static String getResourceManagerClassname( Properties props )
throws TransitException
{
- return props.getProperty(
+ return System.getProperty(
+ ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME_KEY,
+ props.getProperty(
ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME_KEY,
- ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME );
+ ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME ) );
+ }
+
+ /**
+ * Creation of a new secured transit context using a remote service.
+ * @param authorative the authorative url
+ * @param hosts the set of hosts
+ * @param handler the cache handler
+ * @exception TransitException if a context creation error occurs
+ */
+ private SecuredTransitContext( CacheHandler handler )
+ throws TransitException
+ {
+ m_authorativeHost = null;
+ m_cacheHandler = handler;
}
- /** This constructor should only be used for the testcases.
+ /**
+ * Creation of a new secured transit context.
* @param authorative the authorative url
* @param hosts the set of hosts
* @param handler the cache handler
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/StandardResourceManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/StandardResourceManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/StandardResourceManager.java
Fri Feb 25 22:26:03 2005
@@ -126,7 +126,7 @@
* @exception IOException if an io error occurs
* @exception TransitException if a transit system error occurs
*/
- CacheHandler createCacheHandler( String classname )
+ protected CacheHandler createCacheHandler( String classname )
throws TransitException, IOException
{
try
Modified: development/main/transit/core/plugin/etc/bin/transit.bat
==============================================================================
--- development/main/transit/core/plugin/etc/bin/transit.bat (original)
+++ development/main/transit/core/plugin/etc/bin/transit.bat Fri Feb 25
22:26:03 2005
@@ -23,7 +23,7 @@
set $CACHED="%DPML_HOME%\Data\cache\%DPML_TRANSIT_JAR%"
set $LIBRARY="%DPML_SYSTEM%\local\%DPML_TRANSIT_JAR%"
if EXIST %$CACHED% ( set $CLASSPATH=%$CACHED% ) ELSE ( set
$CLASSPATH=%$LIBRARY% )
-set $SUPPLIMENT="%DPML_HOME%\Preferences\transit\lib"
+set $SUPPLIMENT="%DPML_SYSTEM%\lib\osm-transit-adapter-SNAPSHOT.jar"
set $POLICY=-Djava.security.policy="%DPML_SYSTEM%\bin\security.policy"
set $ARGS=%*
- svn commit: r1906 - in development/main/transit/core: handler handler/etc/main handler/src/main/net/dpml/transit handler/src/main/net/dpml/transit/artifact plugin/etc/bin, mcconnell, 02/25/2005
Archive powered by MHonArc 2.6.24.