Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2441 - in development/main: metro/composition/control/src/main/net/dpml/composition/control transit/core/handler/src/main/net/dpml/transit/repository

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2441 - in development/main: metro/composition/control/src/main/net/dpml/composition/control transit/core/handler/src/main/net/dpml/transit/repository
  • Date: Thu, 28 Apr 2005 17:42:48 -0400

Author: mcconnell AT dpml.net
Date: Thu Apr 28 17:42:40 2005
New Revision: 2441

Added:

development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardClassLoader.java
Modified:

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java

development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardLoader.java
Log:
more on classloader info

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
Thu Apr 28 17:42:40 2005
@@ -24,13 +24,15 @@

import net.dpml.parts.control.ControlRuntimeException;

+import net.dpml.transit.repository.StandardClassLoader;
+
/**
* A named classloader.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
*/
-class CompositionClassLoader extends URLClassLoader
+class CompositionClassLoader extends StandardClassLoader
{
//--------------------------------------------------------------------
// state
@@ -50,7 +52,7 @@

public CompositionClassLoader( URI partition, int index, URI[] uris,
ClassLoader parent )
{
- super( urisToURLs( uris ), parent );
+ super( partition, urisToURLs( uris ), parent );
m_partition = partition;
m_index = index;
}
@@ -75,7 +77,7 @@

public String toString()
{
- StringBuffer buffer = new StringBuffer( "classloader stack: " );
+ StringBuffer buffer = new StringBuffer();
listClasspath( buffer );
return buffer.toString();
}
@@ -98,7 +100,19 @@
}
int index = cl.getIndex();
URI partition = cl.getPartition();
- buffer.append( "\n composition classloader:" + partition + " ("
+ index + ")" );
+ buffer.append( "\n metro: " + partition + " (" + index + ")" );
+ appendEntries( buffer, cl );
+ }
+ else if( classloader instanceof StandardClassLoader )
+ {
+ StandardClassLoader cl = (StandardClassLoader) classloader;
+ ClassLoader parent = cl.getParent();
+ if( null != parent )
+ {
+ listClasspath( buffer, parent );
+ }
+ URI partition = cl.getPartition();
+ buffer.append( "\n transit:" + partition );
appendEntries( buffer, cl );
}
else if( classloader instanceof URLClassLoader )

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardClassLoader.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardClassLoader.java
Thu Apr 28 17:42:40 2005
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.transit.repository;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * A named classloader.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class StandardClassLoader extends URLClassLoader
+{
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private final URI m_partition;
+
+ //--------------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------------
+
+ public StandardClassLoader( URI partition, ClassLoader parent )
+ {
+ this( partition, new URL[0], parent );
+ }
+
+ public StandardClassLoader( URI partition, URL[] urls, ClassLoader
parent )
+ {
+ super( urls, parent );
+ m_partition = partition;
+ }
+
+ //--------------------------------------------------------------------
+ // CompositionClassLoader
+ //--------------------------------------------------------------------
+
+ public URI getPartition()
+ {
+ return m_partition;
+ }
+
+ //--------------------------------------------------------------------
+ // Object
+ //--------------------------------------------------------------------
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ listClasspath( buffer );
+ return buffer.toString();
+ }
+
+ protected void listClasspath( StringBuffer buffer )
+ {
+ listClasspath( buffer, this );
+ buffer.append( "\n" );
+ }
+
+ protected void listClasspath( StringBuffer buffer, ClassLoader
classloader )
+ {
+ if( classloader instanceof StandardClassLoader )
+ {
+ StandardClassLoader cl = (StandardClassLoader) classloader;
+ ClassLoader parent = cl.getParent();
+ if( null != parent )
+ {
+ listClasspath( buffer, parent );
+ }
+ URI partition = cl.getPartition();
+ buffer.append( "\n transit: " + partition );
+ appendEntries( buffer, cl );
+ }
+ else if( classloader instanceof URLClassLoader )
+ {
+ URLClassLoader cl = (URLClassLoader) classloader;
+ ClassLoader parent = cl.getParent();
+ if( null != parent )
+ {
+ listClasspath( buffer, parent );
+ }
+ buffer.append( "\n url classloader" );
+ appendEntries( buffer, cl );
+ }
+ else
+ {
+ buffer.append( "\n classloader (no details)" );
+ buffer.append( "\n" );
+ }
+ }
+
+ private void appendEntries( StringBuffer buffer, URLClassLoader
classloader )
+ {
+ URL[] urls = classloader.getURLs();
+ for( int i=0; i<urls.length; i++ )
+ {
+ buffer.append( "\n " );
+ URL url = urls[i];
+ String spec = url.toString();
+ buffer.append( spec );
+ }
+ buffer.append( "\n" );
+ }
+
+}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardLoader.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardLoader.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/repository/StandardLoader.java
Thu Apr 28 17:42:40 2005
@@ -478,15 +478,18 @@

URI[] apiArtifacts = descriptor.getDependencies( Plugin.API_KEY );
URL[] apis = getURLs( apiArtifacts );
- ClassLoader api = buildClassLoader( "api", base, apis );
+ URI apiUri = appendFragment( descriptor.getURI(), "api" );
+ ClassLoader api = buildClassLoader( apiUri, base, apis );

URI[] spiArtifacts = descriptor.getDependencies( Plugin.SPI_KEY );
URL[] spis = getURLs( spiArtifacts );
- ClassLoader spi = buildClassLoader( "spi", api, spis );
+ URI spiUri = appendFragment( descriptor.getURI(), "spi" );
+ ClassLoader spi = buildClassLoader( spiUri, api, spis );

URI[] impArtifacts = descriptor.getDependencies( Plugin.IMPL_KEY );
URL[] imps = getURLs( impArtifacts );
- ClassLoader classloader = buildClassLoader( "impl", spi, imps );
+ URI implUri = appendFragment( descriptor.getURI(), "impl" );
+ ClassLoader classloader = buildClassLoader( implUri, spi, imps );

return classloader;
}
@@ -516,7 +519,7 @@
* @param urls the urls to assign as classloader content
* @return the classloader
*/
- private ClassLoader buildClassLoader( String type, ClassLoader parent,
URL[] urls )
+ private ClassLoader buildClassLoader( URI type, ClassLoader parent,
URL[] urls )
{
if( 0 == urls.length )
{
@@ -537,10 +540,10 @@
}
else
{
- ClassLoader loader = new URLClassLoader( qualified, parent );
+ ClassLoader loader = new StandardClassLoader( type, qualified,
parent );
if( m_monitor != null )
{
- m_monitor.classloaderConstructed( type, loader );
+ m_monitor.classloaderConstructed( type.toString(), loader );
}
return loader;
}
@@ -692,4 +695,18 @@
throw new RepositoryException( error, e );
}
}
+
+ private URI appendFragment( URI base, String fragment )
+ {
+ try
+ {
+ String scheme = base.getScheme();
+ String spec = base.getSchemeSpecificPart();
+ return new URI( scheme, spec, fragment );
+ }
+ catch( Throwable e )
+ {
+ return base;
+ }
+ }
}



  • svn commit: r2441 - in development/main: metro/composition/control/src/main/net/dpml/composition/control transit/core/handler/src/main/net/dpml/transit/repository, mcconnell, 04/28/2005

Archive powered by MHonArc 2.6.24.

Top of Page