Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2438 - in development/main: metro metro/composition/control/src/main/net/dpml/composition/control metro/composition/testing/test/src/main/net/dpml/test/state transit/core/plugin transit/core/plugin/src/main/net/dpml/transit/control

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: r2438 - in development/main: metro metro/composition/control/src/main/net/dpml/composition/control metro/composition/testing/test/src/main/net/dpml/test/state transit/core/plugin transit/core/plugin/src/main/net/dpml/transit/control
  • Date: Thu, 28 Apr 2005 14:23:15 -0400

Author: mcconnell AT dpml.net
Date: Thu Apr 28 14:23:11 2005
New Revision: 2438

Modified:

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

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

development/main/metro/composition/testing/test/src/main/net/dpml/test/state/ManagedComponent.java
development/main/metro/index.xml
development/main/transit/core/plugin/build.xml

development/main/transit/core/plugin/src/main/net/dpml/transit/control/CommandHandler.java
Log:
improving classloader chains (thanks to a nifty classloader stack report)

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
Thu Apr 28 14:23:11 2005
@@ -23,7 +23,10 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import java.util.Map.Entry;
@@ -506,18 +509,76 @@
private ClassLoader getClassLoader( URI partition, ClassLoader parent,
ComponentProfile profile )
{
final String name = profile.getName();
- final URI local = getLocalPartition( partition, name );
final ClassLoaderDirective cld = profile.getClassLoaderDirective();
final ClasspathDirective[] cpds = cld.getClasspathDirectives();
for( int i=(cpds.length - 1); i>-1; i-- )
{
ClasspathDirective cpd = cpds[i];
- URI[] uris = cpd.getURIs();
- parent = new CompositionClassLoader( local, i, uris, parent );
+ URI[] uris = filter( cpd.getURIs(), parent );
+ if( uris.length > 0 )
+ {
+ parent = new CompositionClassLoader( partition, i, uris,
parent );
+ }
}
return parent;
}

