notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1912 - in development/main/transit/core/handler/src/main/net/dpml/transit: . artifact repository
- From: niclas AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1912 - in development/main/transit/core/handler/src/main/net/dpml/transit: . artifact repository
- Date: Mon, 28 Feb 2005 15:17:10 +0100
Author: niclas
Date: Mon Feb 28 15:17:08 2005
New Revision: 1912
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/Transit.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ArtifactURLConnection.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/RemoteCacheHandler.java
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/SecuredTransitContext.java
development/main/transit/core/handler/src/main/net/dpml/transit/repository/PropertiesPlugin.java
Log:
Fixed the RMI exposure of the transit started with the -Xserver
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
Mon Feb 28 15:17:08 2005
@@ -309,18 +309,6 @@
{
if( m_server )
{
- boolean running = true;
- while( running )
- {
- try
- {
- Thread.currentThread().sleep( 100 );
- }
- catch( Throwable e )
- {
- running = false;
- }
- }
return null;
}
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
Mon Feb 28 15:17:08 2005
@@ -39,6 +39,8 @@
public final class Artifact
implements Serializable, Comparable
{
+ static final long serialVersionUID = 1L;
+
//
------------------------------------------------------------------------
// static
//
------------------------------------------------------------------------
@@ -311,58 +313,7 @@
return ver;
}
}
-/*
- **
- * Return the base path for this artifact. The base path is derived from
- * the artifact group and type. For an artifact group of "metro/cache"
and a
- * type equal to "jar", the base value will be translated using the
pattern
- * "[group]/[type]s" to form "metro/cache/jars". The base path value
represents
- * the directory path relative to a repository root of the directory
containing
- * this artifact.
- *
- * @return the base path
- *
- public final String getBase()
- {
- return getGroup() + "/" + getType() + "s";
- }
-
- **
- * Returns the full path of the artifact relative to a logical root
directory.
- * The full path is equivalent to the base path and artifact filename
using the
- * pattern "[base]/[filename]". Path values may be used to resolve an
artifact
- * from a remote repository or local cache relative to the repository or
cache
- * root. An artifact such as
<code>artifact:jar:metro/cache/dpml-cache-main#1.0.0</code>
- * would return the path
<code>metro/cache/jars/dpml-cache-main-1.0.0.jar</code>.
- *
- * @see #getBase
- * @see #getFilename
- * @return the logical artifact path
- *
- public final String getPath()
- {
- return getBase() + "/" + getFilename();
- }
- **
- * Return the expanded filename of the artifact. The filename is
expressed
- * as [name]-[version].[type] or in case of a null version simply
[name].[type].
- *
- * @return the artifact expanded filename
- *
- public String getFilename()
- {
- String ver = getVersion();
- if( null == ver )
- {
- return m_name + "." + m_type;
- }
- else
- {
- return m_name + "-" + ver + "." + m_type;
- }
- }
-*/
/**
* Create an artifact url backed by the repository.
*
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
Mon Feb 28 15:17:08 2005
@@ -97,7 +97,7 @@
//
------------------------------------------------------------------------
/**
- * Establish a connection. The implementation will attempt to
+ * Establish a connection. The implementation will attempt to
* resolve the resource relative to the cache and associated hosts.
*
* @exception IOException is an error occurs while attempting to establish
@@ -107,7 +107,10 @@
throws IOException
{
CacheHandler cache = m_context.getCacheHandler();
- m_local = cache.getResource( m_artifact );
+ if( m_local == null )
+ {
+ m_local = cache.getResource( m_artifact );
+ }
m_connected = true;
}
@@ -158,7 +161,7 @@
/**
* Return the content for this artifact.
- * @param classes a sequence of classes against which the
+ * @param classes a sequence of classes against which the
* implementation will attempt to establish a known match
* @return the content object (possibly null)
* @exception IOException is an error occurs
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
Mon Feb 28 15:17:08 2005
@@ -21,8 +21,11 @@
import java.io.File;
import java.io.IOException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
import java.util.Map;
+
import net.dpml.transit.TransitException;
/**
@@ -33,7 +36,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.
@@ -66,6 +69,6 @@
* @exception TransitException is a transit system error occurs
*/
File getResource( Artifact artifact )
- throws IOException, TransitException;
+ throws IOException, TransitException, RemoteException;
}
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
Mon Feb 28 15:17:08 2005
@@ -19,8 +19,6 @@
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>
@@ -30,7 +28,7 @@
* would return the path
<code>metro/cache/jars/dpml-cache-main-1.0.0.jar</code>.
*/
public class ClassicResolver
- implements LocationResolver, Serializable
+ implements LocationResolver
{
/**
* Return the base path for an artifact. The base path is derived from
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/RemoteCacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/RemoteCacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/RemoteCacheHandler.java
Mon Feb 28 15:17:08 2005
@@ -1,6 +1,6 @@
/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 2004 Niclas Hedhman.
+ * Copyright 2004-2005 Stephen J. McConnell.
+ * Copyright 2004-2005 Niclas Hedhman.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.IOException;
-import java.io.Serializable;
import java.util.Map;
import java.util.Iterator;
@@ -29,6 +28,8 @@
import java.util.TreeMap;
import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
import net.dpml.lang.NullArgumentException;
@@ -41,8 +42,8 @@
/**
* Default cache handler that maintains a file based cache.
*/
-public class RemoteCacheHandler
- implements CacheHandler, Remote, Serializable
+public class RemoteCacheHandler extends UnicastRemoteObject
+ implements CacheHandler
{
//
------------------------------------------------------------------------
// state
@@ -51,7 +52,7 @@
/**
* The base directory of the cache.
*/
- transient CacheHandler m_delegate;
+ private CacheHandler m_delegate;
//
------------------------------------------------------------------------
// constructor
@@ -64,7 +65,9 @@
* @param props the properties against which this instance will be
configured
*/
public RemoteCacheHandler( CacheHandler delegate )
+ throws RemoteException
{
+ super();
m_delegate = delegate;
}
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
Mon Feb 28 15:17:08 2005
@@ -30,16 +30,13 @@
import java.net.URL;
import java.net.UnknownHostException;
-import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
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;
import net.dpml.transit.Transit;
@@ -216,9 +213,8 @@
try
{
- InitialContext context = new InitialContext();
- CacheHandler handler = (CacheHandler) context.lookup(
TRANSIT_JNDI_NAME );
- //CacheHandler handler = (CacheHandler) context.lookup(
"transit" );
+ Registry reg = LocateRegistry.getRegistry();
+ CacheHandler handler = (CacheHandler) reg.lookup(
TRANSIT_NAME );
if( monitor.isTraceEnabled() )
{
monitor.trace( "binding to shared cache handler" );
@@ -226,19 +222,23 @@
m_CONTEXT = new SecuredTransitContext( handler );
return m_CONTEXT;
}
- catch( ServiceUnavailableException e )
+ catch( NotBoundException e )
{
- //
+ // Ignore and continue
}
- catch( NamingException e )
+ catch( java.rmi.ConnectException e )
{
- final String error =
- "Unexpected error while attempting to resolve remote cache
handler.";
- throw new TransitException( error, e );
+ // Ignore and continue
+ }
+ catch( RemoteException e )
+ {
+ // Ignore and continue
+ System.out.println( "SJM: Could not find the
RemoteCacheHandler." );
}
}
- // proceed with context establishment
+ // proceed with context establishment
+
try
{
@@ -264,15 +264,15 @@
try
{
- LocateRegistry.createRegistry( 1099 );
- LocateRegistry.getRegistry().bind(
- TRANSIT_NAME,
- new RemoteCacheHandler( m_CONTEXT.getCacheHandler() ) );
+ CacheHandler lch = m_CONTEXT.getCacheHandler();
+ RemoteCacheHandler rch = new RemoteCacheHandler( lch );
+ Registry reg = LocateRegistry.createRegistry( 1099 );
+ reg.bind( TRANSIT_NAME, rch );
System.out.println( "# server registered on port 1099 as: "
+ TRANSIT_JNDI_NAME );
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Could not establish the cache handler as a remote
service.";
throw new TransitException( error, e );
}
@@ -282,16 +282,16 @@
}
/**
- * Create the resource manager that will be responsible for the
establishment
- * of the transit cache handler. The class implementating the resource
manager
- * is resolved relative to the transit property
- * 'dpml.transit.authority.resourcemanager.classname'. If undefined the
+ * Create the resource manager that will be responsible for the
establishment
+ * of the transit cache handler. The class implementating the resource
manager
+ * is resolved relative to the transit property
+ * 'dpml.transit.authority.resourcemanager.classname'. If undefined the
* default implementation used in the StandardResourceManager class.
- *
+ *
* @param props the transit properties
* @return the resource manager
*/
- private static ResourceManager createResourceManager(
+ private static ResourceManager createResourceManager(
String classname, URL authorative, SystemMonitor monitor ) throws
TransitException
{
try
@@ -308,7 +308,7 @@
}
catch( Throwable e )
{
- String error =
+ String error =
"Unable to establish the ResourceManager using the class ["
+ classname
+ "].";
@@ -317,23 +317,23 @@
}
/**
- * Return the classname of the class implementating the resource manager.
- * Resolved relative to the transit property
'dpml.transit.authority.resourcemanager.classname'.
+ * Return the classname of the class implementating the resource manager.
+ * Resolved relative to the transit property
'dpml.transit.authority.resourcemanager.classname'.
* If undefined the default classname is returned.
- *
+ *
* @param props the transit properties
* @return the resource manager classname
*/
private static String getResourceManagerClassname( Properties props )
throws TransitException
{
- return System.getProperty(
- ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME_KEY,
- props.getProperty(
- ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME_KEY,
+ return System.getProperty(
+ ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME_KEY,
+ props.getProperty(
+ ResourceManager.TRANSIT_RESOURCE_MANAGER_CLASSNAME_KEY,
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
@@ -347,7 +347,7 @@
m_cacheHandler = handler;
}
- /**
+ /**
* Creation of a new secured transit context.
* @param authorative the authorative url
* @param hosts the set of hosts
@@ -486,7 +486,7 @@
{
final String message =
"using extension authority file ["
- + javaAuthFile
+ + javaAuthFile
+ "]";
monitor.trace( message );
}
@@ -508,24 +508,24 @@
ResourceHelper.unpack( classloader,
"transit/authority/cache.properties", new File( authority, "cache.properties"
) );
ResourceHelper.unpack( classloader,
"transit/authority/hosts.xml.example", new File( authority,
"hosts.xml.example" ) );
ResourceHelper.unpack( classloader,
"transit/authority/transit.properties", new File( authority,
"transit.properties" ) );
- ResourceHelper.unpack(
+ ResourceHelper.unpack(
classloader, "transit/authority/hosts/local.host", new
File( hosts, "local.host" ) );
- ResourceHelper.unpack(
+ ResourceHelper.unpack(
classloader,
"transit/authority/hosts/repository.dpml.net.host", new File( hosts,
"repository.dpml.net.host" ) );
- ResourceHelper.unpack(
+ ResourceHelper.unpack(
classloader,
"transit/authority/hosts/www.ibiblio.org.host", new File( hosts,
"www.ibiblio.org.host" ) );
- ResourceHelper.unpack(
+ ResourceHelper.unpack(
classloader,
"transit/authority/hosts/www.apache.org.host", new File( hosts,
"www.apache.org.host" ) );
if( monitor.isTraceEnabled() )
{
final String message =
- "using bundled defaults ["
+ "using bundled defaults ["
+ artifactAuthFile
+ "]";
monitor.trace( message );
}
-
+
return useForAuthority( artifactAuthFile );
}
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/repository/PropertiesPlugin.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/repository/PropertiesPlugin.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/repository/PropertiesPlugin.java
Mon Feb 28 15:17:08 2005
@@ -42,6 +42,8 @@
class PropertiesPlugin
implements Plugin, Serializable
{
+ static final long serialVersionUID = 1L;
+
//-----------------------------------------------------------
// static
//-----------------------------------------------------------
- svn commit: r1912 - in development/main/transit/core/handler/src/main/net/dpml/transit: . artifact repository, niclas, 02/28/2005
Archive powered by MHonArc 2.6.24.