mcconnell 2002/09/08 10:24:56
Modified: assembly/src/java/org/apache/excalibur/merlin/service
DefaultServiceManagementContext.java
InvalidPathException.java
UnknownServiceException.java
Log:
Upgraded the service magement context to original functionity.
Revision Changes Path
1.6 +37 -33
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultServiceManagementContext.java
Index: DefaultServiceManagementContext.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultServiceManagementContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultServiceManagementContext.java 8 Sep 2002 14:36:56 -0000 1.5
+++ DefaultServiceManagementContext.java 8 Sep 2002 17:24:55 -0000 1.6
@@ -34,12 +34,12 @@
private URL m_base;
/**
- * A parent context.
+ * A map of child naming context entries keyed by context name.
*/
private Map m_table = new Hashtable();
/**
- * A hashtable of resources keyed by service name.
+ * The parent naming context.
*/
private ServiceManagementContext m_parent;
@@ -54,15 +54,22 @@
//=============================================================
/**
- * Creation of a new service management context.
+ * Creation of a new service management context. The implementation
+ * handles the once only establishment of the service URL protocol
+ * handler and registers this instance as the root of the service
+ * management naming context hierachy.
*
- * @param parent a possibly null parent context
- * @param name the context name
- * @exception NullPointerException if the supplied name is null
+ * @param domain the host domain name
+ * @exception NullPointerException if the supplied domain name is null
+ * @exception MalformedURLException if the supplied domain name is inconsistent
*/
public DefaultServiceManagementContext( final String domain )
throws NullPointerException, MalformedURLException
{
+ if( domain == null )
+ {
+ throw new NullPointerException( "domain" );
+ }
URL.setURLStreamHandlerFactory( new ServiceURLFactory( domain, this ) );
m_base = new URL("service", domain, -1, "/");
}
@@ -70,9 +77,9 @@
/**
* Creation of a new service management context.
*
- * @param parent a possibly null parent context
+ * @param parent the parent context
* @param name the context name
- * @exception NullPointerException if the supplied name is null
+ * @exception NullPointerException if the supplied name or parent is null
*/
public DefaultServiceManagementContext( final ServiceManagementContext parent,
final String name )
throws NullPointerException, MalformedURLException
@@ -90,7 +97,6 @@
URL base = m_parent.getBase();
String path = base.getPath();
-
if( name.endsWith("/") )
{
m_base = new URL( base, path + name );
@@ -194,26 +200,13 @@
*/
public Resource locate( String uri ) throws UnknownServiceException,
InvalidPathException
{
- System.out.println("## uri: '" + uri + "'");
-
- throw new UnsupportedOperationException();
-
-/*
-
- URI path = m_base.relativize( uri );
- System.out.println("## base: '" + m_base + "'");
- System.out.println("## locating: '" + path + "'");
- if( path.getPath().indexOf("/") > -1 )
+ if( uri.indexOf("/") > -1 )
{
- //
- // its a reference to a nested context
- //
-
- String name = path.getPath().substring( 0, path.getPath().indexOf("/")
);
+ String name = uri.substring( 0, uri.indexOf("/") );
ServiceManagementContext child = (ServiceManagementContext)
m_children.get( name );
if( child != null )
{
- return child.locate( uri );
+ return child.locate( uri.substring( uri.indexOf("/") + 1,
uri.length() ) );
}
else
{
@@ -224,18 +217,29 @@
else
{
//
- // its a reference to an immediate entity
+ // its an immediate resource
//
- Resource resource = (Resource) m_table.get( path );
- if( resource != null )
+ ServiceManagementContext child = (ServiceManagementContext)
m_children.get( uri );
+ if( child != null )
+ {
+ //
+ // then forward the request to the child context
+ //
+
+ return child.locate("");
+ }
+ else
{
- return resource;
+ Resource resource = (Resource) m_table.get( uri );
+ if( resource != null )
+ {
+ return resource;
+ }
+ final String error = "Could not locate the requested service.";
+ throw new UnknownServiceException( uri, error );
}
- final String error = "Could not locate the requested service.";
- throw new UnknownServiceException( uri, error );
}
-*/
}
}
1.5 +5 -5
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/InvalidPathException.java
Index: InvalidPathException.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/InvalidPathException.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- InvalidPathException.java 8 Sep 2002 14:36:56 -0000 1.4
+++ InvalidPathException.java 8 Sep 2002 17:24:55 -0000 1.5
@@ -19,15 +19,15 @@
public final class InvalidPathException
extends Exception
{
- private final URL m_path;
+ private final String m_path;
/**
* Construct a new <code>InvalidPathException</code> instance.
*
- * @param path The supplied URL path.
+ * @param path The supplied url path.
* @param message The detail message for this exception.
*/
- public InvalidPathException( final URL path, final String message )
+ public InvalidPathException( final String path, final String message )
{
super( message );
m_path = path;
@@ -37,7 +37,7 @@
* Return the URL path from which the exception was raised.
* @return the path URL
*/
- public URL getPath()
+ public String getPath()
{
return m_path;
}
1.5 +5 -5
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/UnknownServiceException.java
Index: UnknownServiceException.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/UnknownServiceException.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UnknownServiceException.java 8 Sep 2002 14:36:56 -0000 1.4
+++ UnknownServiceException.java 8 Sep 2002 17:24:55 -0000 1.5
@@ -18,7 +18,7 @@
public final class UnknownServiceException
extends Exception
{
- private final URL m_path;
+ private final String m_path;
/**
* Construct a new <code>UnknownServiceException</code> instance.
@@ -26,7 +26,7 @@
* @param path The supplied URL path.
* @param message The detail message for this exception.
*/
- public UnknownServiceException( final URL path, final String message )
+ public UnknownServiceException( final String path, final String message )
{
super( message );
m_path = path;
@@ -34,9 +34,9 @@
/**
* Return the URL path from which the exception was raised.
- * @return the path URL
+ * @return the path
*/
- public URL getPath()
+ public String getPath()
{
return m_path;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>