mcconnell 2002/09/08 21:33:53
Modified: assembly build.xml
assembly/lib corbaloc-1.0.jar orb-2.0.jar
assembly/src/etc demo.mf
assembly/src/etc/activator client.xml server.xml
assembly/src/idl demo.idl
assembly/src/java/org/apache/excalibur/merlin Main.java
assembly/src/java/org/apache/excalibur/merlin/activation
DefaultRemoteResource.java
DefaultRemoteResourceFactory.java
DefaultServiceResolver.java
assembly/src/java/org/apache/excalibur/merlin/assembly
ContainerManager.java ProfileRegistry.java
TypeManager.java
assembly/src/java/org/apache/excalibur/merlin/container
DefaultContainer.java
assembly/src/java/org/apache/excalibur/merlin/kernel
DefaultKernel.java
assembly/src/java/org/apache/excalibur/merlin/resource
DefaultManager.java DeploymentHelper.java
LifecycleHelper.java Resources.properties
Added: assembly/src/etc activation.mf
assembly/src/java/org/apache/excalibur/merlin
ExceptionHelper.java
assembly/src/java/org/apache/excalibur/merlin/activation
DefaultServantActivator.java
Log:
Addition of remote service activation and related test cases.
Revision Changes Path
1.57 +1 -1 jakarta-avalon-excalibur/assembly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- build.xml 8 Sep 2002 16:53:55 -0000 1.56
+++ build.xml 9 Sep 2002 04:33:52 -0000 1.57
@@ -77,8 +77,8 @@
<target name="deploy" depends="jar">
<mkdir dir="${extension.dir}"/>
- <copy todir="${extension.dir}" file="${build.lib}/${jar.name}"/>
<copy todir="${extension.dir}" file="${build.lib}/${activation.jar}"/>
+ <copy todir="${extension.dir}" file="${build.lib}/${jar.name}"/>
<copy todir="${extension.dir}" file="${logkit.jar}"/>
<copy todir="${extension.dir}" file="${avalon-framework.jar}"/>
<copy todir="${extension.dir}" file="${excalibur-i18n.jar}"/>
1.4 +50 -49 jakarta-avalon-excalibur/assembly/lib/corbaloc-1.0.jar
<<Binary file>>
1.3 +6 -6 jakarta-avalon-excalibur/assembly/lib/orb-2.0.jar
<<Binary file>>
1.5 +1 -1 jakarta-avalon-excalibur/assembly/src/etc/demo.mf
Index: demo.mf
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/demo.mf,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- demo.mf 7 Sep 2002 19:05:40 -0000 1.4
+++ demo.mf 9 Sep 2002 04:33:52 -0000 1.5
@@ -31,5 +31,5 @@
Name: org/apache/excalibur/playground/activation/ActivationClient.class
Avalon: Type
-Name: org/apache/excalibur/playground/remote/TestServant.class
+Name: org/apache/excalibur/playground/activation/TestServant.class
Avalon: Type
1.1 jakarta-avalon-excalibur/assembly/src/etc/activation.mf
Index: activation.mf
===================================================================
Manifest-Version: 1.0
Created-By: OSM SARL
Extension-List: merlin orb
merlin-Extension-Name: avalon-merlin
merlin-Specification-Version: 2.0
orb-Extension-Name: apache-orb
orb-Specification-Version: 2.4
Name: org/apache/excalibur/merlin/activation/DefaultRemoteResourceFactory.class
Avalon: Type
Name: org/apache/excalibur/merlin/activation/DefaultServiceResolver.class
Avalon: Type
1.3 +7 -1 jakarta-avalon-excalibur/assembly/src/etc/activator/client.xml
Index: client.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/activator/client.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- client.xml 7 Sep 2002 19:05:41 -0000 1.2
+++ client.xml 9 Sep 2002 04:33:52 -0000 1.3
@@ -49,7 +49,13 @@
<!--
Request assembly of the client component. The client is depedent on a
- ORB service which will be resolved automatically.
+ ORB service which will be resolved automatically. During execution the
+ client will access the connection URL which is a reference to a service
+ hosted under a remote container. The remote service will not activated
+ until the test client actually invokes an operation of the remote service.
+ This demonstrates the ability to properate references to services
+ encapsulated in resources and the automatic management of actiovation on
+ demand across distributed containers.
-->
<component name="client"
class="org.apache.excalibur.playground.activation.ActivationClient" activation="true">
1.5 +1 -1 jakarta-avalon-excalibur/assembly/src/etc/activator/server.xml
Index: server.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/activator/server.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- server.xml 8 Sep 2002 16:53:55 -0000 1.4
+++ server.xml 9 Sep 2002 04:33:52 -0000 1.5
@@ -69,7 +69,7 @@
</fileset>
</classpath>
- <component name="servant"
class="org.apache.excalibur.playground.remote.TestServant" activation="true">
+ <component name="servant"
class="org.apache.excalibur.playground.activation.TestServant" activation="true">
<categories priority="DEBUG"/>
</component>
1.2 +1 -1 jakarta-avalon-excalibur/assembly/src/idl/demo.idl
Index: demo.idl
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/idl/demo.idl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- demo.idl 7 Sep 2002 07:27:11 -0000 1.1
+++ demo.idl 9 Sep 2002 04:33:53 -0000 1.2
@@ -8,7 +8,7 @@
module playground
{
- module remote
+ module activation
{
/**
1.16 +6 -2
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java
Index: Main.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Main.java 22 Aug 2002 13:43:01 -0000 1.15
+++ Main.java 9 Sep 2002 04:33:53 -0000 1.16
@@ -140,10 +140,14 @@
controller.initialize();
controller.start();
}
+ catch( ControllerException e )
+ {
+ // its already been logged
+ }
catch( Throwable e )
{
final String error = "Controller deployment failure.";
- System.out.println( error + "\n" + ExceptionUtil.printStackTrace( e ) );
+ ExceptionHelper.printException( error, e, null, true );
controller.dispose();
}
}
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/ExceptionHelper.java
Index: ExceptionHelper.java
===================================================================
/*
* @(#)ExceptionHelper.java
*
* Copyright 2000 OSM SARL. All Rights Reserved.
*
* This software is the proprietary information of OSM SARL.
* Use is subject to license terms.
*
* @author Stephen McConnell
* @version 1.0 24/02/2001
*/
package org.apache.excalibur.merlin;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.StringTokenizer;
/**
* General utilities supporting the packaging of exception messages.
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
*/
public class ExceptionHelper
{
private static final String LINE_SEPARATOR = System.getProperty(
"line.separator" );
/**
* Prints the exception to the standard error out together with
* cause statements.
* @param e the exception to print
*/
public static void printException( Throwable e )
{
printException( null, e );
}
/**
* Prints the exception to the standard error out together with
* cause statements.
* @param label label identifying the error
* @param e the exception to print
*/
public static void printException( String label, Throwable e )
{
printException( label, e, null );
}
/**
* Prints the exception to the standard error out together with
* source and cause statements.
* @param label label identifying the error
* @param e the exception to print
* @param source the source of the request
*/
public static void printException( String label, Throwable e, Object source )
{
printException( label, e, source, false );
}
/**
* Prints the exception to the standard error out together with
* source and cause statements.
* @param label label identifying the error
* @param e the exception to print
* @param source the source of the request
* @param trace boolean value inidication if a stack trace though be included
*/
public static void printException( String label, Throwable e, Object source,
boolean trace )
{
if( e == null )
{
throw new NullPointerException("throwable");
}
java.io.PrintStream out = System.err;
synchronized( out )
{
out.println(
"===================================================================" );
if( label != null )
{
out.println( "Message: " + label );
}
if( source != null )
{
out.println( "Source: " + source );
}
out.println( "Exception: " + e.toString() );
if( getCause( e ) != null )
{
printCause( out, e );
}
out.println(
"===================================================================" );
if( trace )
{
e.printStackTrace();
out.println(
"===================================================================" );
}
}
}
private static void printCause( java.io.PrintStream out, Throwable e )
{
Throwable cause = getCause( e );
out.println( "Cause: " + cause.toString() );
if( cause.getCause() != null )
{
printCause( out, cause );
}
}
/**
* Returns the exception and causal exceptions as a formatted string.
* @param message the header message
* @param e the exception
* @return String the formatting string
*/
public static String packException( final String message, final Throwable e )
{
StringBuffer buffer = new StringBuffer();
buffer.append( "Message: " + message );
buffer.append(
"\n===================================================================" );
if( e == null )
{
return buffer.toString();
}
else
{
buffer.append( "\nException: " + e.toString() );
packCause( buffer, getCause( e ) ).toString();
buffer.append(
"\n===================================================================" );
}
Throwable root = getLastThrowable( e );
if( root != null )
{
String[] trace = captureStackTrace( root );
for( int i=0; i<trace.length; i++ )
{
buffer.append("\n" + trace[i] );
}
}
buffer.append(
"\n===================================================================" );
return buffer.toString();
}
private static StringBuffer packCause( StringBuffer buffer, Throwable cause )
{
if( cause == null )
{
return buffer;
}
buffer.append("\nCause: " + cause.toString() );
return packCause( buffer, getCause( cause ) );
}
public static Throwable getLastThrowable( Throwable exception )
{
Throwable cause = getCause( exception );
if( cause != null )
{
return getLastThrowable( cause );
}
return exception;
}
public static Throwable getCause( Throwable exception )
{
if( exception == null )
{
throw new NullPointerException("exception");
}
try
{
Method method = exception.getClass().getMethod( "getCause", new Class[0]
);
return (Throwable) method.invoke( exception, new Object[0] );
}
catch( Throwable e )
{
return null;
}
}
/**
* Captures the stack trace associated with this exception.
*
* @param throwable a <code>Throwable</code>
* @return an array of Strings describing stack frames.
*/
public static String[] captureStackTrace( final Throwable throwable )
{
final StringWriter sw = new StringWriter();
throwable.printStackTrace( new PrintWriter( sw, true ) );
return splitString( sw.toString(), LINE_SEPARATOR );
}
/**
* Splits the string on every token into an array of stack frames.
*
* @param string the string to split
* @param onToken the token to split on
* @return the resultant array
* @deprecated This is an internal utility method that should not be used
*/
public static String[] splitString( final String string, final String onToken )
{
final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
final String[] result = new String[ tokenizer.countTokens() ];
for( int i = 0; i < result.length; i++ )
{
result[ i ] = tokenizer.nextToken();
}
return result;
}
/**
* Returns a HTML formatted exception report.
* @param message the header message
* @param e the exception
* @return String the HTML formatted string
*/
public static String packExceptionAsHTML( final String message, final Throwable
e )
{
String header = "<html><body><table>";
String footer = "</table></body></html>";
String error = header + "<tr bgcolor='#ccccff'><td
valign=top>Message</td><td>"
+ message + "</td></tr>";
if( e == null )
{
return error + footer;
}
error = error + "<tr><td valign='top'>Exception</td><td>"
+ e.getClass().getName() + " <br>" + e.getMessage() + "</td></tr>";
return packCauseInTable( error, e.getCause() ) + footer;
}
private static String packCauseInTable( String s, Throwable cause )
{
if( cause == null )
{
return s;
}
s = s + "<tr><td valign='top'>Cause:</td><td>"
+ cause.getClass().getName() + " <br>" + cause.getMessage() +
"</td></tr>";
return packCauseInTable( s, cause.getCause() );
}
}
1.5 +46 -8
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultRemoteResource.java
Index: DefaultRemoteResource.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultRemoteResource.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultRemoteResource.java 8 Sep 2002 16:59:36 -0000 1.4
+++ DefaultRemoteResource.java 9 Sep 2002 04:33:53 -0000 1.5
@@ -23,6 +23,9 @@
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.IdAssignmentPolicyValue;
import org.omg.PortableServer.LifespanPolicyValue;
+import org.omg.PortableServer.RequestProcessingPolicyValue;
+import org.omg.PortableServer.ServantRetentionPolicyValue;
+
import org.omg.CORBA.Policy;
/**
@@ -43,12 +46,12 @@
/**
* The path of the profile designator.
*/
- private final ORB m_orb;
+ private final POA m_root;
/**
- * The root POA.
+ * The servant activator.
*/
- private POA m_root;
+ private DefaultServantActivator m_activator;
/**
* The application POA.
@@ -82,11 +85,21 @@
final Profile profile,
final Context context,
final LifestyleHandler handler,
- final ORB orb )
+ final DefaultServantActivator activator,
+ final POA poa )
{
super( manager, profile, context, handler );
m_profile = profile;
- m_orb = orb;
+ if( poa == null )
+ {
+ throw new NullPointerException( "poa" );
+ }
+ if( activator == null )
+ {
+ throw new NullPointerException( "activator" );
+ }
+ m_activator = activator;
+ m_root = poa;
}
//==========================================================================
@@ -122,8 +135,33 @@
private org.omg.CORBA.Object createObjectReference() throws Exception
{
- m_root = (POA) m_orb.resolve_initial_references("RootPOA");
- return null;
+ if( m_reference == null )
+ {
+ final String path = getPath();
+ m_poa = m_root.create_POA(
+ path,
+ m_root.the_POAManager(),
+ new Policy[]
+ {
+ m_root.create_id_assignment_policy(
IdAssignmentPolicyValue.USER_ID ),
+ m_root.create_lifespan_policy( LifespanPolicyValue.PERSISTENT ),
+ m_root.create_request_processing_policy(
+ RequestProcessingPolicyValue.USE_SERVANT_MANAGER ),
+ m_root.create_servant_retention_policy(
+ ServantRetentionPolicyValue.RETAIN )
+ }
+ );
+
+ byte[] id = path.getBytes();
+ m_activator.register( id, this );
+ m_poa.set_servant_manager( m_activator );
+ m_poa.the_POAManager().activate();
+
+ String idl =
getProfile().getType().getInfo().getAttribute("corba:poa.servant.id", null );
+ m_reference = m_poa.create_reference_with_id( id, idl );
+
+ }
+ return m_reference;
}
/**
1.5 +30 -4
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultRemoteResourceFactory.java
Index: DefaultRemoteResourceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultRemoteResourceFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultRemoteResourceFactory.java 8 Sep 2002 16:59:36 -0000 1.4
+++ DefaultRemoteResourceFactory.java 9 Sep 2002 04:33:53 -0000 1.5
@@ -9,7 +9,11 @@
*/
package org.apache.excalibur.merlin.activation;
+import java.util.Map;
+import java.util.Hashtable;
+
import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
@@ -20,15 +24,21 @@
import org.apache.excalibur.merlin.model.Resource;
import org.apache.orb.ORB;
+import org.omg.PortableServer.POA;
/**
* The default resource factory.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
*/
-public class DefaultRemoteResourceFactory extends AbstractLogEnabled implements
RemoteResourceFactory
+public class DefaultRemoteResourceFactory extends AbstractLogEnabled
+ implements Serviceable, Initializable, RemoteResourceFactory
{
- private ORB m_orb;
+ private final Map m_map = new Hashtable();
+
+ private DefaultServantActivator m_activator;
+
+ private POA m_poa;
/**
* Factory servicing invoked by the factory container. The remote
@@ -41,7 +51,23 @@
*/
public void service( ServiceManager manager ) throws ServiceException
{
- m_orb = (ORB) manager.lookup( "orb" );
+ ORB orb = (ORB) manager.lookup( "orb" );
+ try
+ {
+ m_poa = (POA) orb.resolve_initial_references("RootPOA");
+ }
+ catch( Throwable e )
+ {
+ final String error = "Unable to resolve root POA.";
+ throw new ServiceException( "orb", error, e );
+ }
+ }
+
+ public void initialize() throws Exception
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ m_activator = new DefaultServantActivator( loader, m_map );
+ m_activator.enableLogging( getLogger().getChildLogger("activator") );
}
/**
@@ -78,7 +104,7 @@
}
DefaultRemoteResource resource =
- new DefaultRemoteResource( manager, profile, context, handler, m_orb );
+ new DefaultRemoteResource( manager, profile, context, handler,
m_activator, m_poa );
resource.enableLogging( getLogger() );
return resource;
}
1.8 +15 -41
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultServiceResolver.java
Index: DefaultServiceResolver.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultServiceResolver.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultServiceResolver.java 8 Sep 2002 16:59:36 -0000 1.7
+++ DefaultServiceResolver.java 9 Sep 2002 04:33:53 -0000 1.8
@@ -11,6 +11,8 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.activity.Startable;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.orb.ORB;
import org.apache.orb.corbaloc.InvalidQuery;
@@ -53,7 +55,7 @@
*/
public class DefaultServiceResolver extends DefaultContainer
-implements ServiceResolverOperations, Serviceable
+implements ServiceResolverOperations, Serviceable, Startable, Disposable
{
/**
* The service manager from which we aquire the ORB.
@@ -204,8 +206,7 @@
catch( Throwable e )
{
String error = "Unable to create the application POA: " + e.toString();
- getLogger().error( error, e );
- throw new Exception( error );
+ throw new ActivationException( error, e );
}
String path = registry.put_object( m_resolver, key );
@@ -280,38 +281,15 @@
}
//
- // it is a path refering to a container resource (container or service) so
- // we resolve the object using the service manager
+ // It is a path refering to a contained resource (container or service).
+ // Use the registry to locate the resource and if the resource is a
referencable
+ // resource then get and return the refence.
//
- getLogger().info("REMOTE: " + path );
-
-
- /*
- //
- // convert the relative corbaloc path to an absolute path relative to the
- // the registries base path (i.e. transform from the corbaloc namespace to
- // the container namespace)
- //
-
- URI base = m_registry.getBase();
- URI uri = base.resolve( path );
- try
- {
- getLogger().info("base: '" + base + "'");
- getLogger().info("path: '" + path + "'");
- getLogger().info("resolved: " + uri );
- }
- catch( Throwable e )
- {
- getLogger().error( e.toString() );
- }
- */
-
try
{
Resource resource = m_registry.locate( path );
- getLogger().info("## located a resource: " + resource );
+ getLogger().debug("located a resource: " + resource );
//
// we have located a resource matching the resolved uri
@@ -319,27 +297,23 @@
// can be passed back to the client inside an any
//
+ if( resource instanceof RemoteResource )
+ {
+ return ((RemoteResource)resource).getReference();
+ }
}
catch( UnknownServiceException use )
{
- getLogger().error( use.toString() );
throw new UnknownReference( path, use.getMessage() );
}
catch( InvalidPathException ipe )
{
- getLogger().error( ipe.toString() );
throw new InvalidReference( path, ipe.getMessage() );
}
- //
- // temporary fallback - return a reference to ourselves
- //
-
- //Any any = m_orb.create_any();
- //ServiceResolverHelper.insert( any, m_resolver );
- //return any;
-
- return m_resolver;
+ final String error =
+ "Supplied path is a local service.";
+ throw new InvalidReference( path, error );
}
//=======================================================================
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/DefaultServantActivator.java
Index: DefaultServantActivator.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.merlin.activation;
import java.util.Map;
import java.lang.reflect.Constructor;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.Resource;
import org.apache.excalibur.meta.info.ServiceDescriptor;
import org.apache.excalibur.merlin.assembly.ContainerManager;
import org.apache.excalibur.merlin.resource.DefaultResource;
import org.apache.excalibur.merlin.resource.LifestyleHandler;
import org.apache.orb.ORB;
import org.omg.CORBA.LocalObject;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.ServantActivator;
import org.omg.PortableServer.ForwardRequest;
import org.omg.PortableServer.LifespanPolicyValue;
import org.omg.CORBA.Policy;
/**
* The <code>DefaultRemoteResource</code> is a resource implementation the
* provides support for the establishment of a CORBA object reference to
* a POA (PortableObjectAdapter) that is itself based on a component
* implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/09/09 04:33:53 $
*/
public class DefaultServantActivator extends LocalObject implements
ServantActivator, LogEnabled
{
//==========================================================================
// state
//==========================================================================
/**
* Logging channel.
*/
Logger m_logger;
/**
* A map of servant resources keyed by resource path.
*/
private final Map m_map;
/**
* A classloader to use.
*/
private final ClassLoader m_loader;
//==========================================================================
// constructor
//==========================================================================
/**
* Create a new remote resource instance.
*
* @param map a map of servant resource mapped to resource path names
* @param orb the object request broker
*/
public DefaultServantActivator( final ClassLoader loader, final Map map )
{
if( map == null )
{
throw new NullPointerException( "map" );
}
if( loader == null )
{
throw new NullPointerException( "loader" );
}
m_map = map;
m_loader = loader;
}
//==========================================================================
// LogEnabled
//==========================================================================
/**
* Supply a logging channel to the instance.
*/
public void enableLogging( Logger logger )
{
m_logger = logger;
}
/**
* Return the logging channel used by the instance.
* @return the <code>Logger</code>
* @exception IllegalStateException if the logging channel has not been set
*/
protected Logger getLogger( )
{
if ( null == m_logger )
{
throw new IllegalStateException("Logging channel has not been
assigned.");
}
return m_logger;
}
//==========================================================================
// ServantActivator
//==========================================================================
/**
* This operation is invoked by the POA whenever the
* POA receives a request for an object that is not
* currently active, assuming the POA has the
* USE_SERVANT_MANAGER and RETAIN policies.
* @param oid object Id associated with the object on
* the request was made.
* @param adapter object reference for the POA in which
* the object is being activated.
* @return Servant corresponding to oid is created or
* located by the user supplied servant manager.
* @exception ForwardRequest to indicate to the ORB
* that it is responsible for delivering
* the current request and subsequent
* requests to the object denoted in the
* forward_reference member of the exception.
*/
public Servant incarnate( byte[] oid, POA adapter ) throws ForwardRequest
{
//
// get the resource based on the supplied oid, establish it
// and either return it directly of return a tie object based
// on the components attributes
//
final String key = new String( oid );
getLogger().debug("incarnation request: " + key );
RemoteResource resource = (RemoteResource) m_map.get( key );
if( resource == null )
{
final String error = "Unknown oid: " + key;
throw new ActivationRuntimeException( error );
}
Profile profile = resource.getProfile();
String strategy = profile.getType().getInfo().getAttribute(
"corba:poa.implementation", "servant" );
if( strategy.equals("servant") )
{
try
{
return (Servant) resource.access();
}
catch( Throwable e )
{
final String error =
"Unexpected exception while attempt to instantate a servant for
the profile: "
+ profile.getName();
throw new ActivationRuntimeException( error, e );
}
}
if( strategy.equals("delegate") )
{
String classname = profile.getType().getInfo().getAttribute(
"corba:poa.delegate", null );
if( classname == null )
{
final String error =
"Missing 'corba:poa.delegate' attribute value in profile: " +
profile.getName();
throw new ActivationRuntimeException( error );
}
Class clazz;
try
{
clazz = m_loader.loadClass( classname );
}
catch( ClassNotFoundException cnfe )
{
throw new ActivationRuntimeException(
"Could not find delegate class " + classname, cnfe );
}
try
{
Constructor constructor = getConstructor( clazz );
return (Servant)constructor.newInstance( new Object[]{
resource.access(), adapter } );
}
catch( Throwable e )
{
throw new ActivationRuntimeException(
"Unexpected exception while creating delegate from class: "
+ classname, e );
}
}
final String error = "The attribute corba:poa.implementation contains an
unrecognized value: "
+ strategy;
throw new ActivationRuntimeException( error );
}
private Constructor getConstructor( Class clazz )
{
Constructor[] constructors = clazz.getConstructors();
for( int i=0; i<constructors.length; i++ )
{
Constructor c = constructors[i];
if( c.getParameterTypes().length == 2 )
{
return c;
}
}
final String error =
"the standard POA Tie constructor pattern is not implemeted by the
supplied class: "
+ clazz.getName();
throw new ActivationRuntimeException( error );
}
public void register( byte[] oid, RemoteResource resource )
{
final String key = new String( oid );
getLogger().debug("registering resource: " + key );
m_map.put( key, resource );
}
/**
* This operation is invoked whenever a servant for
* an object is deactivated, assuming the POA has
* the USE_SERVANT_MANAGER and RETAIN policies.
* @param oid object Id associated with the object
* being deactivated.
* @param adapter object reference for the POA in which
* the object was active.
* @param serv contains reference to the servant
* associated with the object being deactivated.
* @param cleanup if TRUE indicates that
* destroy or deactivate is called with
* etherealize_objects param of TRUE. FALSE
* indicates that etherealize was called due to
* other reasons.
* @param remaining indicates whether the
* Servant Manager can destroy a servant. If
* set to TRUE, the Servant Manager should wait
* until all invocations in progress have
* completed.
*/
public void etherealize( byte[] oid, POA adapter, Servant servant, boolean
cleanup, boolean remaining )
{
getLogger().debug("etherealize request: " + servant );
}
/*
private Resource getResource( byte[] oid )
{
byte[][] array = m_map.keySet().toArray();
for( int i=0; i<array.length; i++ )
{
byte[] id = array[i];
if( compare( id, oid ) )
{
return m_map
}
}
}
*/
/**
* Compares two byte arrays for equality.
*
* @param primary first array
* @param secondary second array
* @return boolean true if these two byte arrays are
* byte-for-byte equivalent
*/
private static boolean compare( byte[] primary, byte secondary[] )
{
if ( primary.length != secondary.length )
{
return false;
}
for ( int i = 0; i < primary.length; i++ )
{
if ( primary[i] != secondary[i] )
{
return false;
}
}
return true;
}
}
1.32 +326 -11
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java
Index: ContainerManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ContainerManager.java 7 Sep 2002 19:05:41 -0000 1.31
+++ ContainerManager.java 9 Sep 2002 04:33:53 -0000 1.32
@@ -37,6 +37,7 @@
import org.apache.excalibur.merlin.model.CategoriesDescriptor;
import org.apache.excalibur.merlin.model.Profile;
import org.apache.excalibur.merlin.model.Resource;
+import org.apache.excalibur.merlin.model.Association;
import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
import org.apache.excalibur.merlin.model.builder.ContainerBuilder;
import org.apache.excalibur.meta.info.StageDescriptor;
@@ -162,7 +163,7 @@
* Utility class that we use to offload the management of profiles
* and which provides the actual assembly process.
*/
- private ProfileRegistry m_registry;
+ //private ProfileRegistry m_registry;
/**
* Internal reference to the supplied context object. This is the
@@ -307,8 +308,8 @@
// setup the assembly sub-system
//
- m_registry = new ProfileRegistry( this );
- m_registry.enableLogging( getLocalLogger().getChildLogger( "assembly") );
+ //m_registry = new ProfileRegistry( this );
+ //m_registry.enableLogging( getLocalLogger().getChildLogger( "assembly") );
//
// build the packaged and implicit profiles
@@ -804,7 +805,7 @@
{
if( isLocal( profile ) )
{
- return createResource( profile, context );
+ return getLocalResource( profile, context );
}
else
{
@@ -855,7 +856,7 @@
* @param context the deployment context
* @return a new resource
*/
- private Resource createResource( Profile profile, Context context )
+ private Resource getLocalResource( Profile profile, Context context )
throws ResourceException
{
Resource resource = getLocalResource( profile );
@@ -918,14 +919,15 @@
if( factoryProfile == null )
{
final String error = "The profile: '" + profile.getName()
- + "' contains a reference to an unknown custom resource factory
component."
+ + "' contains a reference to an unknown resource factory
component."
+ " Factory service interface: " + classname + " is not
recognized.";
throw new ResourceException( error );
}
-
+
try
{
- Resource factoryResource = getResource( factoryProfile, context );
+ Resource factoryResource = assemble( factoryProfile, context );
+ Association[] associations = factoryProfile.getAssociations();
ResourceFactory factory = (ResourceFactory)
factoryResource.access();
Resource res = factory.createResource( this, profile, c, handler );
m_resources.put( profile, res );
@@ -975,7 +977,7 @@
*/
public Resource assemble( Profile profile, Context context ) throws
AssemblyException
{
- Resource resource = m_registry.assembleProfile( m_system, profile, context
);
+ Resource resource = assembleProfile( m_system, profile, context );
logDependency(
getLocalLogger(),
"system: (" + profile.getName() + "): ",
@@ -1033,7 +1035,7 @@
return m_map;
}
- m_registry.assemble( m_map, profiles, context );
+ assemble( m_map, profiles, context );
logDependency( getLocalLogger(), "install: ", m_map.getStartupGraph() );
return m_map;
}
@@ -1140,6 +1142,319 @@
//=============================================================================
// private
//=============================================================================
+
+
+ /**
+ * Initiate dependency correlation for the supplied profile.
+ *
+ * @param map the dependency graph containing candidates and into which
+ * asembled profiles will be added
+ * @param profile the profile to assemble
+ * @param context supplimentary context
+ * @return the assembled resource
+ * @exception AssemblyException if an error occurs during assembly
+ */
+ private Resource assembleProfile(
+ DependencyGraph map, Profile profile, Context context )
+ throws AssemblyException
+ {
+ return assembleProfile( map, profile, context, new ArrayList() );
+ }
+
+ /**
+ * Initiate dependency correlation for the supplied profile.
+ *
+ * @param map the dependency graph containing candidates and into
+ * which asembled profiles will be added
+ * @param profile the profile to assemble
+ * @param context supplimentary context
+ * @param visited list of visited profiles
+ * @return the assembled resource
+ * @exception AssemblyException if an error occurs during assembly
+ */
+ private Resource assembleProfile(
+ DependencyGraph map, Profile profile, Context context, List visited )
+ throws AssemblyException
+ {
+ getLogger().debug("assembly target: " + profile );
+ assembleProfile( map, profile, context, visited, "" );
+ map.add( profile );
+ try
+ {
+ return getResource( profile, context );
+ }
+ catch( ResourceException e )
+ {
+ final String error =
+ "Unable to assemble profile '" + profile.getName() + "'.";
+ throw new AssemblyException( error, e );
+ }
+ }
+
+
+ /**
+ * For all of the explicity declared profiles, initiate dependency correlation.
+ * The implementation will attempt to assembly each profile in the order
+ * supplied.
+ *
+ * @param map the dependency graph containing candidates and into which asemble
+ * profiles will be added
+ * @param profiles the set of profiles to assemble
+ * @param context supplimentary context
+ * @exception AssemblyException if an error occurs during assembly
+ */
+ private void assemble( DependencyGraph map, Profile[] profiles, Context context
)
+ throws AssemblyException
+ {
+ for( int i=0; i<profiles.length; i++ )
+ {
+ Profile profile = profiles[i];
+ getLogger().debug("assembly target: " + profile );
+ ArrayList visited = new ArrayList();
+ assembleProfile( map, profile, context, visited, "" );
+ map.add( profile );
+
+ try
+ {
+ getResource( profile, context );
+ }
+ catch( ResourceException e )
+ {
+ final String error =
+ "Unable to assemble profile '" + profile.getName() + "'.";
+ throw new AssemblyException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Assemble a single profile.
+ * @param map the current depedency map to populate
+ * @param profile the profile to assemble
+ * @param context the assembly context
+ * @param visited the set of profiles already assessed
+ * @param pad used in formatting log messages
+ * @exception AssemblyException if an assembly related error occurs
+ */
+ private void assembleProfile(
+ DependencyGraph map, Profile profile, Context context, List visited, String
pad )
+ throws AssemblyException
+ {
+ getLogger().debug( pad + "assemble: " + profile );
+ String pad2 = pad + " ";
+
+ //
+ // for all of the declared depedencies - make sure the
+ // dependency is satisfied
+ //
+
+ visited.add( profile );
+ DependencyDescriptor[] dependencies = profile.getType().getDependencies();
+ for( int i=0; i<dependencies.length; i++ )
+ {
+ DependencyDescriptor dependency = dependencies[i];
+ String role = dependency.getRole();
+ if( profile.getAssociation( role ) == null )
+ {
+
+ //
+ // there is an unresolve association for one of the depedencies
+ // of the supplied profile - invoking assembleSolutions causes
+ // the resolution of associations between potential suppliers
+ // of the depedency - if assembleSolutions returns true, we
+ // have at least one solution
+ //
+
+ boolean ok =
+ assembleProviders( map, profile, context, dependency, visited,
pad2 );
+ if( !ok )
+ {
+ final String message =
+ "No solution for the dependency: "
+ + dependency.getService() + " in profile: " + profile
+ + ", for the role: " + dependency.getRole();
+
+ profile.setEnabled( false );
+ final Exception problem = new Exception( message );
+ throw new UnresolvedProviderException( dependency, problem );
+ }
+
+ //
+ // select the preferred provider for the dependency - the dependency
+ // argument contains the selection policy to apply
+ //
+
+ Profile supplier = getProfile( dependency );
+ if( supplier == null )
+ {
+ final String message =
+ "Empty selection for the dependency: "
+ + dependency.getService() + " in profile: " + profile
+ + ", for the role: " + dependency.getRole();
+
+ profile.setEnabled( false );
+ final Exception problem =
+ new Exception( "No suitable candidates." );
+ throw new UnresolvedProviderException( dependency, problem );
+ }
+
+ //
+ // associate the supplier to the profile via an association
+ //
+
+ getLogger().debug( pad + " selection: " + supplier );
+ Resource resource;
+ try
+ {
+ resource = getResource( supplier, context );
+ }
+ catch( ResourceException e )
+ {
+ final String error =
+ "Unable to assemble supplier profile '"
+ + supplier.getName()
+ + "' for the profile '" + profile.getName() + "'.";
+ throw new AssemblyException( error, e );
+ }
+
+ profile.addProvider( role, resource );
+ getLogger().debug( pad + " associated supplier: " +
supplier.getName() +
+ " with profile: " + profile.getName() + " under the role: " +
role );
+ map.add( supplier );
+ }
+ }
+
+ //
+ // for all of the lifecycle phases - make sure we assign an extension
+ // manager
+ //
+
+ StageDescriptor[] phases = profile.getType().getPhases();
+ for( int i=0; i<phases.length; i++ )
+ {
+ StageDescriptor stage = phases[i];
+ if( profile.getExtension( stage ) == null )
+ {
+ boolean ok =
+ assembleManagers( map, profile, context, stage, visited, pad2 );
+ if( !ok )
+ {
+ final String message =
+ "Could not locate an extension for the stage: "
+ + stage.getReference() + ", in profile: " + profile;
+
+ profile.setEnabled( false );
+ final AssemblyException problem = new AssemblyException(
message );
+ throw new UnresolvedManagerException( stage, problem );
+ }
+
+ //
+ // select the preferred provider for the stage - the stage
+ // argument contains the selection policy to apply
+ //
+
+ Profile supplier = getProfile( stage );
+ if( supplier == null )
+ {
+ final String message =
+ "Empty selection for a stage extension supporting: "
+ + stage.getReference() + " in profile: " + profile;
+
+ profile.setEnabled( false );
+ final AssemblyException problem =
+ new AssemblyException( message );
+ throw new UnresolvedManagerException( stage, problem );
+ }
+
+ //
+ // associate the supplier to the profile via an association
+ //
+
+ getLogger().debug( pad + " selection: " + supplier );
+ Resource resource;
+ try
+ {
+ resource = getResource( supplier, context );
+ }
+ catch( ResourceException e )
+ {
+ final String error =
+ "Unable to assemble extension profile '"
+ + supplier.getName()
+ + "' for the profile '" + profile.getName() + "'.";
+ throw new AssemblyException( error, e );
+ }
+ profile.addExtension( stage, resource );
+ map.add( supplier );
+ }
+ }
+ }
+
+ private boolean assembleManagers(
+ DependencyGraph map, Profile source, Context context, StageDescriptor stage,
+ List visited, String pad )
+ throws AssemblyException
+ {
+ boolean ok = false;
+ Profile[] profiles = getProfiles( stage );
+ getLogger().debug(
+ pad
+ + "stage: " + stage.getReference()
+ + ", [" + profiles.length + "]"
+ );
+
+ for( int i=0; i<profiles.length; i++ )
+ {
+ Profile profile = profiles[i];
+ if( !profile.equals( source ) )
+ {
+ try
+ {
+ assembleProfile( map, profile, context, visited, pad + " " );
+ ok = true;
+ getLogger().debug( pad + " extension: " + profile );
+ }
+ catch( Throwable e )
+ {
+ // solution is not resolvable
+ getLogger().debug(
+ pad
+ + " ignoring: " + profile + ", cause: " + e.toString()
+ );
+ }
+ }
+ }
+ return ok;
+ }
+
+ private boolean assembleProviders(
+ DependencyGraph map, Profile source, Context context,
+ DependencyDescriptor dependency, List visited, String pad )
+ throws AssemblyException
+ {
+ boolean ok = false;
+ getLogger().debug( pad + "resolving dependency: " + dependency.getRole() );
+ Profile[] profiles = getProfiles( dependency.getService() );
+ for( int i=0; i<profiles.length; i++ )
+ {
+ Profile profile = profiles[i];
+ if( !profile.equals( source ) )
+ {
+
+ try
+ {
+ assembleProfile( map, profile, context, visited, pad + " " );
+ ok = true;
+ getLogger().debug( pad + " candidate: " + profile );
+ }
+ catch( Throwable e )
+ {
+ // solution is not resolvable
+ }
+ }
+ }
+ return ok;
+ }
private Resource getLocalResource( Profile profile )
{
1.17 +5 -5
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java
Index: ProfileRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ProfileRegistry.java 23 Aug 2002 06:25:13 -0000 1.16
+++ ProfileRegistry.java 9 Sep 2002 04:33:53 -0000 1.17
@@ -213,7 +213,7 @@
"No solution for the dependency: "
+ dependency.getService() + " in profile: " + profile
+ ", for the role: " + dependency.getRole();
- getLogger().error( pad + " " + message );
+ //getLogger().error( pad + " " + message );
profile.setEnabled( false );
final Exception problem = new Exception( message );
@@ -232,7 +232,7 @@
"Empty selection for the dependency: "
+ dependency.getService() + " in profile: " + profile
+ ", for the role: " + dependency.getRole();
- getLogger().error( pad + " " + message );
+ //getLogger().error( pad + " " + message );
profile.setEnabled( false );
final Exception problem =
@@ -282,7 +282,7 @@
final String message =
"Could not locate an extension for the stage: "
+ stage.getReference() + ", in profile: " + profile;
- getLogger().error( pad + " " + message );
+ //getLogger().error( pad + " " + message );
profile.setEnabled( false );
final AssemblyException problem = new AssemblyException(
message );
@@ -300,7 +300,7 @@
final String message =
"Empty selection for a stage extension supporting: "
+ stage.getReference() + " in profile: " + profile;
- getLogger().error( pad + " " + message );
+ //getLogger().error( pad + " " + message );
profile.setEnabled( false );
final AssemblyException problem =
1.19 +8 -6
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java
Index: TypeManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TypeManager.java 7 Sep 2002 19:05:41 -0000 1.18
+++ TypeManager.java 9 Sep 2002 04:33:53 -0000 1.19
@@ -478,15 +478,17 @@
else
{
Enumeration keys = errors.keys();
- getLocalLogger().error( "Load error count = " + errors.size() );
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "Load failure. Count: " + errors.size() );
while( keys.hasMoreElements() )
{
File key = (File)keys.nextElement();
- getLocalLogger().error(
- "Error while loading file."
- + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) );
+ buffer.append(
+ "\n Error while loading file: "
+ + key.toString() + ", "
+ + (Throwable)errors.get( key ) );
}
- throw new RuntimeException( "Unable to load file stack - see trace for
details." );
+ throw new RuntimeException( buffer.toString() );
}
}
1.39 +5 -3
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java
Index: DefaultContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- DefaultContainer.java 7 Sep 2002 07:27:11 -0000 1.38
+++ DefaultContainer.java 9 Sep 2002 04:33:53 -0000 1.39
@@ -28,6 +28,7 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.ContextException;
+import org.apache.excalibur.merlin.ExceptionHelper;
import org.apache.excalibur.merlin.assembly.AssemblyException;
import org.apache.excalibur.merlin.assembly.ContainerManager;
import org.apache.excalibur.merlin.assembly.DependencyGraph;
@@ -702,8 +703,9 @@
{
if( error != null )
{
- final String message = "Container disposal triggered by abnormal
condition.";
- getLogger().error( message, error );
+ final String message = "Container disposal triggered by unexpected
condition.";
+ final String info = ExceptionHelper.packException( message, error );
+ getLogger().error( info );
}
if( m_state == StateEvent.STARTED )
1.50 +18 -9
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java
Index: DefaultKernel.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- DefaultKernel.java 8 Sep 2002 14:36:56 -0000 1.49
+++ DefaultKernel.java 9 Sep 2002 04:33:53 -0000 1.50
@@ -30,6 +30,7 @@
import org.apache.avalon.framework.context.ContextException;
import org.apache.excalibur.event.command.TPCThreadManager;
import org.apache.excalibur.event.command.CommandManager;
+import org.apache.excalibur.merlin.ExceptionHelper;
import org.apache.excalibur.merlin.assembly.ContainerManager;
import org.apache.excalibur.merlin.assembly.KernelManager;
import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
@@ -441,8 +442,9 @@
}
catch( Throwable e )
{
- final String error = "kernel establishment failure";
- throw new KernelException( error, e );
+ final String error = "kernel initialization failure";
+ getLogger().error( ExceptionHelper.packException( error, e ) );
+ throw new KernelException( error );
}
}
@@ -509,9 +511,9 @@
}
catch( Throwable e )
{
- final String error = "Kernel startup failure.";
- getLogger().error( error, e );
- throw new KernelException( error, e );
+ final String error = "kernel startup failure";
+ getLogger().error( ExceptionHelper.packException( error, e ) );
+ throw new KernelException( error );
}
}
@@ -549,8 +551,8 @@
}
catch( Throwable e )
{
- final String error = "Unepected error while stopping root
container.";
- getLogger().warn( error, e );
+ final String error = "kernel shutdown error";
+ getLogger().error( ExceptionHelper.packException( error, e ) );
}
}
}
@@ -567,7 +569,14 @@
{
if(( m_container != null ) && ( m_container instanceof Disposable ))
{
- ((Disposable)m_container).dispose();
+ try
+ {
+ ((Disposable)m_container).dispose();
+ }
+ catch( Throwable e )
+ {
+ // ignore it
+ }
}
try
{
1.4 +11 -13
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultManager.java
Index: DefaultManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultManager.java 23 Aug 2002 06:25:13 -0000 1.3
+++ DefaultManager.java 9 Sep 2002 04:33:53 -0000 1.4
@@ -63,20 +63,18 @@
throw new ResourceException(
"Could not locate a provider for the role: " + role );
}
- else
+
+ try
{
- try
- {
- Object object = resource.access();
- m_mapping.put( object, resource );
- return object;
- }
- catch( Throwable e )
- {
- final String error = "Unexpected exception while resolving the
service from "
- + resource.getPath() + " for the role: " + role;
- throw new ResourceException( error, e );
- }
+ Object object = resource.access();
+ m_mapping.put( object, resource );
+ return object;
+ }
+ catch( Throwable e )
+ {
+ final String error = "Unexpected exception while resolving the service
from "
+ + resource.getPath() + " for the role: " + role;
+ throw new ResourceException( error, e );
}
}
1.7 +24 -10
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DeploymentHelper.java
Index: DeploymentHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DeploymentHelper.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeploymentHelper.java 7 Sep 2002 07:27:11 -0000 1.6
+++ DeploymentHelper.java 9 Sep 2002 04:33:53 -0000 1.7
@@ -546,6 +546,10 @@
public ComponentManager createComponentManager( Profile profile )
throws Exception
{
+ if( profile == null )
+ {
+ throw new NullPointerException("profile");
+ }
final Map services = getServices( profile );
final DefaultComponentManager componentManager = new
DefaultComponentManager( services );
return componentManager;
@@ -561,6 +565,10 @@
public ServiceManager createServiceManager( Profile profile )
throws Exception
{
+ if( profile == null )
+ {
+ throw new NullPointerException("profile");
+ }
final Map services = getServices( profile );
final DefaultServiceManager serviceManager = new DefaultServiceManager(
services );
return serviceManager;
@@ -614,29 +622,35 @@
*/
private Map getServices( Profile profile ) throws Exception
{
+ if( profile == null )
+ {
+ throw new NullPointerException("profile");
+ }
getLogger().debug("preparing services for profile: " + profile );
final Type type = profile.getType();
+ if( type == null )
+ {
+ throw new NullPointerException("type");
+ }
+
final DependencyDescriptor[] dependencies = type.getDependencies();
final HashMap services = new HashMap();
for( int i = 0; i < dependencies.length; i++ )
{
DependencyDescriptor dependency = dependencies[i];
final String role = dependency.getRole();
- try
+ final Association association = profile.getAssociation( role );
+ if( association == null )
{
- final Association association = profile.getAssociation( role );
- Object resource = association.getProvider();
- services.put( role, resource );
+ final String error = "Missing association for the role: " + role
+ + " in the profile: " + profile.getName();
+ throw new ResourceException( error );
}
- catch( Throwable e )
+ else
{
- final String error =
- "Unexpected exception while attempting to locate a service to fulfill a
dependency for "
- + "the role: " + role + " in profile: " + profile.getName() + ".";
- throw new ResourceException( error, e );
+ services.put( role, association.getProvider() );
}
}
return services;
}
-
}
1.10 +1 -2
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/LifecycleHelper.java
Index: LifecycleHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/LifecycleHelper.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- LifecycleHelper.java 23 Aug 2002 06:57:48 -0000 1.9
+++ LifecycleHelper.java 9 Sep 2002 04:33:53 -0000 1.10
@@ -369,8 +369,7 @@
final String message =
REZ.getString( "lifecycle.fail.error",
name,
- new Integer( stage ), reason );
- getLogger().error( message );
+ new Integer( stage ));
throw new LifecycleException( message, t );
}
1.2 +2 -2
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/Resources.properties
Index: Resources.properties
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/Resources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Resources.properties 12 Aug 2002 08:11:09 -0000 1.1
+++ Resources.properties 9 Sep 2002 04:33:53 -0000 1.2
@@ -1,2 +1,2 @@
-lifecycle.stage.notice=Component named "{0}" is passing through the
{1,choice,0#Creation|1#Logger
initialization|2#Contextualization|3#Composing|4#Configuration|5#Parameterizing|6#Extension-CREATE|7#Initialization|8#Starting|9#Stopping|10#Extension-DESTROY|11#Disposing|12#Destruction}
stage.
-lifecycle.fail.error=Component named "{0}" failed to pass through the
{1,choice,0#Creation|1#Logger
initialization|2#Contextualization|3#Composing|4#Configuration|5#Parameterizing|6#Extension-CREATE|7#Initialization|8#Starting|9#Stopping|10#Extension-DESTROY|11#Disposing|12#Destruction}
stage. (Reason: {2}).
+lifecycle.stage.notice=Component named "{0}" is passing through the
{1,choice,0#creation|1#logger
initialization|2#contextualization|3#composition|4#configuration|5#parameterization|6#extension/create|7#initialization|8#startup|9#shutdown|10#extension/destroy|11#disposal|12#destruction}
stage.
+lifecycle.fail.error=Component named "{0}" failed to pass through the
{1,choice,0#creation|1#logger
initialization|2#contextualization|3#composition|4#configuration|5#parameterization|6#extension/create|7#initialization|8#startup|9#shutdown|10#extension/destroy|11#disposal|12#destruction}
stage.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>