mcconnell 2003/08/18 12:42:04
Modified: merlin/composition/src/java/org/apache/avalon/composition/model/impl
DefaultContainmentModel.java
merlin/kernel/bootstrap/src/java Merlin.java
Log:
Housekeeping.
Revision Changes Path
1.26 +5 -1
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DefaultContainmentModel.java 18 Aug 2003 11:26:05 -0000 1.25
+++ DefaultContainmentModel.java 18 Aug 2003 19:42:03 -0000 1.26
@@ -572,6 +572,10 @@
throw new ModelException( error );
}
}
+ catch( ModelException e )
+ {
+ throw e;
+ }
catch( MalformedURLException e )
{
final String error =
1.6 +119 -2 avalon-sandbox/merlin/kernel/bootstrap/src/java/Merlin.java
Index: Merlin.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/kernel/bootstrap/src/java/Merlin.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Merlin.java 18 Aug 2003 11:26:05 -0000 1.5
+++ Merlin.java 18 Aug 2003 19:42:04 -0000 1.6
@@ -92,6 +92,12 @@
"merlin.bootstrap.classpath.length";
private static final String MERLIN_BOOTSTRAP_CLASSPATH_KEY =
"merlin.bootstrap.classpath";
+ private static final String MERLIN_API_CLASSPATH_KEY =
+ "merlin.api.classpath";
+ private static final String MERLIN_SPI_CLASSPATH_KEY =
+ "merlin.spi.classpath";
+ private static final String MERLIN_IMPL_CLASSPATH_KEY =
+ "merlin.impl.classpath";
private static final String MERLIN_PROPERTIES_NAME =
"merlin.properties";
@@ -162,7 +168,7 @@
URL[] bootstrap = null;
try
{
- bootstrap = getURLs( repository, properties );
+ bootstrap = getURLs( repository, properties,
MERLIN_BOOTSTRAP_CLASSPATH_KEY );
}
catch( Throwable e )
{
@@ -174,12 +180,63 @@
return;
}
+ URL[] api = null;
+ try
+ {
+ api = getURLs( repository, properties, MERLIN_API_CLASSPATH_KEY );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "\nInternal error while attempting to build api classloader.";
+ String msg =
+ ExceptionHelper.packException( error, e, true );
+ System.err.println( msg );
+ return;
+ }
+
+ URL[] spi = null;
+ try
+ {
+ spi = getURLs( repository, properties, MERLIN_SPI_CLASSPATH_KEY );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "\nInternal error while attempting to build api classloader.";
+ String msg =
+ ExceptionHelper.packException( error, e, true );
+ System.err.println( msg );
+ return;
+ }
+
+ URL[] impl = null;
+ try
+ {
+ impl = getURLs( repository, properties, MERLIN_IMPL_CLASSPATH_KEY );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "\nInternal error while attempting to build implementation
classloader.";
+ String msg =
+ ExceptionHelper.packException( error, e, true );
+ System.err.println( msg );
+ return;
+ }
+
//
// create the container bootstrap classloader using these
// URLs
//
- ClassLoader loader = new URLClassLoader( bootstrap );
+ ClassLoader apiLoader = new URLClassLoader( api );
+ ClassLoader spiLoader = new URLClassLoader( spi, apiLoader );
+ ClassLoader loader = new URLClassLoader( impl, spiLoader );
+
+ //ClassLoader loader = new URLClassLoader( bootstrap );
+ //Thread.currentThread().setContextClassLoader( loader );
+
Thread.currentThread().setContextClassLoader( loader );
//
@@ -228,6 +285,65 @@
}
}
+ private static URL[] getURLs( Repository repository, Properties properties,
String key )
+ {
+ final String value = properties.getProperty( key + ".length" );
+ if( value == null )
+ {
+ throw new NullPointerException( value );
+ }
+ int i = Integer.parseInt( value );
+ return getURLs( repository, properties, key, i );
+ }
+
+ private static URL[] getURLs(
+ Repository repository, Properties properties, String label, int i )
+ {
+ ArrayList list = new ArrayList();
+ for( int j=0; j<i; j++ )
+ {
+ final String key = label + "." + j;
+ final String item = properties.getProperty( key );
+ if( item == null )
+ {
+ final String error =
+ "Inconsistent classpath entry: " + key;
+ throw new IllegalStateException( error );
+ }
+ try
+ {
+ int n = item.indexOf( ":" );
+ final String group = item.substring( 0, n );
+
+ String artifact = null;
+ String version = null;
+ int m = item.indexOf( ";" );
+ if( m > -1 )
+ {
+ artifact = item.substring( n+1, m );
+ version = item.substring( m+1, item.length() );
+ }
+ else
+ {
+ artifact = item.substring( n+1, item.length() );
+ }
+
+ URL url = repository.getArtifact( group, artifact, version, "jar" );
+ list.add( url );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal bootstrap error. Unable to load item: " + item;
+ throw new BootstrapRuntimeException( error, e );
+ }
+ }
+
+ return (URL[]) list.toArray( new URL[0] );
+ }
+
+
+ /*
private static URL[] getURLs( Repository repository, Properties properties )
{
ArrayList list = new ArrayList();
@@ -283,4 +399,5 @@
return (URL[]) list.toArray( new URL[0] );
}
+ */
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]