[jboss-cvs] JBossAS SVN: r94472 - in projects/jboss-osgi: projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloading and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 7 13:26:30 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-07 13:26:29 -0400 (Wed, 07 Oct 2009)
New Revision: 94472
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloading/BundleClassPathTest.java
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/example/pom.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
[JBOSGI-162] Cannot load classes from Bundle-ClassPath
Fixed in OSGiClassLoaderFactory
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2009-10-07 17:26:29 UTC (rev 94472)
@@ -23,6 +23,10 @@
// $Id$
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderPolicyFactory;
import org.jboss.classloader.spi.ClassLoaderSystem;
@@ -31,7 +35,9 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.virtual.VirtualFile;
/**
* OSGiClassLoaderFactory
@@ -43,6 +49,9 @@
*/
public class OSGiClassLoaderFactory implements ClassLoaderFactory
{
+ /** The log */
+ private static final Logger log = Logger.getLogger(OSGiClassLoaderFactory.class);
+
/** The classloader system */
private ClassLoaderSystem system;
@@ -67,8 +76,50 @@
{
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
- return new OSGiClassLoaderPolicy(bundleState, vfsUnit.getRoot());
+ VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
+ return new OSGiClassLoaderPolicy(bundleState, roots);
}
+
+ private VirtualFile[] getClassLoaderPolicyRoots(OSGiBundleState bundleState, VFSDeploymentUnit vfsUnit)
+ {
+ VirtualFile root = vfsUnit.getRoot();
+
+ // If there is no Bundle-ClassPath in the manifest, simply use the root
+ List<String> bundleClassPath = bundleState.getOSGiMetaData().getBundleClassPath();
+ if (bundleClassPath == null)
+ {
+ return new VirtualFile[] { root };
+ }
+
+ log.debug("Bundle-ClassPath: " + bundleClassPath);
+
+ // Add a vfs root for every Bundle-ClassPath element
+ List<VirtualFile> rootsList = new ArrayList<VirtualFile>();
+ for (String path : bundleClassPath)
+ {
+ if (path.equals("."))
+ {
+ rootsList.add(root);
+ }
+ else
+ {
+ try
+ {
+ VirtualFile child = root.getChild(path);
+ rootsList.add(child);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalArgumentException("Cannot find class path '" + path + "' in: " + root);
+ }
+ }
+ }
+
+ VirtualFile[] rootsArray = new VirtualFile[rootsList.size()];
+ rootsList.toArray(rootsArray);
+
+ return rootsArray;
+ }
});
return vfsModule.registerClassLoaderPolicy(system);
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2009-10-07 17:26:29 UTC (rev 94472)
@@ -38,9 +38,9 @@
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
- public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile root)
+ public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile[] roots)
{
- super(new VirtualFile[] { root });
+ super(roots);
if (bundleState == null)
throw new IllegalArgumentException("Null bundleState");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloading/BundleClassPathTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloading/BundleClassPathTest.java 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloading/BundleClassPathTest.java 2009-10-07 17:26:29 UTC (rev 94472)
@@ -22,6 +22,7 @@
package org.jboss.test.osgi.classloading;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
@@ -52,8 +53,8 @@
bundle.start();
assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
- //Class<?> clazz = bundle.loadClass(EndpointServlet.class.getName());
- //assertNotNull("Loaded EndpointServlet", clazz);
+ Class<?> clazz = bundle.loadClass(EndpointServlet.class.getName());
+ assertNotNull("Loaded EndpointServlet", clazz);
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-10-07 17:26:29 UTC (rev 94472)
@@ -153,8 +153,12 @@
<property name="classLoaderSystem"><inject bean="ClassLoaderSystem"/></property>
<property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
</bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
<bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<!--
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-10-07 17:26:29 UTC (rev 94472)
@@ -179,8 +179,12 @@
<property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
<property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
</bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
<bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-07 17:26:29 UTC (rev 94472)
@@ -165,8 +165,12 @@
<property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
<property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
</bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
<bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
Modified: projects/jboss-osgi/trunk/testsuite/example/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/pom.xml 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/trunk/testsuite/example/pom.xml 2009-10-07 17:26:29 UTC (rev 94472)
@@ -298,6 +298,14 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>${target.container.excludes}</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</build>
</profile>
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-07 17:26:29 UTC (rev 94472)
@@ -170,8 +170,12 @@
<property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
<property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
</bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
<bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-07 16:43:58 UTC (rev 94471)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-07 17:26:29 UTC (rev 94472)
@@ -167,8 +167,12 @@
<property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
<property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
</bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
<bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
More information about the jboss-cvs-commits
mailing list