Author: jstrachan
Date: Wed Sep 26 04:08:51 2007
New Revision: 579592
URL: http://svn.apache.org/viewvc?rev=579592&view=rev
Log:
added support for a <component> tag within <classpath> of a service unit to
allow components to be added to the classpath; allowing an SU to work with
multiple components on the classpath
Modified:
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
Modified:
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java?rev=579592&r1=579591&r2=579592&view=diff
==============================================================================
---
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
(original)
+++
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
Wed Sep 26 04:08:51 2007
@@ -28,6 +28,7 @@
import org.apache.servicemix.jbi.container.JBIContainer;
import org.apache.servicemix.jbi.framework.SharedLibrary;
+import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.xbean.classloader.JarFileClassLoader;
import org.apache.xbean.server.repository.FileSystemRepository;
@@ -180,7 +181,19 @@
if (sls.size() > 0 && container == null) {
throw new IllegalStateException("Can not reference shared
libraries if the component is not deployed in ServiceMix");
}
-
+
+ // Add components
+ List<String> components = new ArrayList<String>();
+ NodeList componentList =
classpathElement.getElementsByTagName("component");
+ for (int i = 0; i < componentList.getLength(); i++) {
+ Element locationElement = (Element) locations.item(i);
+ String component = ((Text)
locationElement.getFirstChild()).getData().trim();
+ components.add(component);
+ }
+ if (components.size() > 0 && container == null) {
+ throw new IllegalStateException("Can not reference other
components if the component is not deployed in ServiceMix");
+ }
+
// convert the paths to URLS
URL[] urls;
if (classpath.size() != 0) {
@@ -204,7 +217,11 @@
SharedLibrary sl =
container.getRegistry().getSharedLibrary(library);
parents.add(sl.getClassLoader());
}
- classLoader = new
JarFileClassLoader(applicationContext.getDisplayName(),
+ for (String component : components) {
+ ComponentMBeanImpl componentMBean =
container.getRegistry().getComponent(component);
+
parents.add(componentMBean.getComponent().getClass().getClassLoader());
+ }
+ classLoader = new
JarFileClassLoader(applicationContext.getDisplayName(),
urls,
parents.toArray(new
ClassLoader[parents.size()]),
inverse,