notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1907 - in development/main/transit/core/handler: . etc/main src/main/net/dpml/transit src/main/net/dpml/transit/artifact
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1907 - in development/main/transit/core/handler: . etc/main src/main/net/dpml/transit src/main/net/dpml/transit/artifact
- Date: Sat, 26 Feb 2005 01:23:44 +0100
Author: mcconnell
Date: Sat Feb 26 01:23:43 2005
New Revision: 1907
Added:
development/main/transit/core/handler/etc/main/jndi.properties
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/RemoteCacheHandler.java
Modified:
development/main/transit/core/handler/build.xml
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/ClassicResolver.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
Log:
Move the registration and lookup of remote references inside transit.
Modified: development/main/transit/core/handler/build.xml
==============================================================================
--- development/main/transit/core/handler/build.xml (original)
+++ development/main/transit/core/handler/build.xml Sat Feb 26 01:23:43
2005
@@ -41,7 +41,7 @@
</target>
<target name="build" depends="standard.build">
- <rmic base="${basedir}/target/classes"
includes="**/FileCacheHandler*.class"/>
+ <rmic base="${basedir}/target/classes" includes="**/Remote*.class"/>
</target>
<target name="package" depends="build">
Added: development/main/transit/core/handler/etc/main/jndi.properties
==============================================================================
--- (empty file)
+++ development/main/transit/core/handler/etc/main/jndi.properties Sat
Feb 26 01:23:43 2005
@@ -0,0 +1,3 @@
+#java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
+#java.naming.provider.url=rmi://localhost:1099
+
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
Sat Feb 26 01:23:43 2005
@@ -205,6 +205,8 @@
}
}
+ private boolean m_server;
+
/**
* Private constructor of a transit instance.
* @param monitor the bootstrap monitor
@@ -225,6 +227,7 @@
private Transit( boolean server, SystemMonitor monitor )
throws TransitException
{
+ m_server = server;
try
{
if( monitor.isTraceEnabled() )
@@ -304,6 +307,23 @@
public Object start( URI uri, Object[] args )
throws TransitException, URISyntaxException, IOException,
NullArgumentException
{
+ if( m_server )
+ {
+ boolean running = true;
+ while( running )
+ {
+ try
+ {
+ Thread.currentThread().sleep( 100 );
+ }
+ catch( Throwable e )
+ {
+ running = false;
+ }
+ }
+ return null;
+ }
+
if( null == uri )
{
throw new NullArgumentException( "uri" );
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
Sat Feb 26 01:23:43 2005
@@ -23,8 +23,6 @@
import java.io.IOException;
import java.util.Map;
-import java.rmi.Remote;
-
import net.dpml.transit.TransitException;
/**
@@ -35,7 +33,7 @@
* Selection of a cache manager is defined under the transit cache
configuration
* properties.
*/
-public interface CacheHandler extends Remote
+public interface CacheHandler
{
/**
* The domain identifier.
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ClassicResolver.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ClassicResolver.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ClassicResolver.java
Sat Feb 26 01:23:43 2005
@@ -19,6 +19,8 @@
package net.dpml.transit.artifact;
+import java.io.Serializable;
+
/** The ClassicResolver decodes artifacts into the Classic/Maven layout
* of artifacts on a file system or http server.
* This format says that for an artifact
<code>artifact:[type]:[group]/[name]#[version]</code>
@@ -28,7 +30,7 @@
* would return the path
<code>metro/cache/jars/dpml-cache-main-1.0.0.jar</code>.
*/
public class ClassicResolver
- implements LocationResolver
+ implements LocationResolver, Serializable
{
/**
* Return the base path for an artifact. The base path is derived from
Added:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/RemoteCacheHandler.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/RemoteCacheHandler.java
Sat Feb 26 01:23:43 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 2004 Niclas Hedhman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit.artifact;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import java.rmi.Remote;
+
+import net.dpml.lang.NullArgumentException;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.TransitException;
+import net.dpml.transit.monitors.Monitor;
+
+import net.dpml.transit.monitors.CacheMonitorRouter;
+
+/**
+ * Default cache handler that maintains a file based cache.
+ */
+public class RemoteCacheHandler
+ implements CacheHandler, Remote, Serializable
+{
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ /**
+ * The base directory of the cache.
+ */
+ transient CacheHandler m_delegate;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Creation of a new file based cache handler.
+ * @param monitor the assigned monitor
+ * @param hosts the assigned hosts
+ * @param props the properties against which this instance will be
configured
+ */
+ public RemoteCacheHandler( CacheHandler delegate )
+ {
+ m_delegate = delegate;
+ }
+
+ //
------------------------------------------------------------------------
+ // CacheHandler
+ //
------------------------------------------------------------------------
+
+ /**
+ * Attempts to download and cache a remote artifact using a set of remote
+ * repositories. The operation is not fail fast and so it keeps trying
if
+ * the first repository does not have the artifact in question.
+ *
+ * @param artifact the artifact to retrieve and cache
+ * @return file referencing the local resource
+ * @exception IOException if an IO error occurs.
+ * @exception TransitException if a transit system error occurs.
+ * @exception NullArgumentException if the artifact argument is null.
+ */
+ public File getResource( Artifact artifact )
+ throws IOException, TransitException, NullArgumentException
+ {
+ return m_delegate.getResource( artifact );
+ }
+
+}
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
Sat Feb 26 01:23:43 2005
@@ -30,12 +30,14 @@
import java.net.URL;
import java.net.UnknownHostException;
+import java.rmi.Naming;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.util.Properties;
import javax.naming.InitialContext;
+import javax.naming.ServiceUnavailableException;
import javax.naming.NamingException;
import net.dpml.lang.NullArgumentException;
@@ -131,7 +133,7 @@
/**
* Transt cahce handler service JNDI name.
*/
- private static final String TRANSIT_JNDI_NAME =
"rmi://localhost:1099/dpml/transit";
+ private static final String TRANSIT_JNDI_NAME =
"rmi://localhost:1099/transit";
//------------------------------------------------------------------
// state
@@ -205,7 +207,7 @@
if( !server )
{
// if the cache service is available on localhost then use it
otherwise
- // use the classic per jvm approach
+ // continue with the classic per jvm approach
try
{
@@ -218,9 +220,15 @@
m_CONTEXT = new SecuredTransitContext( handler );
return m_CONTEXT;
}
- catch( NamingException ne )
+ catch( ServiceUnavailableException e )
{
- boolean ignorable = true; // for checkstyle
+ //
+ }
+ catch( NamingException e )
+ {
+ final String error =
+ "Unexpected error while attempting to resolve remote cache
handler.";
+ throw new TransitException( error, e );
}
}
@@ -250,12 +258,16 @@
try
{
- LocateRegistry.getRegistry().bind( TRANSIT_JNDI_NAME,
m_CONTEXT.getCacheHandler() );
+ LocateRegistry.createRegistry( 1099 );
+ LocateRegistry.getRegistry().bind(
+ TRANSIT_JNDI_NAME,
+ new RemoteCacheHandler( m_CONTEXT.getCacheHandler() ) );
+ System.out.println( "# server registered on port 1099 as: "
+ TRANSIT_JNDI_NAME );
}
catch( Throwable e )
{
final String error =
- "Could not establish the cache handloer as a remotely
accessible service.";
+ "Could not establish the cache handler as a remote
service.";
throw new TransitException( error, e );
}
}
- svn commit: r1907 - in development/main/transit/core/handler: . etc/main src/main/net/dpml/transit src/main/net/dpml/transit/artifact, mcconnell, 02/25/2005
Archive powered by MHonArc 2.6.24.