mcconnell 02/05/06 18:43:37
Modified: enterprise/tools build.xml
enterprise/tools/lib merlin.jar
enterprise/tools/src/etc loader.mf
enterprise/tools/src/java/org/apache/avalon/excalibur/context
ContextUtility.java
enterprise/tools/src/java/org/apache/avalon/excalibur/service
ServiceFactory.java ServiceLoader.java
ServiceRegistry.java UnitInfo.java
Added: enterprise/tools build.properties demo.bat
Log:
no message
Revision Changes Path
1.10 +30 -35 jakarta-avalon-apps/enterprise/tools/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-apps/enterprise/tools/build.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- build.xml 14 Mar 2002 10:32:03 -0000 1.9
+++ build.xml 7 May 2002 01:43:36 -0000 1.10
@@ -1,9 +1,4 @@
-<!--
-PSS Service.
-Copyright 2001-2002 OSM SARL, All Rights Reserved.
--->
-
<project name="tools" default="help" basedir=".">
<property file="local.properties"/>
@@ -15,7 +10,7 @@
Description
-----------
- Enterprise suite tools.
+ ${project.title}
General Targets:
----------------
@@ -25,14 +20,11 @@
dist - executes build, javadoc and support file creation
clean - destroy the build directory
install - upgrade merlin.jar in lib
- export - export jar files to ANT_HOME/lib
+ export - export jar files to ${ant.home}/lib
</echo>
</target>
- <property name="MAJOR" value="1"/>
- <property name="MINOR" value="0"/>
- <property name="MICRO" value="1"/>
<property name="VERSION" value="${MAJOR}.${MINOR}.${MICRO}"/>
<property name="enterprise" value=".." />
@@ -40,7 +32,6 @@
<property name="tools.lib.path" value="${tools.path}/lib" />
<property name="excalibur.path" value="../jakarta-avalon-excalibur" />
-
<property name="merlin.jar" value="merlin.jar"/>
<property name="lib" value="lib" />
@@ -144,6 +135,9 @@
<fileset dir="${etc}">
<include name="merlin.properties"/>
</fileset>
+ <fileset dir="${src}/java">
+ <include name="*.xinfo"/>
+ </fileset>
</copy>
<jar jarfile="${dist}/${merlin.jar}" basedir="${build}/lib"
manifest="${etc}/loader.mf" />
</target>
@@ -189,11 +183,11 @@
</fileset>
</copy>
<javadoc destdir="${javadoc.root.path}/${ant.project.name}"
- doctitle="<h1>Merlin Service Management</h1>"
+ doctitle="<h1>${project.title} ${VERSION}</h1>"
noindex="false" author="false"
use="true"
overview="${overview.html}"
- windowtitle="Enterprise Tools"
+ windowtitle="${project.title}"
bottom="<a href='[EMAIL PROTECTED]/LICENSE.HTML'/>License,
Disclaimer and due credits.</a>"
additionalparam="-breakiterator -J-Xmx128m"
packagenames="org.*"
@@ -209,28 +203,6 @@
</javadoc>
</target>
- <target name="loader.context">
- <available property="merlin.available"
file="${ant.home}/lib/${merlin.jar}"/>
- </target>
-
- <target name="loader.defintion" depends="loader.context"
if="merlin.available">
- <taskdef resource="merlin.properties"/>
- </target>
-
- <target name="loader.validation" depends="loader.defintion"
unless="merlin.available">
- <echo>
-
- Merlin is not installed in your Ant library.
- In order to use the "load" task the following jar files
- must be added to your ${ant.home}/lib directory:
-
- - merlin.jar
- - avalon-framework.jar
- - logkit.jar
- - xerces.jar (pre JRE 1.4 only)
- </echo>
- </target>
-
<target name="demo" depends="loader.validation,examples"
if="merlin.available">
<load target="org.apache.demo.ReferralBlock" priority="${demo.priority}"
@@ -269,5 +241,28 @@
</fileset>
</copy>
</target>
+
+ <target name="loader.context">
+ <available property="merlin.available"
file="${ant.home}/lib/${merlin.jar}"/>
+ </target>
+
+ <target name="loader.defintion" depends="loader.context"
if="merlin.available">
+ <taskdef resource="merlin.properties"/>
+ </target>
+
+ <target name="loader.validation" depends="loader.defintion"
unless="merlin.available">
+ <echo>
+
+ Merlin is not installed in your Ant library.
+ In order to use the "load" task the following jar files
+ must be added to your ${ant.home}/lib directory:
+
+ - merlin.jar
+ - avalon-framework.jar
+ - logkit.jar
+ - xerces.jar (pre JRE 1.4 only)
+ </echo>
+ </target>
+
</project>
1.1 jakarta-avalon-apps/enterprise/tools/build.properties
Index: build.properties
===================================================================
#
# The pss.properties file is read in by the build.xml file.
#
project.title=Merlin Service Management
MAJOR=1
MINOR=0
MICRO=2
1.1 jakarta-avalon-apps/enterprise/tools/demo.bat
Index: demo.bat
===================================================================
java -jar lib\merlin.jar dist\examples.jar -target
org.apache.demo.ReferralBlock -verbose true -priority DEBUG
1.13 +119 -113 jakarta-avalon-apps/enterprise/tools/lib/merlin.jar
<<Binary file>>
1.3 +2 -2 jakarta-avalon-apps/enterprise/tools/src/etc/loader.mf
Index: loader.mf
===================================================================
RCS file: /home/cvs/jakarta-avalon-apps/enterprise/tools/src/etc/loader.mf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- loader.mf 14 Mar 2002 10:32:03 -0000 1.2
+++ loader.mf 7 May 2002 01:43:37 -0000 1.3
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Main-Class: org.apache.avalon.excalibur.service.ServiceLoader
-Class-Path: avalon-framework.jar logkit-1.0.jar
+Class-Path: avalon-framework.jar logkit.jar
-Name: org/apache/excalibur/service/ServiceLoader.class
+Name: org/apache/avalon/excalibur/service/ServiceLoader.class
Avalon-Block: true
1.2 +1 -1
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/context/ContextUtility.java
Index: ContextUtility.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/context/ContextUtility.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContextUtility.java 12 Mar 2002 22:19:10 -0000 1.1
+++ ContextUtility.java 7 May 2002 01:43:37 -0000 1.2
@@ -80,7 +80,7 @@
}
catch( Throwable e )
{
- throw new ConfigurationException("Unexpected exception while
creating custom context form "
+ throw new ConfigurationException("Unexpected exception while
creating custom context for "
+ contextClassName, e );
}
1.8 +46 -38
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceFactory.java
Index: ServiceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ServiceFactory.java 12 Mar 2002 22:17:04 -0000 1.7
+++ ServiceFactory.java 7 May 2002 01:43:37 -0000 1.8
@@ -52,7 +52,7 @@
* The <code>ServiceFactory</code> class provides support for the
* instantiation of objects based on supplied service meta-info.
*/
-class ServiceFactory extends AbstractLogEnabled implements Configurable,
Disposable
+class ServiceFactory extends AbstractLogEnabled implements Configurable,
Initializable, Disposable
{
private File m_root;
private boolean m_verbose;
@@ -79,6 +79,10 @@
m_config = config;
}
+ //=======================================================================
+ // Initializable
+ //=======================================================================
+
/**
* Initialize the factory.
*/
@@ -93,6 +97,10 @@
m_registry.initialize();
}
+ //=======================================================================
+ // ServiceFactory
+ //=======================================================================
+
/**
* Populates the set of available services based on a supplied
* vector of jar files. The implementation delegates registration
@@ -117,8 +125,9 @@
{
DependencyInfo d = dependencies[i];
if( m_registry.lookup( d ) == null ) throw new Exception(
- "Could not resolve dependent service " + d.getRole()
- + " for block " + info.getName() );
+ "Could not resolve dependent service '" + d.getRole()
+ + "' with service: '" +
d.getService().getInterface().getName()
+ + "' for block '" + info.getName() + "'" );
}
}
@@ -170,8 +179,7 @@
}
/**
- * Create a provider implementation for a class identified by a
- * supplied met-info instance and a configuration.
+ * Create a provider implementation.
* @param info the dependecy declaration
* @param profile the configuration profile
*/
@@ -267,21 +275,7 @@
public Object pipeline( UnitInfo info, String role ) throws Exception
{
- Logger logger = getLogger();
-
- try
- {
- return execute( null, info, role, m_base_logger );
- }
- catch( Exception e )
- {
- enableLogging( logger );
- throw e;
- }
- finally
- {
- enableLogging( logger );
- }
+ return execute( null, info, role, m_base_logger );
}
private Object execute( UnitInfo container, UnitInfo info, String role,
Logger logger ) throws Exception
@@ -290,7 +284,7 @@
if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(
"pipelining " + role + " (" + info.getClassName() + ")");
- enableLogging( getLogger().getChildLogger( role ) );
+ //enableLogging( getLogger().getChildLogger( role ) );
Configuration config = null;
if( container != null )
@@ -330,8 +324,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to assign a logger channel.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
@@ -349,8 +344,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to configure an object.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
else if( m_object instanceof Parameterizable ) try
@@ -361,8 +357,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to parameterize an object.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
@@ -378,8 +375,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to contextualize the object.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
@@ -395,8 +393,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to service the object.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
else if( m_object instanceof Composable ) try
@@ -407,8 +406,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to compose the object.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
@@ -423,8 +423,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to initilize the object.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
@@ -439,8 +440,9 @@
}
catch( Throwable e )
{
- handleDisposal( m_object );
final String error = "Failed to start the service.";
+ getLogger().error( error, e );
+ handleDisposal( m_object );
throw new PipelineException( error, e );
}
@@ -472,18 +474,20 @@
// dispose of all of the service pools
//
- if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
- "pool disposal (" + m_pools.size() + ")");
Enumeration pools = m_pools.elements();
while( pools.hasMoreElements() )
{
- Object pool = pools.nextElement();
+ ServiceProvider pool = (ServiceProvider) pools.nextElement();
if( pool instanceof Disposable )
{
try
{
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "pool entry disposal (" + pool.getRole() + ")");
((Disposable)pool).dispose();
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "pool entry disposal (" + pool.getRole() + ")
complete");
}
catch( Throwable e )
{
@@ -497,17 +501,19 @@
// dispose of all of the service singletons
//
- if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
- "singleton disposal (" + m_singletons.size() + ")");
Enumeration singletons = m_singletons.elements();
while( singletons.hasMoreElements() )
{
- Object singleton = singletons.nextElement();
+ ServiceProvider singleton = (ServiceProvider)
singletons.nextElement();
if( singleton instanceof Disposable )
{
try
{
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "singleton entry disposal (" + singleton.getRole() +
")");
((Disposable)singleton).dispose();
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "singleton entry disposal complete");
}
catch( Throwable e )
{
@@ -521,17 +527,19 @@
// dispose of all of the transient service providers
//
- if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
- "transient disposal (" + m_transients.size() + ")");
Enumeration transients = m_transients.elements();
while( transients.hasMoreElements() )
{
- Object object = transients.nextElement();
+ ServiceProvider object = (ServiceProvider)
transients.nextElement();
if( object instanceof Disposable )
{
try
{
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "transient entry disposal (" + object.getRole() +
")");
((Disposable)object).dispose();
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "transient entry disposal complete");
}
catch( Throwable e )
{
1.8 +161 -83
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceLoader.java
Index: ServiceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceLoader.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ServiceLoader.java 12 Mar 2002 22:17:04 -0000 1.7
+++ ServiceLoader.java 7 May 2002 01:43:37 -0000 1.8
@@ -24,6 +24,7 @@
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
import org.apache.log.output.io.StreamTarget;
+import org.apache.log.format.ExtendedPatternFormatter;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.CascadingException;
@@ -48,6 +49,7 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.DefaultServiceManager;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.activity.Disposable;
@@ -151,8 +153,7 @@
* </td></tr>
* </table>
*/
-public class ServiceLoader extends AbstractLogEnabled
- implements Configurable, Contextualizable, Initializable, Disposable
+public class ServiceLoader extends AbstractLogEnabled implements
PipelineService
{
private static final String DEFAULT_FORMAT = "[%7.7{priority}]
(%{category}): %{message}\\n%{throwable}";
private static OutputStream m_out = System.out;
@@ -172,6 +173,8 @@
private ServiceFactory m_factory;
private Configuration m_config;
+ private ServiceManager m_manager;
+
/**
* Command line entry point supporting establishment and initalization of
a service
@@ -187,7 +190,7 @@
* </ul>
* <p>An example command line is shown below:</p>
* <pre>
- * $ java -jar <strong>merlin.jar</strong> <supporting-jar-files>
+ * $ java -jar <strong>merlin.jar</strong>
<space-sep-list-of-supporting-jar-files>
* -target <class-name>
* </pre>
* <p><strong>java -classpath form</strong></p>
@@ -198,7 +201,7 @@
* <pre>
* $ java -classpath merlin.jar;avalon-framework.jar;logkit.jar
* <strong>org.apache.avalon.excalibur.service.ServiceLoader</strong>
- * <supporting-jar-files> -target <class-name>
+ * <space-sep-list-of-supporting-jar-files> -target
<class-name>
* </pre>
* </ul>
*
@@ -258,6 +261,20 @@
CLI cli = new CLI( args );
Hierarchy hierarchy = createBootstrapLogger(
cli.getLoggingPriority() );
logger = new LogKitLogger( hierarchy.getLoggerFor( "" ) );
+ Logger merlin = logger.getChildLogger("merlin");
+
+ merlin.info("starting");
+
+ String target = cli.getTarget();
+ if( target == null )
+ {
+ merlin.warn(
+ "missing parameter: " +
+ "-target <required-target-classname>" );
+ merlin.warn("cannot proceed");
+ return;
+ }
+
File path = cli.getConfigurationPath();
Configuration config = null;
@@ -272,10 +289,13 @@
pipeline.configure( config );
pipeline.contextualize( cli.getContext() );
pipeline.initialize();
+
+ pipeline.pipeline( cli.getTarget(), cli.getDisposalPolicy() );
+
}
catch( IllegalParameterException ipe )
{
- logger.error( ipe.getMessage() );
+ System.err.println( ipe.getMessage() );
}
catch( PipelineException e )
{
@@ -299,17 +319,22 @@
return m_verbose;
}
+ //=======================================================================
+ // Configurable
+ //=======================================================================
+
/**
* Configuration of the pipeline.
*/
public void configure( Configuration config ) throws
ConfigurationException
{
- //getLogger().debug(
- // "pipeline configuration\n"
- // + CascadingConfiguration.list( config ));
m_config = config;
}
+ //=======================================================================
+ // Contextualizable
+ //=======================================================================
+
/**
* Contextualization of the pipeline including the supply of command-line
* arguments, include files, target class, and related execution policies.
@@ -321,7 +346,7 @@
*/
public void contextualize( Context context ) throws ContextException
{
- try
+ if( context instanceof ServiceLoaderContext ) try
{
ServiceLoaderContext c = (ServiceLoaderContext) context;
m_includes = c.getIncludes();
@@ -331,18 +356,54 @@
}
catch( Throwable e )
{
- final String error = "Unexpected error while reslving pipeline
context.";
+ final String error = "Unexpected error while resolving pipeline
context.";
throw new ContextException( error, e );
}
+ else
+ {
+ try
+ {
+ m_includes = (File[]) context.get(
+ ServiceLoaderContext.INCLUDES_KEY );
+ }
+ catch( ContextException e )
+ {
+ m_includes = new File[0];
+ }
+
+ try
+ {
+ m_verbose = ((Boolean)context.get(
+ ServiceLoaderContext.VERBOSE_POLICY_KEY )).booleanValue();
+ }
+ catch( ContextException e )
+ {
+ m_verbose = false;
+ }
+
+ try
+ {
+ m_policy = ((Boolean)context.get(
+ ServiceLoaderContext.DISPOSAL_POLICY_KEY
)).booleanValue();
+ }
+ catch( ContextException e )
+ {
+ m_policy = false;
+ }
+ }
}
+ //=======================================================================
+ // Initializable
+ //=======================================================================
+
/**
* Start the pipeline and handle any errors arrising from loader
execution.
*/
public void initialize() throws PipelineException
{
- if( m_target == null ) throw new PipelineException(
- "The pipeline task required attribute 'target' has not been not
supplied.");
+ //if( m_target == null ) throw new PipelineException(
+ // "The pipeline task required attribute 'target' has not been not
supplied.");
//
// setup the factory
@@ -365,25 +426,8 @@
return;
}
- try
- {
- process();
- }
- catch( Throwable e )
- {
- final String error = "Service processing error.";
- throw new PipelineException( error, e );
- }
- }
-
- /**
- * Initates execution of the loading of supporting services derived from
a
- * target.
- */
- private void process( ) throws PipelineException
- {
//
- // add the included jar files to the classloader
+ // preprocess the components in the include list
//
Vector list = new Vector();
@@ -394,7 +438,16 @@
stack.add( target );
list.add( target );
}
- load( stack );
+
+ try
+ {
+ load( stack );
+ }
+ catch( Throwable e )
+ {
+ final String error = "Include failure during initialization.";
+ throw new PipelineException( error, e );
+ }
// build the registry of available services
@@ -404,9 +457,21 @@
}
catch( Throwable e )
{
- final String error = "Coould not complete service registration.";
+ final String error = "Factory registration failure.";
throw new PipelineException( error, e );
}
+ }
+
+ //=======================================================================
+ // PipelineService
+ //=======================================================================
+
+ /**
+ * Initates execution of the loading of supporting services derived from
a
+ * target.
+ */
+ public Object pipeline( String target ) throws PipelineException
+ {
//
// create an instance of the target and verify that dependencies are
resolvable
@@ -415,7 +480,7 @@
UnitInfo info;
try
{
- info = new UnitInfo( m_target.replace('.','/'), m_config, m_root
);
+ info = new UnitInfo( target.replace('.','/'), m_config, m_root );
if( getVerbose() && getLogger().isDebugEnabled() )
getLogger().debug( "validating target");
try
@@ -440,13 +505,32 @@
try
{
- m_object = m_factory.pipeline( info );
+ return m_factory.pipeline( info );
}
catch( Throwable e )
{
final String error = "Service loader exception encounter during
target execution.";
throw new PipelineException( error, e );
}
+ }
+
+ //=======================================================================
+ // ServiceLoader
+ //=======================================================================
+
+ /**
+ * Handles association of a shutdown hook prior to execution of a normal
+ * pipeline process.
+ * @param target the name of the component class
+ * @param policy if TRUE then terminate following initialization
+ * @exception PipelineException if a component execution error occurs
+ */
+ private void pipeline( String target, boolean policy ) throws
PipelineException
+ {
+ if( getVerbose() && (getLogger() != null) &&
getLogger().isDebugEnabled() )
+ getLogger().debug("pipelining: " + target );
+
+ final Object object = pipeline( target );
//
// add a shutdown hook so we can stop services and target and invoke
disposal
@@ -458,53 +542,45 @@
public void run()
{
if( getVerbose() && (getLogger() != null) &&
getLogger().isDebugEnabled() )
- getLogger().debug("shutdown hook");
- terminate();
+ getLogger().debug("shutdown initiated");
+ terminate( object );
dispose();
}
}
);
- if( m_policy )
+ if( policy )
{
- if( m_object != null )
+ if( object != null )
{
- if( m_object instanceof Executable )
- {
- try
- {
- ((Executable)m_object).execute();
- }
- catch( Throwable e )
- {
- throw new PipelineException("Target execution
error.", e );
- }
- }
- terminate();
+ terminate( object );
dispose();
return;
}
}
-
+ else
+ {
+ getLogger().info( "target established: " +
object.getClass().getName());
+ }
}
/**
* Run the termination lifecycle actions on the primary object.
*/
- private void terminate( )
+ private void terminate( Object object )
{
if( m_terminated ) return;
m_terminated = true;
- if( m_object == null ) return;
+ if( object == null ) return;
if( getVerbose() && getLogger().isDebugEnabled() )
getLogger().debug(
- "terminating " + m_object.getClass().getName() );
+ "terminating " + object.getClass().getName() );
- if( m_object instanceof Startable )
+ if( object instanceof Startable )
{
try
{
- ((Startable)m_object).stop();
+ ((Startable)object).stop();
}
catch( Throwable e )
{
@@ -513,11 +589,11 @@
}
}
- if( m_object instanceof Disposable )
+ if( object instanceof Disposable )
{
try
{
- ((Disposable)m_object).dispose();
+ ((Disposable)object).dispose();
}
catch( Throwable e )
{
@@ -533,19 +609,10 @@
public void dispose()
{
if( m_disposed ) return;
-
- if( !m_terminated ) try
- {
- terminate();
- }
- catch( Throwable e )
- {
- // ignore and continue
- }
-
m_disposed = true;
- if( getVerbose() && getLogger().isDebugEnabled() )
getLogger().debug( "loader disposal" );
+ if( getVerbose() && getLogger().isDebugEnabled() )
getLogger().debug(
+ "loader disposal" );
if( m_factory instanceof Disposable )
{
try
@@ -617,23 +684,25 @@
private void load( Vector stack )
{
int size = stack.size();
+ if( getVerbose() ) getLogger().debug( "Loading stack: " +
stack.size() );
Hashtable errors = new Hashtable();
Enumeration enum = stack.elements();
while( enum.hasMoreElements() )
{
- File target = (File) enum.nextElement();
+ File file = (File) enum.nextElement();
+ if( getVerbose() ) getLogger().debug( "Loading resource: " +
file );
try
{
- m_classloader.addURL( target.toURL() );
- if( getVerbose() ) getLogger().debug( "Loaded file: " +
target );
- stack.remove( target );
+ m_classloader.addURL( file.toURL() );
+ stack.remove( file );
}
catch( Throwable error )
{
- errors.put( target, error );
+ if( getVerbose() ) getLogger().warn(
+ "Encountered error while loading resource: " + file, error
);
+ errors.put( file, error );
}
}
-
if( stack.size() == 0 ) return;
if( stack.size() < size )
{
@@ -719,7 +788,7 @@
{
private String[] m_args = new String[0];
private Priority m_priority = Priority.INFO;
- private String m_target = "";
+ private String m_target = null;
private boolean m_policy = true;
private boolean m_verbose = false;
private File[] m_files = new File[0];
@@ -729,9 +798,13 @@
{
m_args = args;
Vector vector = new Vector();
+ String arg = null;
for( int i=0; i < m_args.length; i++ )
{
- if( m_args[i].toLowerCase().startsWith("-tar") )
+
+ arg = m_args[i].toLowerCase();
+
+ if( arg.startsWith("-tar") )
{
if( i+1 < m_args.length )
{
@@ -744,7 +817,7 @@
throw new RuntimeException( error );
}
}
- else if( m_args[i].toLowerCase().startsWith("-conf") )
+ else if( arg.startsWith("-conf") )
{
if( i+1 < m_args.length )
{
@@ -757,7 +830,7 @@
throw new RuntimeException( error );
}
}
- else if( m_args[i].toLowerCase().startsWith("-pri") )
+ else if( arg.startsWith("-pri") )
{
if( i+1 < m_args.length )
{
@@ -770,7 +843,7 @@
throw new RuntimeException( error );
}
}
- else if( m_args[i].toLowerCase().startsWith("-dis") )
+ else if( arg.startsWith("-dis") )
{
if( i+1 < m_args.length )
{
@@ -783,7 +856,7 @@
throw new RuntimeException( error );
}
}
- else if( m_args[i].toLowerCase().startsWith("-ver") )
+ else if( arg.startsWith("-ver") )
{
if( i+1 < m_args.length )
{
@@ -796,9 +869,9 @@
throw new RuntimeException( error );
}
}
- else if( m_args[i].startsWith("-") )
+ else if( arg.startsWith("-") )
{
- final String error = "Unrecognized parameter: " +
m_args[i];
+ final String error = "Unrecognized parameter: " + arg;
throw new IllegalParameterException( error );
}
else
@@ -808,6 +881,11 @@
}
}
m_files = (File[]) vector.toArray( new File[0] );
+ }
+
+ public String getTarget()
+ {
+ return m_target;
}
public ServiceLoaderContext getContext()
1.5 +15 -1
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceRegistry.java
Index: ServiceRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceRegistry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServiceRegistry.java 12 Mar 2002 22:17:04 -0000 1.4
+++ ServiceRegistry.java 7 May 2002 01:43:37 -0000 1.5
@@ -140,7 +140,21 @@
for( int i=0; i<blocks.length; i++ )
{
final String path = blocks[i];
- vector.add( new UnitInfo( path, m_root ) );
+ try
+ {
+ vector.add( new UnitInfo( path, m_root ) );
+ }
+ catch( Throwable e )
+ {
+ if( m_verbose )
+ {
+ getLogger().debug( "bypassing block: " + path, e );
+ }
+ else
+ {
+ getLogger().debug( "bypassing block: " + path );
+ }
+ }
}
}
catch( Throwable e )
1.5 +9 -1
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/UnitInfo.java
Index: UnitInfo.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/UnitInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UnitInfo.java 12 Mar 2002 22:17:04 -0000 1.4
+++ UnitInfo.java 7 May 2002 01:43:37 -0000 1.5
@@ -27,7 +27,7 @@
/**
* Meta information about a <code>Serviceable</code> component.
*/
-class UnitInfo
+public class UnitInfo
{
public static final int SINGLETON_LIFETIME_POLICY = 0;
@@ -353,6 +353,9 @@
+ ", service: " +
dependencies[i].getService().getInterface().getName()
+ ", version: " + dependencies[i].getService().getVersion() );
}
+ buffer.append("\n configuration\n");
+ buffer.append( CascadingConfiguration.list( this.getConfiguration()
));
+
return buffer.toString();
}
@@ -379,6 +382,11 @@
}
}
+ /**
+ * Loads a class given a path in the form <code>org/xyz/MyClass</code>.
+ * @param path the resource path
+ * @return Class the class loaded from the path
+ */
private static Class loadClass( final String path ) throws Exception
{
return Thread.currentThread().getContextClassLoader().loadClass(
path.replace('/','.'));
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>