+ private URI[] filter( URI[] uris, ClassLoader classloader )
+ {
+ if( classloader instanceof URLClassLoader )
+ {
+ URLClassLoader loader = (URLClassLoader) classloader;
+ return filterURLClassLoader( uris, loader );
+ }
+ else
+ {
+ return uris;
+ }
+ }
+
+ private URI[] filterURLClassLoader( URI[] uris, URLClassLoader parent )
+ {
+ ArrayList list = new ArrayList();
+ for( int i=(uris.length - 1); i>-1; i-- )
+ {
+ URI uri = uris[i];
+ String path = uri.toString();
+ if( false == exists( uri, parent ) )
+ {
+ list.add( uri );
+ }
+ }
+ return (URI[]) list.toArray( new URI[0] );
+ }
+
+ private boolean exists( URI uri, URLClassLoader classloader )
+ {
+ ClassLoader parent = classloader.getParent();
+ if( parent instanceof URLClassLoader )
+ {
+ URLClassLoader loader = (URLClassLoader) parent;
+ if( exists( uri, loader ) )
+ {
+ return true;
+ }
+ }
+
+ String ref = uri.toString();
+ URL[] urls = classloader.getURLs();
+ for( int i=0; i<urls.length; i++ )
+ {
+ URL url = urls[i];
+ String spec = url.toString();
+ if( spec.equals( ref ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
private URI getLocalPartition( URI base, String name )
{
String scheme = base.getScheme();

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
Thu Apr 28 14:23:11 2005
@@ -81,9 +81,8 @@
super( new DefaultMonitor( system.getLogger() ), system,
createPartition( system ) );

URI partition = createPartition( system );
- ClassLoader anchor = net.dpml.logging.Logger.class.getClassLoader();
+ m_classloader =
net.dpml.composition.info.Type.class.getClassLoader();

- m_classloader = new CompositionClassLoader( partition, anchor );
m_context = system;
m_partition = partition;


Modified:
development/main/metro/composition/testing/test/src/main/net/dpml/test/state/ManagedComponent.java
==============================================================================
---
development/main/metro/composition/testing/test/src/main/net/dpml/test/state/ManagedComponent.java
(original)
+++
development/main/metro/composition/testing/test/src/main/net/dpml/test/state/ManagedComponent.java
Thu Apr 28 14:23:11 2005
@@ -148,6 +148,10 @@
buffer.append( "\n-------------------------------------------------"
);
buffer.append( STATE_GRAPH.list() );
buffer.append( "\n-------------------------------------------------"
);
+ buffer.append( "\nClass Loader Stack" );
+ buffer.append( "\n-------------------------------------------------"
);
+ buffer.append( "\n" + getClass().getClassLoader().toString() );
+ buffer.append( "\n-------------------------------------------------"
);
getLogger().info( buffer.toString() );
}


Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Thu Apr 28 14:23:11 2005
@@ -269,9 +269,9 @@
<include key="dpml-util-exception"/>
<include key="dpml-util-criteria"/>
<include key="dpml-util-cli"/>
+ <include key="commons-cli"/>
<include key="dpml-system-impl" build="false"/>
<include key="dpml-classic-impl" build="false"/>
- <include key="commons-cli"/>
</dependencies>
</project>

@@ -428,19 +428,12 @@
<dependencies>
<include key="dpml-parts-api"/>
<include key="dpml-transit-main"/>
- <include key="dpml-util-i18n"/>
<include key="dpml-configuration-api"/>
- <include key="dpml-context-api"/>
- <include key="dpml-service-api"/>
<include key="dpml-parameters-api"/>
<include key="dpml-logging-api"/>
<include key="dpml-logging-data"/>
- <!--
<include key="dpml-configuration-impl" build="false" test="true"
runtime="false"/>
<include key="dpml-parameters-impl" build="false" test="true"
runtime="false"/>
- -->
- <include key="dpml-configuration-impl"/>
- <include key="dpml-parameters-impl"/>
</dependencies>
</project>

@@ -460,9 +453,9 @@
<include key="dpml-activity-api" tag="api"/>
<include key="dpml-parameters-api" tag="api"/>
<include key="dpml-configuration-api" tag="api"/>
- <include key="dpml-parts-api" tag="api"/>
+ <include key="dpml-parts-api" tag="spi"/>
<include key="dpml-composition-part" tag="spi"/>
- <include key="dpml-system-api" tag="spi"/>
+ <include key="dpml-system-api"/>
<include key="dpml-util-exception"/>
<include key="dpml-parameters-impl"/>
<include key="dpml-configuration-impl"/>
@@ -524,7 +517,7 @@
</types>
</info>
<plugins>
- <include key="dpml-composition-builder"/>
+ <include key="dpml-composition-builder" runtime="false"/>
</plugins>
</project>


Modified: development/main/transit/core/plugin/build.xml
==============================================================================
--- development/main/transit/core/plugin/build.xml (original)
+++ development/main/transit/core/plugin/build.xml Thu Apr 28 14:23:11
2005
@@ -78,15 +78,19 @@
dpml.plugin.class = net.dpml.transit.control.CommandHandler

#
+# API dependencies.
+#
+dpml.artifact.dependency.api.0 =
artifact:jar:dpml/transit/dpml-transit-main#${project.version}
+
+#
# Implementation dependencies.
#
-dpml.artifact.dependency.0 =
artifact:jar:dpml/transit/dpml-transit-main#${project.version}
-dpml.artifact.dependency.1 =
artifact:jar:dpml/util/dpml-util-criteria#${project.version}
-dpml.artifact.dependency.2 =
artifact:jar:dpml/util/dpml-util-i18n#${project.version}
-dpml.artifact.dependency.3 =
artifact:jar:dpml/util/dpml-util-exception#${project.version}
-dpml.artifact.dependency.4 =
artifact:jar:dpml/util/dpml-util-cli#${project.version}
-dpml.artifact.dependency.5 = artifact:jar:commons-cli/commons-cli#1.0
-dpml.artifact.dependency.6 =
artifact:jar:dpml/transit/dpml-transit-plugin#${project.version}
+dpml.artifact.dependency.0 =
artifact:jar:dpml/util/dpml-util-criteria#${project.version}
+dpml.artifact.dependency.1 =
artifact:jar:dpml/util/dpml-util-i18n#${project.version}
+dpml.artifact.dependency.2 =
artifact:jar:dpml/util/dpml-util-exception#${project.version}
+dpml.artifact.dependency.3 =
artifact:jar:dpml/util/dpml-util-cli#${project.version}
+dpml.artifact.dependency.4 = artifact:jar:commons-cli/commons-cli#1.0
+dpml.artifact.dependency.5 =
artifact:jar:dpml/transit/dpml-transit-plugin#${project.version}

#
# EOF.

Modified:
development/main/transit/core/plugin/src/main/net/dpml/transit/control/CommandHandler.java
==============================================================================
---
development/main/transit/core/plugin/src/main/net/dpml/transit/control/CommandHandler.java
(original)
+++
development/main/transit/core/plugin/src/main/net/dpml/transit/control/CommandHandler.java
Thu Apr 28 14:23:11 2005
@@ -30,6 +30,7 @@

import net.dpml.lang.NullArgumentException;

+import net.dpml.transit.Transit;
import net.dpml.transit.TransitException;
import net.dpml.transit.repository.Plugin;
import net.dpml.transit.repository.Repository;
@@ -293,7 +294,8 @@
map.put( "urn:transit.cli.args", m_args );
Dictionary dictionary = new Dictionary( map );

- ClassLoader loader = CommandHandler.class.getClassLoader();
+ //ClassLoader loader = CommandHandler.class.getClassLoader();
+ ClassLoader loader = Transit.class.getClassLoader();
Object[] args = new Object[]{dictionary, m_args};
try
{



  • svn commit: r2438 - in development/main: metro metro/composition/control/src/main/net/dpml/composition/control metro/composition/testing/test/src/main/net/dpml/test/state transit/core/plugin transit/core/plugin/src/main/net/dpml/transit/control, mcconnell, 04/28/2005

Archive powered by MHonArc 2.6.24.

Top of Page