Author: gnodet
Date: Mon Oct 27 04:02:35 2008
New Revision: 708133
URL: http://svn.apache.org/viewvc?rev=708133&view=rev
Log:
SM-1662: When deployed in smx4, the JBI SUs do not have access to the whole JRE
Modified:
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/xbean/XBeanDeployerTest.java
Modified:
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
URL:
http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java?rev=708133&r1=708132&r2=708133&view=diff
==============================================================================
---
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
(original)
+++
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
Mon Oct 27 04:02:35 2008
@@ -190,7 +190,7 @@
sls.add(library);
}
if (sls.size() > 0 && component.getContainer().getType() !=
Container.Type.ServiceMix3) {
- throw new IllegalStateException("Can not reference shared
libraries if the component is not deployed in ServiceMix");
+ throw new IllegalStateException("Can not reference shared
libraries if the component is not deployed in ServiceMix 3");
}
// Add components
@@ -202,7 +202,7 @@
components.add(component);
}
if (components.size() > 0 && component.getContainer().getType() !=
Container.Type.ServiceMix3) {
- throw new IllegalStateException("Can not reference other
components if the component is not deployed in ServiceMix");
+ throw new IllegalStateException("Can not reference other
components if the component is not deployed in ServiceMix 3");
}
// convert the paths to URLS
@@ -221,7 +221,7 @@
urls = getDefaultLocations();
}
- // create the classloader
+ // populate the list of parent classloaders
List<ClassLoader> parents = new ArrayList<ClassLoader>();
parents.add(getParentClassLoader(applicationContext));
for (String library : sls) {
@@ -238,6 +238,12 @@
}
parents.add(cl);
}
+ // In smx4, add the system classloader as a parent so that the
whole JRE classes are available
+ // to the SU, and not only the packages used by the components
themselves
+ if (component.getContainer().getType() ==
Container.Type.ServiceMix4) {
+ parents.add(ClassLoader.getSystemClassLoader());
+ }
+ // now actually create the classloader
classLoader = new
JarFileClassLoader(applicationContext.getDisplayName(),
urls,
parents.toArray(new
ClassLoader[parents.size()]),
Modified:
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/xbean/XBeanDeployerTest.java
URL:
http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/xbean/XBeanDeployerTest.java?rev=708133&r1=708132&r2=708133&view=diff
==============================================================================
---
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/xbean/XBeanDeployerTest.java
(original)
+++
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/xbean/XBeanDeployerTest.java
Mon Oct 27 04:02:35 2008
@@ -22,6 +22,7 @@
import org.apache.servicemix.common.ServiceUnit;
import org.apache.servicemix.common.ServiceMixComponent;
import org.apache.servicemix.common.DefaultComponent;
+import org.apache.servicemix.common.Container;
import org.apache.xbean.classloader.JarFileClassLoader;
import junit.framework.TestCase;
@@ -37,7 +38,7 @@
}
public void testDeployWithProperties() throws Exception {
- MyXBeanDeployer deployer = new MyXBeanDeployer(new DefaultComponent());
+ MyXBeanDeployer deployer = new MyXBeanDeployer(new MyComponent());
ServiceUnit su = deployer.deploy("xbean", getServiceUnitPath("xbean"));
assertNotNull(su);
assertEquals(1, su.getEndpoints().size());
@@ -46,7 +47,7 @@
}
public void testDeployWithClasspathXml() throws Exception {
- MyXBeanDeployer deployer = new MyXBeanDeployer(new DefaultComponent()
{ });
+ MyXBeanDeployer deployer = new MyXBeanDeployer(new MyComponent() { });
ServiceUnit su = deployer.deploy("xbean-cp",
getServiceUnitPath("xbean-cp"));
assertNotNull(su);
ClassLoader cl = su.getConfigurationClassLoader();
@@ -57,7 +58,7 @@
}
public void testDeployWithInlineClasspath() throws Exception {
- MyXBeanDeployer deployer = new MyXBeanDeployer(new DefaultComponent()
{ });
+ MyXBeanDeployer deployer = new MyXBeanDeployer(new MyComponent() { });
ServiceUnit su = deployer.deploy("xbean-inline",
getServiceUnitPath("xbean-inline"));
assertNotNull(su);
ClassLoader cl = su.getConfigurationClassLoader();
@@ -68,7 +69,7 @@
}
public void testDeployWithDefaultClasspath() throws Exception {
- MyXBeanDeployer deployer = new MyXBeanDeployer(new DefaultComponent()
{ });
+ MyXBeanDeployer deployer = new MyXBeanDeployer(new MyComponent() { });
ServiceUnit su = deployer.deploy("xbean-lib",
getServiceUnitPath("xbean-lib"));
assertNotNull(su);
ClassLoader cl = su.getConfigurationClassLoader();
@@ -85,6 +86,15 @@
}
}
+
+
+ protected static class MyComponent extends DefaultComponent {
+ public MyComponent() {
+ this.container = new Container.Smx3Container(null);
+ }
+ }
+
+
protected String getServiceUnitPath(String name) {
URL url = getClass().getClassLoader().getResource(name + "/xbean.xml");