JBoss-OSGI SVN: r99284 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-12 09:00:11 -0500 (Tue, 12 Jan 2010)
New Revision: 99284
Added:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragB/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragC/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/HostAActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostB/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostB/HostBActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostC/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostC/HostCActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/subA/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragA.bnd
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragB.bnd
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragC.bnd
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostB.bnd
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostC.bnd
Removed:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragmentService.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/frgmA/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/FragmentHostActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd
Log:
[JBOSGI-245] Framework fragments
Add more test coverage
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -805,6 +805,7 @@
*/
protected void checkInstalled()
{
+ // If this bundle's state is UNINSTALLED, then an IllegalStateException is thrown
if ((getState() & Bundle.UNINSTALLED) != 0)
throw new IllegalStateException("Bundle " + getCanonicalName() + " is not installed");
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -141,9 +141,14 @@
checkInstalled();
checkAdminPermission(AdminPermission.CLASS);
+ // If this bundle's state is INSTALLED, this method must attempt to resolve this bundle
+ // [TODO] If this bundle cannot be resolved, a Framework event of type FrameworkEvent.ERROR is fired containing a BundleException with details of the reason this bundle could not be resolved.
+ // This method must then throw a ClassNotFoundException.
if (resolveBundle() == false)
+ {
throw new ClassNotFoundException("Cannot load class: " + name);
-
+ }
+
ClassLoader classLoader = getDeploymentUnit().getClassLoader();
Class<?> clazz = classLoader.loadClass(name);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -29,7 +29,6 @@
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.classloading.spi.metadata.RequirementsMetaData;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.ClassLoaderFactory;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/pom.xml 2010-01-12 14:00:11 UTC (rev 99284)
@@ -58,7 +58,7 @@
<version.jboss.osgi.hotdeploy>1.0.3</version.jboss.osgi.hotdeploy>
<version.jboss.osgi.husky>1.0.3-SNAPSHOT</version.jboss.osgi.husky>
<version.jboss.osgi.jaxb>2.1.10.SP3</version.jboss.osgi.jaxb>
- <version.jboss.osgi.jmx>1.0.2.SP1</version.jboss.osgi.jmx>
+ <version.jboss.osgi.jmx>1.0.3-SNAPSHOT</version.jboss.osgi.jmx>
<version.jboss.osgi.jndi>1.0.2</version.jboss.osgi.jndi>
<version.jboss.osgi.jta>1.0.0</version.jboss.osgi.jta>
<version.jboss.osgi.reflect>2.2.0-SNAPSHOT</version.jboss.osgi.reflect>
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2010-01-12 14:00:11 UTC (rev 99284)
@@ -64,7 +64,11 @@
<!-- fragments/simple -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-hostA.jar" files="${tests.resources.dir}/fragments/simple-hostA.bnd" />
- <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-frgmA.jar" files="${tests.resources.dir}/fragments/simple-frgmA.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-hostB.jar" files="${tests.resources.dir}/fragments/simple-hostB.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-hostC.jar" files="${tests.resources.dir}/fragments/simple-hostC.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-fragA.jar" files="${tests.resources.dir}/fragments/simple-fragA.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-fragB.jar" files="${tests.resources.dir}/fragments/simple-fragB.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-fragC.jar" files="${tests.resources.dir}/fragments/simple-fragC.bnd" />
<!-- jbossas/jbosgi36 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi36-bundle.jar" files="${tests.resources.dir}/jbossas/jbosgi36/jbosgi36.bnd" />
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2010-01-12 14:00:11 UTC (rev 99284)
@@ -27,6 +27,7 @@
<include>*:jboss-osgi-webapp:jar</include>
<include>*:jboss-osgi-xml-binding:jar</include>
<include>*:org.apache.felix.configadmin:jar</include>
+ <include>*:org.apache.felix.eventadmin:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.apache.felix.metatype:jar</include>
<include>*:pax-web-jetty-bundle:jar</include>
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -31,10 +31,13 @@
import java.net.URL;
import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiPackageAdmin;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
-import org.jboss.test.osgi.fragments.frgmA.FragmentService;
-import org.junit.Ignore;
+import org.jboss.test.osgi.fragments.fragA.FragBeanA;
+import org.jboss.test.osgi.fragments.subA.SubBeanA;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -47,104 +50,294 @@
*/
public class FragmentTestCase extends OSGiTest
{
+ private OSGiRuntime runtime;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ runtime = getDefaultRuntime();
+ }
+
+ @After
+ public void tearDown()
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
@Test
- @Ignore
public void testHostOnly() throws Exception
{
- OSGiRuntime runtime = getDefaultRuntime();
- try
- {
- OSGiBundle host = runtime.installBundle("fragments-simple-hostA.jar");
- assertBundleState(Bundle.INSTALLED, host.getState());
+ // Bundle-SymbolicName: simple-hostA
+ // Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
+ OSGiBundle hostA = runtime.installBundle("fragments-simple-hostA.jar");
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
- host.start();
- assertBundleState(Bundle.ACTIVE, host.getState());
+ hostA.start();
+ assertBundleState(Bundle.ACTIVE, hostA.getState());
- URL entryURL = host.getEntry("resources/resource.txt");
- assertNull("Entry URL null", entryURL);
+ URL entryURL = hostA.getEntry("resources/resource.txt");
+ assertNull("Entry URL null", entryURL);
- URL resourceURL = host.getResource("resources/resource.txt");
- assertNull("Resource URL null", resourceURL);
+ URL resourceURL = hostA.getResource("resources/resource.txt");
+ assertNull("Resource URL null", resourceURL);
- host.uninstall();
- assertBundleState(Bundle.UNINSTALLED, host.getState());
- }
- finally
- {
- runtime.shutdown();
- }
+ // Load a private class
+ OSGiBundle subBeanProvider = hostA.loadClass(SubBeanA.class.getName());
+ assertEquals("Class provided by host", hostA, subBeanProvider);
+
+ hostA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostA.getState());
}
@Test
- @Ignore
public void testFragmentOnly() throws Exception
{
- OSGiRuntime runtime = getDefaultRuntime();
+ // Bundle-SymbolicName: simple-fragA
+ // Export-Package: org.jboss.test.osgi.fragments.fragA
+ // Include-Resource: resources/resource.txt=resource.txt
+ // Fragment-Host: simple-hostA
+ OSGiBundle fragA = runtime.installBundle("fragments-simple-fragA.jar");
+ assertBundleState(Bundle.INSTALLED, fragA.getState());
+
+ URL entryURL = fragA.getEntry("resources/resource.txt");
+ assertNotNull("Entry URL not null", entryURL);
+
+ URL resourceURL = fragA.getResource("resources/resource.txt");
+ assertNull("Resource URL null", resourceURL);
+
try
{
- OSGiBundle fragment = runtime.installBundle("fragments-simple-frgmA.jar");
- assertBundleState(Bundle.INSTALLED, fragment.getState());
+ fragA.start();
+ fail("Fragment bundles can not be started");
+ }
+ catch (BundleException e)
+ {
+ assertBundleState(Bundle.INSTALLED, fragA.getState());
+ }
- URL entryURL = fragment.getEntry("resources/resource.txt");
- assertNotNull("Entry URL not null", entryURL);
+ fragA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, fragA.getState());
+ }
- URL resourceURL = fragment.getResource("resources/resource.txt");
- assertNull("Resource URL null", resourceURL);
+ @Test
+ public void testAttachedFragment() throws Exception
+ {
+ // Bundle-SymbolicName: simple-hostA
+ // Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
+ OSGiBundle hostA = runtime.installBundle("fragments-simple-hostA.jar");
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
- try
- {
- fragment.start();
- fail("Fragment bundles can not be started");
- }
- catch (BundleException e)
- {
- assertBundleState(Bundle.INSTALLED, fragment.getState());
- }
+ // Bundle-SymbolicName: simple-fragA
+ // Export-Package: org.jboss.test.osgi.fragments.fragA
+ // Include-Resource: resources/resource.txt=resource.txt
+ // Fragment-Host: simple-hostA
+ OSGiBundle fragA = runtime.installBundle("fragments-simple-fragA.jar");
+ assertBundleState(Bundle.INSTALLED, fragA.getState());
- fragment.uninstall();
- assertBundleState(Bundle.UNINSTALLED, fragment.getState());
- }
- finally
+ hostA.start();
+ assertBundleState(Bundle.ACTIVE, hostA.getState());
+ assertBundleState(Bundle.RESOLVED, fragA.getState());
+
+ URL entryURL = hostA.getEntry("resources/resource.txt");
+ assertNull("Entry URL null", entryURL);
+
+ URL resourceURL = hostA.getResource("resources/resource.txt");
+ assertNotNull("Resource URL not null", resourceURL);
+
+ OSGiBundle fragBeanProvider = hostA.loadClass(FragBeanA.class.getName());
+ assertEquals("Class provided by fragment", hostA, fragBeanProvider);
+
+ // Load a private class
+ OSGiBundle subBeanProvider = hostA.loadClass(SubBeanA.class.getName());
+ assertEquals("Class provided by fragment", hostA, subBeanProvider);
+
+ hostA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostA.getState());
+ assertBundleState(Bundle.RESOLVED, fragA.getState());
+
+ fragA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, fragA.getState());
+ }
+
+ @Test
+ public void testHiddenPrivatePackage() throws Exception
+ {
+ if ("jbossmc".equals(getFramework()))
{
- runtime.shutdown();
+ System.out.println("FIXME [JBOSGI-245] Framework fragments");
+ return;
}
+
+ // Bundle-SymbolicName: simple-hostA
+ // Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
+ OSGiBundle hostA = runtime.installBundle("fragments-simple-hostA.jar");
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
+
+ // Bundle-SymbolicName: simple-hostB
+ // Export-Package: org.jboss.test.osgi.fragments.subA
+ // Private-Package: org.jboss.test.osgi.fragments.hostB
+ OSGiBundle hostB = runtime.installBundle("fragments-simple-hostB.jar");
+ assertBundleState(Bundle.INSTALLED, hostB.getState());
+
+ // Bundle-SymbolicName: simple-fragB
+ // Import-Package: org.jboss.test.osgi.fragments.subA
+ // Fragment-Host: simple-hostA
+ OSGiBundle fragB = runtime.installBundle("fragments-simple-fragB.jar");
+ assertBundleState(Bundle.INSTALLED, fragB.getState());
+
+ hostA.start();
+ assertBundleState(Bundle.ACTIVE, hostA.getState());
+ assertBundleState(Bundle.RESOLVED, fragB.getState());
+
+ // The fragment contains an overwrites Private-Package with Import-Package
+ // The SubBeanA is expected to come from HostB, which exports that package
+ OSGiBundle subBeanProvider = hostA.loadClass(SubBeanA.class.getName());
+ assertEquals("Class provided by host", hostB, subBeanProvider);
+
+ hostA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostA.getState());
+ assertBundleState(Bundle.RESOLVED, fragB.getState());
+
+ hostB.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostB.getState());
+
+ fragB.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, fragB.getState());
}
@Test
- public void testAttachedFragment() throws Exception
+ public void testFragmentExportsPackage() throws Exception
{
- OSGiRuntime runtime = getDefaultRuntime();
+ if ("jbossmc".equals(getFramework()))
+ {
+ System.out.println("FIXME [JBOSGI-245] Framework fragments");
+ return;
+ }
+
+ // Bundle-SymbolicName: simple-hostA
+ // Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
+ OSGiBundle hostA = runtime.installBundle("fragments-simple-hostA.jar");
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
+
+ // Bundle-SymbolicName: simple-hostC
+ // Import-Package: org.jboss.test.osgi.fragments.fragA
+ // Private-Package: org.jboss.test.osgi.fragments.hostC
+ OSGiBundle hostC = runtime.installBundle("fragments-simple-hostC.jar");
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
+
+ hostA.start();
+ assertBundleState(Bundle.ACTIVE, hostA.getState());
+
try
{
- OSGiBundle host = runtime.installBundle("fragments-simple-hostA.jar");
- assertBundleState(Bundle.INSTALLED, host.getState());
+ // HostA does not export the package needed by HostC
+ hostC.start();
+ fail("Unresolved constraint expected");
+ }
+ catch (BundleException ex)
+ {
+ assertBundleState(Bundle.INSTALLED, hostC.getState());
+ }
- OSGiBundle fragment = runtime.installBundle("fragments-simple-frgmA.jar");
- assertBundleState(Bundle.INSTALLED, fragment.getState());
+ // Bundle-SymbolicName: simple-fragA
+ // Export-Package: org.jboss.test.osgi.fragments.fragA
+ // Include-Resource: resources/resource.txt=resource.txt
+ // Fragment-Host: simple-hostA
+ OSGiBundle fragA = runtime.installBundle("fragments-simple-fragA.jar");
+ assertBundleState(Bundle.INSTALLED, fragA.getState());
- host.start();
- assertBundleState(Bundle.ACTIVE, host.getState());
- assertBundleState(Bundle.RESOLVED, fragment.getState());
+ try
+ {
+ // FragA does not attach to the aleady resolved HostA
+ // HostA does not export the package needed by HostC
+ hostC.start();
+ fail("Unresolved constraint expected");
+ }
+ catch (BundleException ex)
+ {
+ assertBundleState(Bundle.INSTALLED, hostC.getState());
+ }
- URL entryURL = host.getEntry("resources/resource.txt");
- assertNull("Entry URL null", entryURL);
+ // Refreshing HostA causes the FragA to get attached
+ OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
+ packageAdmin.refreshPackages(new OSGiBundle[] { hostA });
- URL resourceURL = host.getResource("resources/resource.txt");
- assertNotNull("Resource URL not null", resourceURL);
+ // Wait for the fragment to get attached
+ int timeout = 2000;
+ while (timeout > 0 && fragA.getState() != Bundle.RESOLVED)
+ {
+ Thread.sleep(200);
+ timeout -= 200;
+ }
- OSGiBundle classProvider = host.loadClass(FragmentService.class.getName());
- assertEquals("Class provided by fragment", host, classProvider);
+ // HostC should now resolve and start
+ hostC.start();
+ assertBundleState(Bundle.ACTIVE, hostC.getState());
- host.uninstall();
- assertBundleState(Bundle.UNINSTALLED, host.getState());
- assertBundleState(Bundle.RESOLVED, fragment.getState());
+ hostA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostA.getState());
- fragment.uninstall();
- assertBundleState(Bundle.UNINSTALLED, fragment.getState());
+ hostC.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostC.getState());
+
+ fragA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, fragA.getState());
+ }
+
+ @Test
+ public void testFragmentRequireBundle() throws Exception
+ {
+ if ("jbossmc".equals(getFramework()))
+ {
+ System.out.println("FIXME [JBOSGI-245] Framework fragments");
+ return;
}
- finally
+
+ // Bundle-SymbolicName: simple-hostA
+ // Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
+ OSGiBundle hostA = runtime.installBundle("fragments-simple-hostA.jar");
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
+
+ // Bundle-SymbolicName: simple-fragC
+ // Export-Package: org.jboss.test.osgi.fragments.fragC
+ // Require-Bundle: simple-hostB
+ // Fragment-Host: simple-hostA
+ OSGiBundle fragC = runtime.installBundle("fragments-simple-fragC.jar");
+ assertBundleState(Bundle.INSTALLED, fragC.getState());
+
+ try
{
- runtime.shutdown();
+ // The attached FragA requires bundle HostB, which is not yet installed
+ hostA.start();
+
+ // Clarify error behaviour when fragments fail to attach
+ // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1524
+ //
+ // Felix: Merges FragC Require-Bundle into HostA and fails to resolve
+ // Equinox: Resolves HostA but does not attach FragA
+ if (hostA.getState() == Bundle.ACTIVE)
+ assertBundleState(Bundle.INSTALLED, fragC.getState());
}
+ catch (BundleException ex)
+ {
+ assertBundleState(Bundle.INSTALLED, hostA.getState());
+ }
+
+ // Bundle-SymbolicName: simple-hostB
+ // Export-Package: org.jboss.test.osgi.fragments.subA
+ // Private-Package: org.jboss.test.osgi.fragments.hostB
+ OSGiBundle hostB = runtime.installBundle("fragments-simple-hostB.jar");
+ assertBundleState(Bundle.INSTALLED, hostB.getState());
+
+ // HostA should resolve and start after HostB got installed
+ hostA.start();
+ assertBundleState(Bundle.ACTIVE, hostA.getState());
+
+ hostA.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, hostA.getState());
+
+ fragC.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, fragC.getState());
}
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA (from rev 99165, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/frgmA)
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java (from rev 99165, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/frgmA/FragmentService.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.fragA;
+
+//$Id$
+
+
+public class FragBeanA
+{
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragmentService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/frgmA/FragmentService.java 2010-01-08 15:37:37 UTC (rev 99165)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragA/FragmentService.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.fragments.frgmA;
-
-//$Id$
-
-
-public class FragmentService
-{
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.fragB;
+
+//$Id: FragmentService.java 99106 2010-01-07 11:02:59Z thomas.diesler(a)jboss.com $
+
+
+public class FragBeanB
+{
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.fragC;
+
+//$Id: FragmentService.java 99106 2010-01-07 11:02:59Z thomas.diesler(a)jboss.com $
+
+
+public class FragBeanC
+{
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/FragmentHostActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/FragmentHostActivator.java 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/FragmentHostActivator.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.fragments.hostA;
-
-//$Id$
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class FragmentHostActivator implements BundleActivator
-{
- public void start(BundleContext context)
- {
- }
-
- public void stop(BundleContext context)
- {
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/HostAActivator.java (from rev 99165, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/FragmentHostActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/HostAActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostA/HostAActivator.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.hostA;
+
+//$Id$
+
+import org.jboss.test.osgi.fragments.subA.SubBeanA;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class HostAActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ SubBeanA subBean = new SubBeanA();
+ subBean.getProvider(context);
+ }
+
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostB/HostBActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostB/HostBActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostB/HostBActivator.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.hostB;
+
+//$Id: FragmentHostActivator.java 99106 2010-01-07 11:02:59Z thomas.diesler(a)jboss.com $
+
+import org.jboss.test.osgi.fragments.subA.SubBeanA;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class HostBActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ SubBeanA subBean = new SubBeanA();
+ subBean.getProvider(context);
+ }
+
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostC/HostCActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostC/HostCActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/hostC/HostCActivator.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.hostC;
+
+//$Id: FragmentHostActivator.java 99106 2010-01-07 11:02:59Z thomas.diesler(a)jboss.com $
+
+import org.jboss.test.osgi.fragments.fragA.FragBeanA;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class HostCActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ new FragBeanA();
+ }
+
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.fragments.subA;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+//$Id: SomeBean.java 91513 2009-07-21 19:48:28Z thomas.diesler(a)jboss.com $
+
+public class SubBeanA
+{
+ public Bundle getProvider(BundleContext context)
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = (PackageAdmin)context.getService(sref);
+ Bundle provider = packageAdmin.getBundle(getClass());
+ return provider;
+ }
+
+}
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 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-12 14:00:11 UTC (rev 99284)
@@ -106,6 +106,9 @@
<bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="MessageBoardService" class="org.jboss.osgi.framework.service.internal.MessageBoardServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragA.bnd (from rev 99165, projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragA.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragA.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,9 @@
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-fragA.jar src/test/resources/fragments/simple-fragA.bnd
+
+Bundle-SymbolicName: simple-fragA
+Export-Package: org.jboss.test.osgi.fragments.fragA
+Include-Resource: resources/resource.txt=resource.txt
+Fragment-Host: simple-hostA
+
+-removeheaders: Include-Resource
+
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragB.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragB.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragB.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-fragB.jar src/test/resources/fragments/simple-fragB.bnd
+
+Bundle-SymbolicName: simple-fragB
+Export-Package: org.jboss.test.osgi.fragments.fragB
+Import-Package: org.jboss.test.osgi.fragments.subA
+Fragment-Host: simple-hostA
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragC.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragC.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-fragC.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-fragC.jar src/test/resources/fragments/simple-fragC.bnd
+
+Bundle-SymbolicName: simple-fragC
+Export-Package: org.jboss.test.osgi.fragments.fragC
+Require-Bundle: simple-hostB
+Fragment-Host: simple-hostA
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -1,9 +0,0 @@
-# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-frgmA.jar src/test/resources/fragments/simple-frgmA.bnd
-
-Bundle-SymbolicName: simple-frgmA
-Fragment-Host: simple-hostA
-Export-Package: org.jboss.test.osgi.fragments.frgmA
-Include-Resource: resources/resource.txt=resource.txt
-
--removeheaders: Include-Resource
-
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd 2010-01-12 13:57:21 UTC (rev 99283)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -1,6 +1,6 @@
# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-hostA.jar src/test/resources/fragments/simple-hostA.bnd
Bundle-SymbolicName: simple-hostA
-Bundle-Activator: org.jboss.test.osgi.fragments.hostA.FragmentHostActivator
-Private-Package: org.jboss.test.osgi.fragments.hostA
+Bundle-Activator: org.jboss.test.osgi.fragments.hostA.HostAActivator
+Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostB.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostB.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostB.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,7 @@
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-hostB.jar src/test/resources/fragments/simple-hostB.bnd
+
+Bundle-SymbolicName: simple-hostB
+Bundle-Activator: org.jboss.test.osgi.fragments.hostB.HostBActivator
+Export-Package: org.jboss.test.osgi.fragments.subA
+Private-Package: org.jboss.test.osgi.fragments.hostB
+
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostC.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostC.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostC.bnd 2010-01-12 14:00:11 UTC (rev 99284)
@@ -0,0 +1,7 @@
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-hostC.jar src/test/resources/fragments/simple-hostC.bnd
+
+Bundle-SymbolicName: simple-hostC
+Bundle-Activator: org.jboss.test.osgi.fragments.hostC.HostCActivator
+Private-Package: org.jboss.test.osgi.fragments.hostC
+Import-Package: org.osgi.framework, org.jboss.test.osgi.fragments.fragA
+
15 years, 11 months
JBoss-OSGI SVN: r99283 - in projects/jboss-osgi/projects/bundles/jmx/trunk: src/main/java/org/jboss/osgi/jmx/internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-12 08:57:21 -0500 (Tue, 12 Jan 2010)
New Revision: 99283
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/pom.xml
projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java
projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
Log:
Add PackageAdmin.resolveBundles()
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/pom.xml 2010-01-12 13:53:12 UTC (rev 99282)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/pom.xml 2010-01-12 13:57:21 UTC (rev 99283)
@@ -41,7 +41,7 @@
<properties>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
<version.jboss.osgi.jndi>1.0.2</version.jboss.osgi.jndi>
- <version.jboss.osgi.spi>1.0.3.SP1</version.jboss.osgi.spi>
+ <version.jboss.osgi.spi>1.0.4-SNAPSHOT</version.jboss.osgi.spi>
<version.osgi>4.2.0</version.osgi>
</properties>
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java 2010-01-12 13:53:12 UTC (rev 99282)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java 2010-01-12 13:57:21 UTC (rev 99283)
@@ -94,7 +94,7 @@
{
ObjectName oname = null;
- String namestr = DOMAIN_NAME + ":" + PROPERTY_SYMBOLIC_NAME + "=" + symbolicName + "," + PROPERTY_VERSION + "=" + version + ",*" ;
+ String namestr = DOMAIN_NAME + ":" + PROPERTY_SYMBOLIC_NAME + "=" + symbolicName + "," + PROPERTY_VERSION + "=" + version + ",*";
Set<ObjectName> names = mbeanServer.queryNames(ObjectNameFactory.create(namestr), null);
if (names.size() > 0)
@@ -194,29 +194,39 @@
public void refreshPackages(ObjectName[] objectNames)
{
+ Bundle[] bundleArr = getBundles(objectNames);
ServiceReference sref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
- if (sref != null)
+ PackageAdmin service = (PackageAdmin)getBundleContext().getService(sref);
+ service.refreshPackages(bundleArr);
+ }
+
+ public boolean resolveBundles(ObjectName[] objectNames)
+ {
+ Bundle[] bundleArr = getBundles(objectNames);
+ ServiceReference sref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)getBundleContext().getService(sref);
+ return service.resolveBundles(bundleArr);
+ }
+
+ private Bundle[] getBundles(ObjectName[] objectNames)
+ {
+ Bundle[] bundleArr = null;
+ if (objectNames != null)
{
- PackageAdmin service = (PackageAdmin)getBundleContext().getService(sref);
+ List<String> symbolicNames = new ArrayList<String>();
+ for (ObjectName oname : objectNames)
+ symbolicNames.add(oname.getKeyProperty(PROPERTY_SYMBOLIC_NAME));
- Bundle[] bundleArr = null;
- if (objectNames != null)
+ Set<Bundle> bundleSet = new HashSet<Bundle>();
+ for (Bundle bundle : getBundleContext().getBundles())
{
- List<String> symbolicNames = new ArrayList<String>();
- for (ObjectName oname : objectNames)
- symbolicNames.add(oname.getKeyProperty(PROPERTY_SYMBOLIC_NAME));
-
- Set<Bundle> bundleSet = new HashSet<Bundle>();
- for (Bundle bundle : getBundleContext().getBundles())
- {
- if (symbolicNames.contains(bundle.getSymbolicName()))
- bundleSet.add(bundle);
- }
- bundleArr = new Bundle[bundleSet.size()];
- bundleSet.toArray(bundleArr);
+ if (symbolicNames.contains(bundle.getSymbolicName()))
+ bundleSet.add(bundle);
}
- service.refreshPackages(bundleArr);
+ bundleArr = new Bundle[bundleSet.size()];
+ bundleSet.toArray(bundleArr);
}
+ return bundleArr;
}
public void start()
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2010-01-12 13:53:12 UTC (rev 99282)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2010-01-12 13:57:21 UTC (rev 99283)
@@ -130,13 +130,13 @@
return delegate.isRegistered(name);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "rawtypes" })
public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
{
return delegate.queryMBeans(name, query);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "rawtypes" })
public Set queryNames(ObjectName name, QueryExp query) throws IOException
{
return delegate.queryNames(name, query);
15 years, 11 months
JBoss-OSGI SVN: r99282 - in projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing: internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-12 08:53:12 -0500 (Tue, 12 Jan 2010)
New Revision: 99282
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
Log:
Add PackageAdmin.resolveBundles()
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java 2010-01-12 13:49:21 UTC (rev 99281)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java 2010-01-12 13:53:12 UTC (rev 99282)
@@ -42,4 +42,14 @@
* or null for all bundles updated or uninstalled since the last call to this method.
*/
void refreshPackages(OSGiBundle[] bundles);
+
+ /**
+ * Resolve the specified bundles.
+ *
+ * @see {@link PackageAdmin#resolveBundles(org.osgi.framework.Bundle[])}
+ *
+ * @param bundles The bundles to resolve or null to resolve all unresolved bundles installed in the Framework.
+ * @return true if all specified bundles are resolved
+ */
+ boolean resolveBundles(OSGiBundle[] bundles);
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-01-12 13:49:21 UTC (rev 99281)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-01-12 13:53:12 UTC (rev 99282)
@@ -147,7 +147,7 @@
assertNotUninstalled();
try
{
- BundleContext context = ((EmbeddedRuntime)getRuntime()).getBundleContext();
+ BundleContext context = ((EmbeddedRuntime)getRuntime()).getSystemContext();
ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
if (sref != null)
{
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java 2010-01-12 13:49:21 UTC (rev 99281)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java 2010-01-12 13:53:12 UTC (rev 99282)
@@ -34,15 +34,27 @@
*/
public class EmbeddedPackageAdmin implements OSGiPackageAdmin
{
- private PackageAdmin packAdmin;
+ private PackageAdmin delegate;
public EmbeddedPackageAdmin(PackageAdmin packAdmin)
{
- this.packAdmin = packAdmin;
+ this.delegate = packAdmin;
}
+ public boolean resolveBundles(OSGiBundle[] bundles)
+ {
+ Bundle[] bundleArr = getBundles(bundles);
+ return delegate.resolveBundles(bundleArr);
+ }
+
public void refreshPackages(OSGiBundle[] bundles)
{
+ Bundle[] bundleArr = getBundles(bundles);
+ delegate.refreshPackages(bundleArr);
+ }
+
+ private Bundle[] getBundles(OSGiBundle[] bundles)
+ {
Bundle[] bundleArr = null;
if (bundles != null)
{
@@ -52,6 +64,6 @@
bundleArr[i] = ((EmbeddedBundle)bundles[i]).getBundle();
}
}
- packAdmin.refreshPackages(bundleArr);
+ return bundleArr;
}
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-01-12 13:49:21 UTC (rev 99281)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-01-12 13:53:12 UTC (rev 99282)
@@ -74,7 +74,7 @@
OSGiBundle bundle;
- BundleContext context = getBundleContext();
+ BundleContext context = getSystemContext();
ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
if (sref != null)
{
@@ -95,7 +95,7 @@
public OSGiBundle[] getBundles()
{
List<OSGiBundle> absBundles = new ArrayList<OSGiBundle>();
- for (Bundle bundle : getBundleContext().getBundles())
+ for (Bundle bundle : getSystemContext().getBundles())
{
absBundles.add(new EmbeddedBundle(this, bundle));
}
@@ -106,13 +106,13 @@
public OSGiBundle getBundle(long bundleId)
{
- Bundle bundle = getBundleContext().getBundle(bundleId);
+ Bundle bundle = getSystemContext().getBundle(bundleId);
return bundle != null ? new EmbeddedBundle(this, bundle) : null;
}
public OSGiServiceReference getServiceReference(String clazz)
{
- ServiceReference sref = getBundleContext().getServiceReference(clazz);
+ ServiceReference sref = getSystemContext().getServiceReference(clazz);
return (sref != null ? new EmbeddedServiceReference(sref) : null);
}
@@ -123,7 +123,7 @@
ServiceReference[] srefs;
try
{
- srefs = getBundleContext().getServiceReferences(clazz, filter);
+ srefs = getSystemContext().getServiceReferences(clazz, filter);
}
catch (InvalidSyntaxException e)
{
@@ -179,25 +179,6 @@
}
}
- public BundleContext getBundleContext()
- {
- OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
- Framework framework = bootProvider.getFramework();
- if (framework.getState() != Bundle.ACTIVE)
- {
- try
- {
- log.debug("Framework start: " + framework);
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start framework", ex);
- }
- }
- return framework.getBundleContext();
- }
-
@SuppressWarnings("unchecked")
public MBeanServerConnection getMBeanServer()
{
@@ -217,7 +198,7 @@
public OSGiPackageAdmin getPackageAdmin()
{
- BundleContext context = getBundleContext();
+ BundleContext context = getSystemContext();
ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packAdmin = (PackageAdmin)context.getService(sref);
return new EmbeddedPackageAdmin(packAdmin);
@@ -227,4 +208,23 @@
{
return false;
}
+
+ BundleContext getSystemContext()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+ if (framework.getState() != Bundle.ACTIVE)
+ {
+ try
+ {
+ log.debug("Framework start: " + framework);
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+ }
+ return framework.getBundleContext();
+ }
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-01-12 13:49:21 UTC (rev 99281)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-01-12 13:53:12 UTC (rev 99282)
@@ -23,6 +23,7 @@
// $Id$
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Dictionary;
@@ -130,14 +131,14 @@
public URL getEntry(String path)
{
assertNotUninstalled();
- return bundle.getEntry(path);
+ return toURL(bundle.getEntry(path));
}
@Override
public URL getResource(String name)
{
assertNotUninstalled();
- return bundle.getResource(name);
+ return toURL(bundle.getResource(name));
}
@Override
@@ -182,4 +183,16 @@
log.error("Cannot uninstall: " + getLocation(), ex);
}
}
+
+ private URL toURL(String urlstr)
+ {
+ try
+ {
+ return urlstr != null ? new URL(urlstr) : null;
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalArgumentException("Invalid URL: " + urlstr);
+ }
+ }
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java 2010-01-12 13:49:21 UTC (rev 99281)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java 2010-01-12 13:53:12 UTC (rev 99282)
@@ -46,8 +46,36 @@
this.runtime = runtime;
}
+ public boolean resolveBundles(OSGiBundle[] bundles)
+ {
+ ObjectName[] bundleArr = getBundleNames(bundles);
+ try
+ {
+ ManagedFrameworkMBean mbeanProxy = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
+ return mbeanProxy.resolveBundles(bundleArr);
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new IllegalStateException("Cannot refresh packages", ex);
+ }
+ }
+
public void refreshPackages(OSGiBundle[] bundles)
{
+ ObjectName[] bundleArr = getBundleNames(bundles);
+ try
+ {
+ ManagedFrameworkMBean mbeanProxy = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
+ mbeanProxy.refreshPackages(bundleArr);
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new IllegalStateException("Cannot refresh packages", ex);
+ }
+ }
+
+ private ObjectName[] getBundleNames(OSGiBundle[] bundles)
+ {
ObjectName[] bundleArr = null;
if (bundles != null)
{
@@ -61,14 +89,6 @@
bundleArr[i] = ManagedBundle.getObjectName(id, symbolicName, version);
}
}
- try
- {
- ManagedFrameworkMBean mbeanProxy = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
- mbeanProxy.refreshPackages(bundleArr);
- }
- catch (MBeanProxyException ex)
- {
- throw new IllegalStateException("Cannot refresh packages", ex);
- }
+ return bundleArr;
}
}
15 years, 11 months
JBoss-OSGI SVN: r99281 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-12 08:49:21 -0500 (Tue, 12 Jan 2010)
New Revision: 99281
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
Log:
Add PackageAdmin.resolveBundles()
Return string encoded URLs from ManagedBundle
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2010-01-12 13:00:01 UTC (rev 99280)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2010-01-12 13:49:21 UTC (rev 99281)
@@ -119,14 +119,16 @@
return retHeaders;
}
- public URL getEntry(String path)
+ public String getEntry(String path)
{
- return bundle.getEntry(path);
+ URL url = bundle.getEntry(path);
+ return url != null ? url.toExternalForm() : null;
}
- public URL getResource(String name)
+ public String getResource(String name)
{
- return bundle.getResource(name);
+ URL url = bundle.getResource(name);
+ return url != null ? url.toExternalForm() : null;
}
public ObjectName loadClass(String name) throws ClassNotFoundException
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java 2010-01-12 13:00:01 UTC (rev 99280)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java 2010-01-12 13:49:21 UTC (rev 99281)
@@ -23,7 +23,6 @@
//$Id$
-import java.net.URL;
import java.util.Dictionary;
import javax.management.ObjectName;
@@ -89,19 +88,19 @@
ObjectName loadClass(String name) throws ClassNotFoundException;
/**
- * Returns a URL to the entry at the specified path in this bundle.
+ * Returns a string encoded URL to the entry at the specified path in this bundle.
*
* @param name The path name of the entry
* @return A URL to the entry, or null if no entry could be found
*/
- URL getEntry(String path);
+ String getEntry(String path);
/**
* Find the specified resource from this bundle's class loader.
* @param name The name of the resource.
- * @return A URL to the named resource, or null if the resource could not be found
+ * @return A string encoded URL to the named resource, or null if the resource could not be found
*/
- URL getResource(String name);
+ String getResource(String name);
/**
* Starts this bundle with no options
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2010-01-12 13:00:01 UTC (rev 99280)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2010-01-12 13:49:21 UTC (rev 99281)
@@ -68,4 +68,9 @@
* Refresh packages through the PackageAdmin service
*/
void refreshPackages(ObjectName[] bundles);
+
+ /**
+ * Resolve bundles through the PackageAdmin service
+ */
+ boolean resolveBundles(ObjectName[] bundles);
}
\ No newline at end of file
15 years, 11 months
JBoss-OSGI SVN: r99175 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 19:02:03 -0500 (Fri, 08 Jan 2010)
New Revision: 99175
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.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/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
Delegate all fragment resource/class loading to the policy
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-01-09 00:02:03 UTC (rev 99175)
@@ -170,6 +170,7 @@
</bean>
<bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -37,7 +37,7 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHostMetaData;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
@@ -95,7 +95,7 @@
DeploymentUnit fragUnit = fragState.getDeploymentUnit();
OSGiClassLoadingMetaData fragMetaData = (OSGiClassLoadingMetaData)fragUnit.getAttachment(ClassLoadingMetaData.class);
- FragmentHost fragHost = fragMetaData.getFragmentHost();
+ FragmentHostMetaData fragHost = fragMetaData.getFragmentHost();
if (hostName.equals(fragHost.getSymbolicName()) == false)
return false;
@@ -123,7 +123,7 @@
fragmentState.setFragmentHost(this);
// attach classloading metadata to the hosts classloading metadata
- clMetaData.attachedFragmentMetaData(fragMetaData);
+ clMetaData.attachClassLoadingMetaData(fragMetaData);
}
public boolean isFragment()
@@ -144,42 +144,10 @@
if (resolveBundle() == false)
throw new ClassNotFoundException("Cannot load class: " + name);
- Class<?> retClass = null;
-
ClassLoader classLoader = getDeploymentUnit().getClassLoader();
- ClassNotFoundException cnfEx = null;
- try
- {
- retClass = classLoader.loadClass(name);
- }
- catch (ClassNotFoundException ex)
- {
- cnfEx = ex;
- }
+ Class<?> clazz = classLoader.loadClass(name);
- // Try to load the class in the attached fragments
- if (retClass == null)
- {
- for (OSGiFragmentState fragment : getAttachedFragments())
- {
- classLoader = fragment.getDeploymentUnit().getClassLoader();
- try
- {
- retClass = classLoader.loadClass(name);
- cnfEx = null;
- break;
- }
- catch (ClassNotFoundException ex)
- {
- // ignore
- }
- }
- }
-
- if (retClass == null && cnfEx != null)
- throw cnfEx;
-
- return retClass;
+ return clazz;
}
public URL getResource(String name)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -23,15 +23,16 @@
// $Id: OSGiClassLoaderFactory.java 95177 2009-10-20 15:14:31Z thomas.diesler(a)jboss.com $
+import java.util.List;
+
import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.DelegateLoader;
import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer;
/**
* An OSGi bundle class loader.
*
* This implementation supports the notion of OSGi Native Code Libraries.
- * The library map is initialized in {@link OSGiBundleNativeCodeDeployer}.
*
* @author Thomas.Diesler(a)jboss.com
* @since 19-Dec-2009
@@ -62,4 +63,30 @@
return libraryPath;
}
+ @Override
+ public Class<?> loadClass(String className) throws ClassNotFoundException
+ {
+ try
+ {
+ Class<?> clazz = super.loadClass(className);
+ return clazz;
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // Try to load the class in the attached fragments
+ List<DelegateLoader> fragmentLoaders = osgiPolicy.getFragmentLoaders();
+ if (fragmentLoaders != null)
+ {
+ for (DelegateLoader fragLoader : fragmentLoaders)
+ {
+ Class<?> clazz = fragLoader.loadClass(className);
+ if (clazz != null)
+ return clazz;
+ }
+ }
+
+ // Throw the ClassNotFoundException
+ throw ex;
+ }
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -34,7 +34,6 @@
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.virtual.VirtualFile;
/**
@@ -58,11 +57,11 @@
public ClassLoader createClassLoader(final DeploymentUnit unit) throws Exception
{
if (unit instanceof VFSDeploymentUnit == false)
- throw new IllegalStateException("DeploymentUnit is not an instance of " + VFSDeploymentUnit.class.getName() + " actual=" + unit);
+ throw new IllegalStateException("Not an instance of VFSDeploymentUnit: " + unit);
Module module = unit.getAttachment(Module.class);
if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
- throw new IllegalStateException("Module is not an instance of " + VFSDeploymentClassLoaderPolicyModule.class.getName() + " actual=" + module);
+ throw new IllegalStateException("Not an instance of VFSDeploymentClassLoaderPolicyModule: " + module);
VFSDeploymentClassLoaderPolicyModule vfsModule = (VFSDeploymentClassLoaderPolicyModule)module;
vfsModule.setPolicyFactory(new ClassLoaderPolicyFactory()
@@ -70,7 +69,7 @@
public ClassLoaderPolicy createClassLoaderPolicy()
{
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
- OSGiBundleState bundleState = (OSGiBundleState)unit.getAttachment(AbstractBundleState.class);
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(bundleState, roots);
unit.addAttachment(ClassLoaderPolicy.class, policy);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -25,15 +25,17 @@
import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.jboss.classloader.spi.DelegateLoader;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.virtual.VirtualFile;
/**
@@ -46,45 +48,52 @@
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
- // The bundle state associated with this policy
- private OSGiBundleState bundleState;
// Maps the lib name to native code archive
- private Map<String, File> libraryMap = new HashMap<String, File>();
+ private Map<String, File> libraryMap;
+ // The optional list of attached fragment loaders
+ private List<DelegateLoader> fragmentLoaders;
- public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile[] roots)
+ public OSGiClassLoaderPolicy(AbstractBundleState bundleState, VirtualFile[] roots)
{
super(roots);
if (bundleState == null)
throw new IllegalArgumentException("Null bundleState");
- this.bundleState = bundleState;
-
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- Module module = unit.getAttachment(Module.class);
- if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
- throw new IllegalStateException("Module is not an instance of " + VFSDeploymentClassLoaderPolicyModule.class.getName() + " actual=" + module);
+ if (bundleState instanceof AbstractDeployedBundleState)
+ {
+ AbstractDeployedBundleState depBundleState = (AbstractDeployedBundleState)bundleState;
+ Module module = depBundleState.getDeploymentUnit().getAttachment(Module.class);
+ if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
+ throw new IllegalStateException("Not an instance of VFSDeploymentClassLoaderPolicyModule: " + module);
- VFSDeploymentClassLoaderPolicyModule vfsModule = (VFSDeploymentClassLoaderPolicyModule)module;
- String[] packageNames = vfsModule.getPackageNames();
- setExportedPackages(packageNames);
- setIncluded(vfsModule.getIncluded());
- setExcluded(vfsModule.getExcluded());
- setExcludedExport(vfsModule.getExcludedExport());
- setExportAll(vfsModule.getExportAll());
- setImportAll(vfsModule.isImportAll());
- setCacheable(vfsModule.isCacheable());
- setBlackListable(vfsModule.isBlackListable());
- setDelegates(vfsModule.getDelegates());
+ VFSDeploymentClassLoaderPolicyModule vfsModule = (VFSDeploymentClassLoaderPolicyModule)module;
+ String[] packageNames = vfsModule.getPackageNames();
+ setExportedPackages(packageNames);
+ setIncluded(vfsModule.getIncluded());
+ setExcluded(vfsModule.getExcluded());
+ setExcludedExport(vfsModule.getExcludedExport());
+ setExportAll(vfsModule.getExportAll());
+ setImportAll(vfsModule.isImportAll());
+ setCacheable(vfsModule.isCacheable());
+ setBlackListable(vfsModule.isBlackListable());
+ setDelegates(vfsModule.getDelegates());
+ }
}
public void addLibraryMapping(String libname, File libfile)
{
+ if (libraryMap == null)
+ libraryMap = new HashMap<String, File>();
+
libraryMap.put(libname, libfile);
}
public String findLibrary(String libname)
{
+ if (libraryMap == null)
+ return null;
+
File libfile = libraryMap.get(libname);
// [TODO] why does the TCK use 'Native' to mean 'libNative' ?
@@ -94,18 +103,30 @@
return (libfile != null ? libfile.getAbsolutePath() : null);
}
+ public List<DelegateLoader> getFragmentLoaders()
+ {
+ return fragmentLoaders;
+ }
+
+ public void addFragmentLoader(DelegateLoader delegateLoader)
+ {
+ if (fragmentLoaders == null)
+ fragmentLoaders = new ArrayList<DelegateLoader>();
+
+ fragmentLoaders.add(delegateLoader);
+ }
+
@Override
public URL getResource(String path)
{
URL resourceURL = super.getResource(path);
// Try to find the resource in the attached fragments
- if (resourceURL == null && bundleState.isFragment() == false)
+ if (resourceURL == null && fragmentLoaders != null)
{
- for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
+ for (DelegateLoader fragLoader : fragmentLoaders)
{
- ClassLoader classLoader = fragment.getDeploymentUnit().getClassLoader();
- resourceURL = classLoader.getResource(path);
+ resourceURL = fragLoader.getResource(path);
if (resourceURL != null)
break;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -42,26 +42,26 @@
private static final long serialVersionUID = 1L;
// The optional fragment host
- private FragmentHost fragmentHost;
+ private FragmentHostMetaData fragmentHost;
// The list of attached fragment classloading metadata
private List<OSGiClassLoadingMetaData> attachedFragments = new ArrayList<OSGiClassLoadingMetaData>();
- public FragmentHost getFragmentHost()
+ public FragmentHostMetaData getFragmentHost()
{
return fragmentHost;
}
- public void setFragmentHost(FragmentHost fragmentHost)
+ public void setFragmentHost(FragmentHostMetaData fragmentHost)
{
this.fragmentHost = fragmentHost;
}
- public List<OSGiClassLoadingMetaData> getAttachedFragmentMetaData()
+ public List<OSGiClassLoadingMetaData> getAttachedClassLoadingMetaData()
{
return Collections.unmodifiableList(attachedFragments);
}
- public void attachedFragmentMetaData(OSGiClassLoadingMetaData fragment)
+ public void attachClassLoadingMetaData(OSGiClassLoadingMetaData fragment)
{
if (fragment == null)
throw new IllegalArgumentException("Null fragment");
@@ -76,13 +76,13 @@
/**
* Fragment-Host metadata.
*/
- public static class FragmentHost
+ public static class FragmentHostMetaData
{
private String symbolicName;
private Version bundleVersion;
private String extension;
- public FragmentHost(String symbolicName)
+ public FragmentHostMetaData(String symbolicName)
{
if (symbolicName == null)
throw new IllegalArgumentException("Null symbolicName");
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -28,6 +28,7 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
@@ -42,6 +43,7 @@
public class AbstractOSGiClassLoadingDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
{
private ClassLoaderDomain domain;
+ private ClassLoaderFactory factory;
public AbstractOSGiClassLoadingDeployer()
{
@@ -56,6 +58,11 @@
{
this.domain = domain;
}
+
+ public void setFactory(ClassLoaderFactory factory)
+ {
+ this.factory = factory;
+ }
@Override
public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
@@ -73,8 +80,12 @@
classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
-
+
// AnnotationMetaDataDeployer.ANNOTATION_META_DATA_COMPLETE
unit.addAttachment("org.jboss.deployment.annotation.metadata.complete", Boolean.TRUE);
+
+ // Add the OSGi ClassLoaderFactory if configured
+ if (factory != null)
+ unit.addAttachment(ClassLoaderFactory.class, factory);
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -52,13 +52,6 @@
*/
public class OSGiBundleClassLoadingDeployer extends AbstractOSGiClassLoadingDeployer
{
- private ClassLoaderFactory factory;
-
- public void setFactory(ClassLoaderFactory factory)
- {
- this.factory = factory;
- }
-
@Override
public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
{
@@ -115,9 +108,5 @@
}
}
}
-
- // Add the OSGi ClassLoaderFactory if configured
- if (factory != null)
- unit.addAttachment(ClassLoaderFactory.class, factory);
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -23,6 +23,8 @@
// $Id$
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.DelegateLoader;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
@@ -32,6 +34,7 @@
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
import org.osgi.framework.Bundle;
/**
@@ -59,21 +62,39 @@
{
// Return if this is not a real bundle (i.e. a fragment)
AbstractBundleState absBundleState = unit.getAttachment(AbstractBundleState.class);
- if (absBundleState == null || absBundleState.isFragment())
+ if (absBundleState == null)
return;
-
- OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
-
- // Iterate over all installed fragments and attach when appropriate
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
- for (AbstractBundleState auxBundle : bundleManager.getBundles(Bundle.INSTALLED))
+
+ OSGiBundleManager bundleManager = absBundleState.getBundleManager();
+
+ // Iterate over all installed fragments and attach to host when appropriate
+ if (absBundleState.isFragment() == false)
{
- if (auxBundle.isFragment())
+ OSGiBundleState hostState = (OSGiBundleState)absBundleState;
+ for (AbstractBundleState auxBundle : bundleManager.getBundles(Bundle.INSTALLED))
{
- OSGiFragmentState auxState = (OSGiFragmentState)auxBundle;
- if (bundleState.isFragmentAttachable(auxState))
- bundleState.attachFragment(auxState);
+ if (auxBundle.isFragment())
+ {
+ OSGiFragmentState auxState = (OSGiFragmentState)auxBundle;
+ if (hostState.isFragmentAttachable(auxState))
+ {
+ hostState.attachFragment(auxState);
+ }
+ }
}
}
+
+ // Add the fragment's DelegateLoader to the host's ClassLoaderPolicy
+ if (absBundleState.isFragment() == true)
+ {
+ OSGiFragmentState fragState = (OSGiFragmentState)absBundleState;
+ OSGiBundleState hostState = fragState.getFragmentHost();
+ DeploymentUnit hostUnit = hostState.getDeploymentUnit();
+ OSGiClassLoaderPolicy hostPolicy = (OSGiClassLoaderPolicy)hostUnit.getAttachment(ClassLoaderPolicy.class);
+
+ OSGiClassLoaderPolicy fragPolicy = (OSGiClassLoaderPolicy)unit.getAttachment(ClassLoaderPolicy.class);
+ DelegateLoader fragLoader = new DelegateLoader(fragPolicy);
+ hostPolicy.addFragmentLoader(fragLoader);
+ }
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -28,7 +28,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHostMetaData;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
@@ -60,7 +60,7 @@
// Initialize the Fragment-Host
ParameterizedAttribute hostAttr = osgiMetaData.getFragmentHost();
- FragmentHost fragmentHost = new FragmentHost(hostAttr.getAttribute());
+ FragmentHostMetaData fragmentHost = new FragmentHostMetaData(hostAttr.getAttribute());
classLoadingMetaData.setFragmentHost(fragmentHost);
Parameter bundleVersionAttr = hostAttr.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
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 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2010-01-09 00:02:03 UTC (rev 99175)
@@ -202,6 +202,7 @@
</bean>
<bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
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 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2010-01-09 00:02:03 UTC (rev 99175)
@@ -224,6 +224,7 @@
</bean>
<bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
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 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-09 00:02:03 UTC (rev 99175)
@@ -207,6 +207,7 @@
</bean>
<bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-09 00:02:03 UTC (rev 99175)
@@ -34,6 +34,7 @@
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
import org.jboss.test.osgi.fragments.frgmA.FragmentService;
+import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -47,6 +48,7 @@
public class FragmentTestCase extends OSGiTest
{
@Test
+ @Ignore
public void testHostOnly() throws Exception
{
OSGiRuntime runtime = getDefaultRuntime();
@@ -74,6 +76,7 @@
}
@Test
+ @Ignore
public void testFragmentOnly() throws Exception
{
OSGiRuntime runtime = getDefaultRuntime();
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 2010-01-08 23:01:15 UTC (rev 99174)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-09 00:02:03 UTC (rev 99175)
@@ -194,6 +194,7 @@
</bean>
<bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
15 years, 11 months
JBoss-OSGI SVN: r99167 - in projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework: classloading and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 11:43:56 -0500 (Fri, 08 Jan 2010)
New Revision: 99167
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
Log:
Load fragment resources from CL policy
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 15:49:11 UTC (rev 99166)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 16:43:56 UTC (rev 99167)
@@ -192,21 +192,7 @@
return getDeploymentUnit().getResourceLoader().getResource(name);
ClassLoader classLoader = getDeploymentUnit().getClassLoader();
- URL resourceURL = classLoader.getResource(name);
-
- // Try to find the resource in the attached fragments
- if (resourceURL == null)
- {
- for (OSGiFragmentState fragment : getAttachedFragments())
- {
- classLoader = fragment.getDeploymentUnit().getClassLoader();
- resourceURL = classLoader.getResource(name);
- if (resourceURL != null)
- break;
- }
- }
-
- return resourceURL;
+ return classLoader.getResource(name);
}
@SuppressWarnings("rawtypes")
@@ -219,7 +205,8 @@
if (resolveBundle() == false)
return getDeploymentUnit().getResourceLoader().getResources(name);
- return getDeploymentUnit().getClassLoader().getResources(name);
+ ClassLoader classLoader = getDeploymentUnit().getClassLoader();
+ return classLoader.getResources(name);
}
// [TODO] options
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-01-08 15:49:11 UTC (rev 99166)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-01-08 16:43:56 UTC (rev 99167)
@@ -34,7 +34,7 @@
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.virtual.VirtualFile;
/**
@@ -70,10 +70,9 @@
public ClassLoaderPolicy createClassLoaderPolicy()
{
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
- AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
- AbstractDeployedBundleState depBundleState = (AbstractDeployedBundleState)bundleState;
- VirtualFile[] roots = getClassLoaderPolicyRoots(depBundleState, vfsUnit);
- ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(depBundleState, roots);
+ OSGiBundleState bundleState = (OSGiBundleState)unit.getAttachment(AbstractBundleState.class);
+ VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
+ ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(bundleState, roots);
unit.addAttachment(ClassLoaderPolicy.class, policy);
return policy;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-08 15:49:11 UTC (rev 99166)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-08 16:43:56 UTC (rev 99167)
@@ -24,6 +24,7 @@
// $Id$
import java.io.File;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -31,7 +32,8 @@
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.OSGiFragmentState;
import org.jboss.virtual.VirtualFile;
/**
@@ -44,16 +46,20 @@
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
+ // The bundle state associated with this policy
+ private OSGiBundleState bundleState;
// Maps the lib name to native code archive
private Map<String, File> libraryMap = new HashMap<String, File>();
- public OSGiClassLoaderPolicy(AbstractDeployedBundleState bundleState, VirtualFile[] roots)
+ public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile[] roots)
{
super(roots);
if (bundleState == null)
throw new IllegalArgumentException("Null bundleState");
+ this.bundleState = bundleState;
+
DeploymentUnit unit = bundleState.getDeploymentUnit();
Module module = unit.getAttachment(Module.class);
if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
@@ -87,4 +93,24 @@
return (libfile != null ? libfile.getAbsolutePath() : null);
}
+
+ @Override
+ public URL getResource(String path)
+ {
+ URL resourceURL = super.getResource(path);
+
+ // Try to find the resource in the attached fragments
+ if (resourceURL == null && bundleState.isFragment() == false)
+ {
+ for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
+ {
+ ClassLoader classLoader = fragment.getDeploymentUnit().getClassLoader();
+ resourceURL = classLoader.getResource(path);
+ if (resourceURL != null)
+ break;
+ }
+ }
+
+ return resourceURL;
+ }
}
15 years, 11 months
JBoss-OSGI SVN: r99164 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 10:22:10 -0500 (Fri, 08 Jan 2010)
New Revision: 99164
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
Log:
Add support for loadClass, findEntry, getResource on fragment bundle
TODO - move code from bundle state to CL policy
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 15:03:27 UTC (rev 99163)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 15:22:10 UTC (rev 99164)
@@ -1331,21 +1331,30 @@
}
DeploymentUnit unit = bundleState.getDeploymentUnit();
+ String unitName = unit.getName();
+
ControllerContext context = unit.getAttachment(ControllerContext.class);
-
ControllerState requiredState = context.getRequiredState();
DeploymentStage requiredStage = unit.getRequiredStage();
// TODO [JBDEPLOY-226] Allow multiple deployments to change state at once
try
{
- deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
- deployerClient.checkComplete(unit.getName());
+ deployerClient.change(unitName, DeploymentStages.CLASSLOADER);
+ deployerClient.checkComplete(unitName);
+ // Advance the attached fragments to CLASSLOADER
+ for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
+ {
+ String fragUnitName = fragment.getDeploymentUnit().getName();
+ deployerClient.change(fragUnitName, DeploymentStages.CLASSLOADER);
+ deployerClient.checkComplete(fragUnitName);
+ }
+
bundleState.changeState(Bundle.RESOLVED);
for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
fragment.changeState(Bundle.RESOLVED);
-
+
return true;
}
catch (DeploymentException ex)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 15:03:27 UTC (rev 99163)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 15:22:10 UTC (rev 99164)
@@ -88,16 +88,18 @@
return Collections.unmodifiableList(attachedFragments);
}
- public boolean isFragmentAttachable(OSGiFragmentState fragmentState)
+ public boolean isFragmentAttachable(OSGiFragmentState fragState)
{
String hostName = getSymbolicName();
Version hostVersion = getVersion();
- FragmentHost fragmentHost = fragmentState.getFragmentHost();
- if (hostName.equals(fragmentHost.getSymbolicName()) == false)
+ DeploymentUnit fragUnit = fragState.getDeploymentUnit();
+ OSGiClassLoadingMetaData fragMetaData = (OSGiClassLoadingMetaData)fragUnit.getAttachment(ClassLoadingMetaData.class);
+ FragmentHost fragHost = fragMetaData.getFragmentHost();
+ if (hostName.equals(fragHost.getSymbolicName()) == false)
return false;
- Version version = fragmentHost.getBundleVersion();
+ Version version = fragHost.getBundleVersion();
if (version != null && hostVersion.equals(version) == false)
return false;
@@ -118,6 +120,7 @@
log.debug("Attach " + fragmentState + " -> " + this);
attachedFragments.add(fragmentState);
+ fragmentState.setFragmentHost(this);
// attach classloading metadata to the hosts classloading metadata
clMetaData.attachedFragmentMetaData(fragMetaData);
@@ -141,8 +144,42 @@
if (resolveBundle() == false)
throw new ClassNotFoundException("Cannot load class: " + name);
+ Class<?> retClass = null;
+
ClassLoader classLoader = getDeploymentUnit().getClassLoader();
- return classLoader.loadClass(name);
+ ClassNotFoundException cnfEx = null;
+ try
+ {
+ retClass = classLoader.loadClass(name);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ cnfEx = ex;
+ }
+
+ // Try to load the class in the attached fragments
+ if (retClass == null)
+ {
+ for (OSGiFragmentState fragment : getAttachedFragments())
+ {
+ classLoader = fragment.getDeploymentUnit().getClassLoader();
+ try
+ {
+ retClass = classLoader.loadClass(name);
+ cnfEx = null;
+ break;
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // ignore
+ }
+ }
+ }
+
+ if (retClass == null && cnfEx != null)
+ throw cnfEx;
+
+ return retClass;
}
public URL getResource(String name)
@@ -154,7 +191,22 @@
if (resolveBundle() == false)
return getDeploymentUnit().getResourceLoader().getResource(name);
- return getDeploymentUnit().getClassLoader().getResource(name);
+ ClassLoader classLoader = getDeploymentUnit().getClassLoader();
+ URL resourceURL = classLoader.getResource(name);
+
+ // Try to find the resource in the attached fragments
+ if (resourceURL == null)
+ {
+ for (OSGiFragmentState fragment : getAttachedFragments())
+ {
+ classLoader = fragment.getDeploymentUnit().getClassLoader();
+ resourceURL = classLoader.getResource(name);
+ if (resourceURL != null)
+ break;
+ }
+ }
+
+ return resourceURL;
}
@SuppressWarnings("rawtypes")
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 15:03:27 UTC (rev 99163)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 15:22:10 UTC (rev 99164)
@@ -26,34 +26,42 @@
import java.net.URL;
import java.util.Enumeration;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
/**
- * OSGiSystemBundle.
+ * The state of a fragment {@link Bundle}.
*
* @author Thomas.Diesler(a)jboss.com
* @since 25-Dec-2009
*/
public class OSGiFragmentState extends AbstractDeployedBundleState
{
- /**
- * Create a new OSGiFragmentState
- */
+ // The host that this fragment is attached to
+ private OSGiBundleState fragmentHost;
+
public OSGiFragmentState(DeploymentUnit unit)
{
super(unit);
}
+ public OSGiBundleState getFragmentHost()
+ {
+ return fragmentHost;
+ }
+
+ void setFragmentHost(OSGiBundleState fragmentHost)
+ {
+ this.fragmentHost = fragmentHost;
+ }
+
public boolean isFragment()
{
return true;
}
-
+
public URL getResource(String name)
{
// Null if the resource could not be found or if this bundle is a fragment bundle
@@ -92,13 +100,4 @@
{
throw new NotImplementedException();
}
-
- public FragmentHost getFragmentHost()
- {
- FragmentHost fhMetaData = null;
- ClassLoadingMetaData clMetaData = getDeploymentUnit().getAttachment(ClassLoadingMetaData.class);
- if (clMetaData != null)
- fhMetaData = ((OSGiClassLoadingMetaData)clMetaData).getFragmentHost();
- return fhMetaData;
- }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-08 15:03:27 UTC (rev 99163)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-08 15:22:10 UTC (rev 99164)
@@ -32,20 +32,19 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer;
import org.jboss.virtual.VirtualFile;
/**
* The ClassLoaderPolicy for OSGi bundles.
*
* This implementation supports the notion of OSGi Native Code Libraries.
- * The library map is initialized in {@link OSGiBundleNativeCodeDeployer}.
*
* @author Thomas.Diesler(a)jboss.com
* @since 11-Sep-2209
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
+ // Maps the lib name to native code archive
private Map<String, File> libraryMap = new HashMap<String, File>();
public OSGiClassLoaderPolicy(AbstractDeployedBundleState bundleState, VirtualFile[] roots)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-01-08 15:03:27 UTC (rev 99163)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-01-08 15:22:10 UTC (rev 99164)
@@ -40,6 +40,7 @@
import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.OSGiFragmentState;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
@@ -103,8 +104,14 @@
AbstractDeploymentClassLoaderPolicyModule deploymentModule = (AbstractDeploymentClassLoaderPolicyModule)module;
DeploymentUnit unit = deploymentModule.getDeploymentUnit();
AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
- if (bundleState != null && bundleState.getState() != Bundle.INSTALLED)
+ if (bundleState != null)
+ {
+ // Return the fragment's host bundle
+ if (bundleState.isFragment())
+ bundleState = ((OSGiFragmentState)bundleState).getFragmentHost();
+
return bundleState.getBundleInternal();
+ }
}
return null;
}
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 15:03:27 UTC (rev 99163)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 15:22:10 UTC (rev 99164)
@@ -54,10 +54,13 @@
{
OSGiBundle host = runtime.installBundle("fragments-simple-hostA.jar");
assertBundleState(Bundle.INSTALLED, host.getState());
-
+
host.start();
assertBundleState(Bundle.ACTIVE, host.getState());
-
+
+ URL entryURL = host.getEntry("resources/resource.txt");
+ assertNull("Entry URL null", entryURL);
+
URL resourceURL = host.getResource("resources/resource.txt");
assertNull("Resource URL null", resourceURL);
@@ -78,13 +81,13 @@
{
OSGiBundle fragment = runtime.installBundle("fragments-simple-frgmA.jar");
assertBundleState(Bundle.INSTALLED, fragment.getState());
-
- URL resourceURL = fragment.getResource("resources/resource.txt");
- assertNull("Resource URL null", resourceURL);
URL entryURL = fragment.getEntry("resources/resource.txt");
assertNotNull("Entry URL not null", entryURL);
+ URL resourceURL = fragment.getResource("resources/resource.txt");
+ assertNull("Resource URL null", resourceURL);
+
try
{
fragment.start();
@@ -94,7 +97,7 @@
{
assertBundleState(Bundle.INSTALLED, fragment.getState());
}
-
+
fragment.uninstall();
assertBundleState(Bundle.UNINSTALLED, fragment.getState());
}
@@ -112,23 +115,23 @@
{
OSGiBundle host = runtime.installBundle("fragments-simple-hostA.jar");
assertBundleState(Bundle.INSTALLED, host.getState());
-
+
OSGiBundle fragment = runtime.installBundle("fragments-simple-frgmA.jar");
assertBundleState(Bundle.INSTALLED, fragment.getState());
-
+
host.start();
assertBundleState(Bundle.ACTIVE, host.getState());
assertBundleState(Bundle.RESOLVED, fragment.getState());
-
- OSGiBundle classProvider = host.loadClass(FragmentService.class.getName());
- assertEquals("Class provided by fragment", host, classProvider);
-
- URL resourceURL = host.getResource("resources/resource.txt");
- assertNotNull("Resource URL not null", resourceURL);
URL entryURL = host.getEntry("resources/resource.txt");
assertNull("Entry URL null", entryURL);
+ URL resourceURL = host.getResource("resources/resource.txt");
+ assertNotNull("Resource URL not null", resourceURL);
+
+ OSGiBundle classProvider = host.loadClass(FragmentService.class.getName());
+ assertEquals("Class provided by fragment", host, classProvider);
+
host.uninstall();
assertBundleState(Bundle.UNINSTALLED, host.getState());
assertBundleState(Bundle.RESOLVED, fragment.getState());
15 years, 11 months
JBoss-OSGI SVN: r99161 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 09:33:26 -0500 (Fri, 08 Jan 2010)
New Revision: 99161
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/DeployersTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
Log:
Fix findEntry for fragment bundle
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -353,7 +353,7 @@
}
// Get the entry without checking permissions and bundle state.
- protected URL getEntryInternal(String path)
+ URL getEntryInternal(String path)
{
return null;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -21,10 +21,13 @@
*/
package org.jboss.osgi.framework.bundle;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
+import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
@@ -32,6 +35,7 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
@@ -158,6 +162,60 @@
return super.getHeaders(locale);
}
+ public URL getEntry(String path)
+ {
+ checkInstalled();
+ if (noAdminPermission(AdminPermission.RESOURCE))
+ return null;
+
+ return getEntryInternal(path);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Enumeration getEntryPaths(String path)
+ {
+ checkInstalled();
+ if (noAdminPermission(AdminPermission.RESOURCE))
+ return null;
+
+ DeploymentUnit unit = getDeploymentUnit();
+ if (unit instanceof VFSDeploymentUnit)
+ {
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+ VirtualFile root = vfsDeploymentUnit.getRoot();
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ try
+ {
+ VirtualFile child = root.getChild(path);
+ if (child != null)
+ return new VFSEntryPathsEnumeration(root, child);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error determining entry paths for " + root + " path=" + path);
+ }
+
+ }
+ return null;
+ }
+
+ @Override
+ protected URL getEntryInternal(String path)
+ {
+ DeploymentUnit unit = getDeploymentUnit();
+ if (unit instanceof VFSDeploymentUnit)
+ {
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ return vfsDeploymentUnit.getResourceLoader().getResource(path);
+ }
+ return null;
+ }
+
public void uninstall() throws BundleException
{
checkAdminPermission(AdminPermission.LIFECYCLE);
@@ -171,4 +229,52 @@
getBundleManager().uninstallBundle(this);
}
+
+ @SuppressWarnings("rawtypes")
+ public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ checkInstalled();
+ if (noAdminPermission(AdminPermission.RESOURCE))
+ return null;
+
+ // [TODO] fragments
+ resolveBundle();
+
+ if (filePattern == null)
+ filePattern = "*";
+
+ DeploymentUnit unit = getDeploymentUnit();
+ if (unit instanceof VFSDeploymentUnit)
+ {
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+ VirtualFile root = vfsDeploymentUnit.getRoot();
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ try
+ {
+ VirtualFile child = root.getChild(path);
+ if (child != null)
+ return new VFSFindEntriesEnumeration(root, child, filePattern, recurse);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error finding entries for " + root + " path=" + path + " pattern=" + filePattern + " recurse=" + recurse);
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ * Try to resolve the bundle
+ * @return true when resolved
+ */
+ protected boolean resolveBundle()
+ {
+ PackageAdminPlugin packageAdmin = getBundleManager().getPlugin(PackageAdminPlugin.class);
+ return packageAdmin.resolveBundles(new Bundle[] { this });
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -842,7 +842,7 @@
/**
* Updates a bundle from an InputStream.
*/
- public void updateBundle(OSGiBundleState bundleState, InputStream in) throws BundleException
+ public void updateBundle(AbstractDeployedBundleState bundleState, InputStream in) throws BundleException
{
// If the specified InputStream is null, the Framework must create the InputStream from which to read the updated bundle by interpreting,
// in an implementation dependent manner, this bundle's Bundle-UpdateLocation Manifest header, if present, or this bundle's original location.
@@ -927,7 +927,7 @@
if (activeBeforeUpdate)
{
if (updatedBundleState.isFragment() == false)
- startBundle((OSGiBundleState)updatedBundleState);
+ startBundle((AbstractDeployedBundleState)updatedBundleState);
}
}
@@ -958,7 +958,7 @@
try
{
if (bundleState.isFragment() == false)
- stopBundle((OSGiBundleState)bundleState);
+ stopBundle((AbstractDeployedBundleState)bundleState);
}
catch (Exception ex)
{
@@ -1027,7 +1027,7 @@
else
{
// Create a new OSGiBundleState
- OSGiBundleState bundleState = new OSGiBundleState(unit);
+ AbstractDeployedBundleState bundleState = new OSGiBundleState(unit);
absBundle = bundleState;
addBundle(bundleState);
}
@@ -1065,7 +1065,7 @@
boolean fireEvent = true;
if (bundleState instanceof OSGiBundleState)
{
- DeploymentUnit unit = ((OSGiBundleState)bundleState).getDeploymentUnit();
+ DeploymentUnit unit = ((AbstractDeployedBundleState)bundleState).getDeploymentUnit();
Deployment dep = unit.getAttachment(Deployment.class);
fireEvent = (dep == null || dep.isBundleUpdate() == false);
}
@@ -1154,7 +1154,7 @@
if (id == 0)
throw new IllegalArgumentException("Cannot get deployment from system bundle");
- OSGiBundleState bundleState = (OSGiBundleState)getBundleById(id);
+ AbstractDeployedBundleState bundleState = (AbstractDeployedBundleState)getBundleById(id);
if (bundleState == null)
return null;
@@ -1247,7 +1247,7 @@
// Fallback to the deployment name
else if (aux instanceof OSGiBundleState)
{
- DeploymentUnit unit = ((OSGiBundleState)aux).getDeploymentUnit();
+ DeploymentUnit unit = ((AbstractDeployedBundleState)aux).getDeploymentUnit();
if (location.equals(unit.getName()))
{
result = aux;
@@ -1370,7 +1370,7 @@
* @see OSGiBundleActivatorDeployer
* @see OSGiBundleState#startInternal()
*/
- public void startBundle(OSGiBundleState bundleState) throws BundleException
+ public void startBundle(AbstractDeployedBundleState bundleState) throws BundleException
{
// If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
if (bundleState.getState() == Bundle.UNINSTALLED)
@@ -1442,7 +1442,7 @@
* @see OSGiBundleActivatorDeployer
* @see OSGiBundleState#stopInternal()
*/
- public void stopBundle(OSGiBundleState bundleState) throws BundleException
+ public void stopBundle(AbstractDeployedBundleState bundleState) throws BundleException
{
// If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
if (bundleState.getState() == Bundle.UNINSTALLED)
@@ -1672,7 +1672,7 @@
* @param bundleState the owning bundle
* @return registered contexts
*/
- Set<ControllerContext> getRegisteredContext(OSGiBundleState bundleState)
+ Set<ControllerContext> getRegisteredContext(AbstractDeployedBundleState bundleState)
{
DeploymentUnit unit = bundleState.getDeploymentUnit();
return registry.getContexts(unit);
@@ -1699,7 +1699,7 @@
*
* @param bundleState the stopping bundle
*/
- void unregisterContexts(OSGiBundleState bundleState)
+ void unregisterContexts(AbstractDeployedBundleState bundleState)
{
DeploymentUnit unit = bundleState.getDeploymentUnit();
Set<ControllerContext> contexts = registry.getContexts(unit);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -36,12 +36,9 @@
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
-import org.jboss.virtual.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
@@ -95,7 +92,7 @@
{
String hostName = getSymbolicName();
Version hostVersion = getVersion();
-
+
FragmentHost fragmentHost = fragmentState.getFragmentHost();
if (hostName.equals(fragmentHost.getSymbolicName()) == false)
return false;
@@ -103,7 +100,7 @@
Version version = fragmentHost.getBundleVersion();
if (version != null && hostVersion.equals(version) == false)
return false;
-
+
return true;
}
@@ -121,7 +118,7 @@
log.debug("Attach " + fragmentState + " -> " + this);
attachedFragments.add(fragmentState);
-
+
// attach classloading metadata to the hosts classloading metadata
clMetaData.attachedFragmentMetaData(fragMetaData);
}
@@ -136,103 +133,10 @@
return getBundleManager().getRegisteredContext(this);
}
- public URL getEntry(String path)
- {
- checkInstalled();
- if (noAdminPermission(AdminPermission.RESOURCE))
- return null;
-
- return getEntryInternal(path);
- }
-
- @Override
- protected URL getEntryInternal(String path)
- {
- DeploymentUnit unit = getDeploymentUnit();
- if (unit instanceof VFSDeploymentUnit)
- {
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
-
- if (path.startsWith("/"))
- path = path.substring(1);
-
- return vfsDeploymentUnit.getResourceLoader().getResource(path);
- }
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- public Enumeration getEntryPaths(String path)
- {
- checkInstalled();
- if (noAdminPermission(AdminPermission.RESOURCE))
- return null;
-
- DeploymentUnit unit = getDeploymentUnit();
- if (unit instanceof VFSDeploymentUnit)
- {
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
- VirtualFile root = vfsDeploymentUnit.getRoot();
- if (path.startsWith("/"))
- path = path.substring(1);
- try
- {
- VirtualFile child = root.getChild(path);
- if (child != null)
- return new VFSEntryPathsEnumeration(root, child);
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error determining entry paths for " + root + " path=" + path);
- }
-
- }
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- public Enumeration findEntries(String path, String filePattern, boolean recurse)
- {
- if (path == null)
- throw new IllegalArgumentException("Null path");
-
- checkInstalled();
- if (noAdminPermission(AdminPermission.RESOURCE))
- return null;
-
- // [TODO] fragments
- resolveBundle();
-
- if (filePattern == null)
- filePattern = "*";
-
- DeploymentUnit unit = getDeploymentUnit();
- if (unit instanceof VFSDeploymentUnit)
- {
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
- VirtualFile root = vfsDeploymentUnit.getRoot();
- if (path.startsWith("/"))
- path = path.substring(1);
- try
- {
- VirtualFile child = root.getChild(path);
- if (child != null)
- return new VFSFindEntriesEnumeration(root, child, filePattern, recurse);
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error finding entries for " + root + " path=" + path + " pattern=" + filePattern + " recurse=" + recurse);
- }
-
- }
- return null;
- }
-
public Class<?> loadClass(String name) throws ClassNotFoundException
{
checkInstalled();
checkAdminPermission(AdminPermission.CLASS);
- // [TODO] bundle fragment
if (resolveBundle() == false)
throw new ClassNotFoundException("Cannot load class: " + name);
@@ -241,23 +145,12 @@
return classLoader.loadClass(name);
}
- /**
- * Try to resolve the bundle
- * @return true when resolved
- */
- boolean resolveBundle()
- {
- PackageAdminPlugin packageAdmin = getBundleManager().getPlugin(PackageAdminPlugin.class);
- return packageAdmin.resolveBundles(new Bundle[] { this });
- }
-
public URL getResource(String name)
{
checkInstalled();
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
- // [TODO] bundle fragment
if (resolveBundle() == false)
return getDeploymentUnit().getResourceLoader().getResource(name);
@@ -271,7 +164,6 @@
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
- // [TODO] bundle fragment
if (resolveBundle() == false)
return getDeploymentUnit().getResourceLoader().getResources(name);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -54,23 +54,6 @@
return true;
}
- @SuppressWarnings("rawtypes")
- public Enumeration findEntries(String path, String filePattern, boolean recurse)
- {
- throw new NotImplementedException();
- }
-
- public URL getEntry(String path)
- {
- throw new NotImplementedException();
- }
-
- @SuppressWarnings("rawtypes")
- public Enumeration getEntryPaths(String path)
- {
- throw new NotImplementedException();
- }
-
public URL getResource(String name)
{
// Null if the resource could not be found or if this bundle is a fragment bundle
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -244,7 +244,7 @@
ScopeKey mutableScope;
if (bundleState instanceof OSGiBundleState)
{
- OSGiBundleState obs = (OSGiBundleState)bundleState;
+ AbstractDeployedBundleState obs = (AbstractDeployedBundleState)bundleState;
DeploymentUnit unit = obs.getDeploymentUnit();
scope = unit.getScope();
mutableScope = unit.getMutableScope();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -40,6 +40,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
@@ -131,7 +132,7 @@
if ((absBundleState instanceof OSGiBundleState) == false)
return;
- OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
+ AbstractDeployedBundleState bundleState = (AbstractDeployedBundleState)absBundleState;
OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
List<ParameterizedAttribute> nativeCodeParams = osgiMetaData.getBundleNativeCode();
if (nativeCodeParams == null)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -38,6 +38,7 @@
import org.jboss.managed.api.ManagedObject;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.osgi.framework.Bundle;
@@ -148,7 +149,7 @@
// Use PackageAdmin to resolve the bundles
getPackageAdmin().resolveBundles(unresolved);
- for (OSGiBundleState aux : unresolved)
+ for (AbstractDeployedBundleState aux : unresolved)
{
if (aux.getState() != Bundle.RESOLVED)
log.info("Unresolved: " + aux);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
@@ -61,7 +62,7 @@
if (bundle == null)
throw new IllegalArgumentException("Null bundle");
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
return resolverBundleMap.get(bundleState);
}
@@ -95,7 +96,7 @@
public ResolverBundle removeBundle(Bundle bundle)
{
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
return resolverBundleMap.remove(bundleState);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -36,6 +36,7 @@
import org.jboss.classloading.spi.version.VersionRange;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
@@ -80,7 +81,7 @@
{
ResolverBundle removedBundle = super.removeBundle(bundle);
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
bundleCapabilitiesMap.remove(bundleState);
List<BundleRequirement> bundleRequirements = bundleRequirementsMap.remove(bundleState);
@@ -97,7 +98,7 @@
public List<ResolverBundle> resolve(List<Bundle> bundles)
{
List<ResolverBundle> resolvedBundles = new ArrayList<ResolverBundle>();
- for (OSGiBundleState aux : resolveBundles(bundles))
+ for (AbstractDeployedBundleState aux : resolveBundles(bundles))
{
ResolverBundle resBundle = getBundle(aux);
if (resBundle == null)
@@ -164,7 +165,7 @@
log.debug("END *****************************************************************");
// Log the unresolved bundles
- for (OSGiBundleState bundle : unresolvedBundles)
+ for (AbstractDeployedBundleState bundle : unresolvedBundles)
{
StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
message.append("\n Cannot find exporter for");
@@ -186,17 +187,17 @@
public ExportPackage getExporter(Bundle bundle, String importPackage)
{
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
BundleCapability match = getMatchingCapability(bundleState, importPackage);
if (match == null)
return null;
- OSGiBundleState exportingBundle = match.getExportingBundle();
+ AbstractDeployedBundleState exportingBundle = match.getExportingBundle();
ResolverBundle resolverBundle = getBundle(exportingBundle);
return resolverBundle.getExportPackage(importPackage);
}
- private BundleCapability getMatchingCapability(OSGiBundleState bundle, String importPackage)
+ private BundleCapability getMatchingCapability(AbstractDeployedBundleState bundle, String importPackage)
{
List<BundleRequirement> requirements = bundleRequirementsMap.get(bundle);
if (requirements == null)
@@ -258,7 +259,7 @@
/**
* Logs information about a resolved bundle
*/
- private void logResolvedBundleInfo(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
+ private void logResolvedBundleInfo(AbstractDeployedBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
{
// Log the package wiring information
StringBuffer message = new StringBuffer("Resolved: " + bundle);
@@ -350,11 +351,11 @@
/**
* Get the set of bundle capabilities
*/
- private List<BundleCapability> getBundleCapabilities(OSGiBundleState bundle)
+ private List<BundleCapability> getBundleCapabilities(AbstractDeployedBundleState bundle)
{
List<BundleCapability> result = new ArrayList<BundleCapability>();
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
DeploymentUnit unit = bundleState.getDeploymentUnit();
ClassLoadingMetaData metadata = unit.getAttachment(ClassLoadingMetaData.class);
@@ -376,11 +377,11 @@
/**
* Get the set of bundle requirements
*/
- private List<BundleRequirement> getBundleRequirements(OSGiBundleState bundle)
+ private List<BundleRequirement> getBundleRequirements(AbstractDeployedBundleState bundle)
{
List<BundleRequirement> result = new ArrayList<BundleRequirement>();
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
DeploymentUnit unit = bundleState.getDeploymentUnit();
ClassLoadingMetaData classloadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
@@ -400,7 +401,7 @@
return result;
}
- private boolean processRequiredBundle(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
+ private boolean processRequiredBundle(AbstractDeployedBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
{
// The Require-Bundle header specifies that all exported packages from
// another bundle must be imported, effectively requiring the public interface
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -28,6 +28,7 @@
import org.jboss.classloading.plugins.metadata.PackageCapability;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.classloading.OSGiPackageCapability;
import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
@@ -40,11 +41,11 @@
*/
class BundleCapability
{
- private OSGiBundleState bundle;
+ private AbstractDeployedBundleState bundle;
private PackageCapability packageCapability;
private List<BundleRequirement> wires;
- BundleCapability(OSGiBundleState bundle, PackageCapability packageCapability)
+ BundleCapability(AbstractDeployedBundleState bundle, PackageCapability packageCapability)
{
if (bundle == null)
throw new IllegalArgumentException("Null bundle");
@@ -55,14 +56,14 @@
this.packageCapability = packageCapability;
}
- OSGiBundleState getExportingBundle()
+ AbstractDeployedBundleState getExportingBundle()
{
return bundle;
}
Module getExportingModule()
{
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
DeploymentUnit unit = bundleState.getDeploymentUnit();
return unit.getAttachment(Module.class);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -22,7 +22,7 @@
package org.jboss.osgi.framework.resolver.internal.basic;
import org.jboss.classloading.plugins.metadata.PackageRequirement;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
/**
* An association of bundle/requirement.
@@ -32,11 +32,11 @@
*/
class BundleRequirement
{
- private OSGiBundleState bundle;
+ private AbstractDeployedBundleState bundle;
private PackageRequirement packageRequirement;
private BundleCapability wire;
- BundleRequirement(OSGiBundleState bundle, PackageRequirement packageRequirement)
+ BundleRequirement(AbstractDeployedBundleState bundle, PackageRequirement packageRequirement)
{
if (bundle == null)
throw new IllegalArgumentException("Null bundle");
@@ -52,7 +52,7 @@
return wire;
}
- OSGiBundleState getImportingBundle()
+ AbstractDeployedBundleState getImportingBundle()
{
return bundle;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -29,8 +29,8 @@
import org.jboss.osgi.deployment.interceptor.InvocationContext;
import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
import org.jboss.osgi.deployment.internal.InvocationContextImpl;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.plugins.LifecycleInterceptorServicePlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
import org.jboss.osgi.framework.util.DeploymentUnitAttachments;
@@ -66,7 +66,7 @@
protected InvocationContext getInvocationContext(Bundle bundle)
{
long bundleId = bundle.getBundleId();
- OSGiBundleState bundleState = (OSGiBundleState)bundleManager.getBundleById(bundleId);
+ AbstractDeployedBundleState bundleState = (AbstractDeployedBundleState)bundleManager.getBundleById(bundleId);
if (bundle == null)
throw new IllegalStateException("Cannot obtain bundle for: " + bundle);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -37,6 +37,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
@@ -131,7 +132,7 @@
if (abstractBundleState instanceof OSGiBundleState == false)
throw new UnsupportedOperationException("FIXME: getExportedPackages for System bundle");
- OSGiBundleState bundleState = (OSGiBundleState)abstractBundleState;
+ AbstractDeployedBundleState bundleState = (AbstractDeployedBundleState)abstractBundleState;
DeploymentUnit unit = bundleState.getDeploymentUnit();
ClassLoadingMetaData metaData = unit.getAttachment(ClassLoadingMetaData.class);
if (metaData == null)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -28,6 +28,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.virtual.VirtualFile;
@@ -50,7 +51,7 @@
name = parseName(rootURI);
- OSGiBundleState bundleState = getBundleState(rootURI, manager);
+ AbstractDeployedBundleState bundleState = getBundleState(rootURI, manager);
String path = parsePath(rootURI);
URL resource = bundleState.getEntry(path); // permission check
if (resource == null)
@@ -99,7 +100,7 @@
* @param manager the osgi manager
* @return bundle state or exception if no such bundle exists
*/
- protected OSGiBundleState getBundleState(URI uri, OSGiBundleManager manager)
+ protected AbstractDeployedBundleState getBundleState(URI uri, OSGiBundleManager manager)
{
String host = uri.getHost();
long id = Long.parseLong(host);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/DeployersTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/DeployersTest.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/DeployersTest.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -27,6 +27,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VirtualFile;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.osgi.framework.Bundle;
@@ -139,7 +140,7 @@
protected Bundle getBundle(DeploymentUnit unit) throws Exception
{
- OSGiBundleState bundle = unit.getAttachment(OSGiBundleState.class);
+ AbstractDeployedBundleState bundle = unit.getAttachment(OSGiBundleState.class);
assertNotNull(bundle);
return bundle.getBundleInternal();
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -41,6 +41,7 @@
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
@@ -129,7 +130,7 @@
{
if (aux.getBundleId() != 0)
{
- OSGiBundleState bundleState = (OSGiBundleState)aux;
+ AbstractDeployedBundleState bundleState = (AbstractDeployedBundleState)aux;
bundleManager.uninstallBundle(bundleState);
}
}
@@ -204,7 +205,7 @@
{
if (bundle.getState() != Bundle.UNINSTALLED)
{
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ AbstractDeployedBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
getBundleManager().uninstallBundle(bundleState);
}
}
@@ -284,7 +285,7 @@
try
{
DeploymentUnit unit = deployerStructure.getDeploymentUnit(deployment.getName());
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ AbstractDeployedBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
if (bundleState == null)
throw new IllegalStateException("Unable to determine bundle state for " + deployment.getName());
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -26,6 +26,7 @@
import java.lang.reflect.Proxy;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.osgi.framework.Bundle;
@@ -60,7 +61,7 @@
{
if (bundle == null)
{
- OSGiBundleState bundle = unit.getAttachment(OSGiBundleState.class);
+ AbstractDeployedBundleState bundle = unit.getAttachment(OSGiBundleState.class);
if (bundle == null)
throw new IllegalArgumentException("No such OSGiBundleState attachment: " + unit);
this.bundle = bundle.getBundleInternal();
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 13:58:04 UTC (rev 99160)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 14:33:26 UTC (rev 99161)
@@ -55,12 +55,12 @@
OSGiBundle host = runtime.installBundle("fragments-simple-hostA.jar");
assertBundleState(Bundle.INSTALLED, host.getState());
+ host.start();
+ assertBundleState(Bundle.ACTIVE, host.getState());
+
URL resourceURL = host.getResource("resources/resource.txt");
assertNull("Resource URL null", resourceURL);
- host.start();
- assertBundleState(Bundle.ACTIVE, host.getState());
-
host.uninstall();
assertBundleState(Bundle.UNINSTALLED, host.getState());
}
15 years, 11 months
JBoss-OSGI SVN: r99158 - in projects/jboss-osgi: projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 08:25:27 -0500 (Fri, 08 Jan 2010)
New Revision: 99158
Added:
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/resource.txt
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd
Log:
Test loadClass, findEntry, getResource on fragment bundle
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -21,6 +21,7 @@
*/
package org.jboss.osgi.testing;
+import java.net.URL;
import java.util.Dictionary;
import org.osgi.framework.Bundle;
@@ -76,6 +77,30 @@
public abstract String getProperty(String key);
/**
+ * Loads the specified class using this bundle's class loader.
+ *
+ * @param name The name of the class to load
+ * @return The OSGiBundle that is wired to this bundle class loader and contains the class.
+ * @throws ClassNotFoundException If no such class can be found or if this bundle is a fragment bundle
+ */
+ public abstract OSGiBundle loadClass(String name) throws ClassNotFoundException;
+
+ /**
+ * Returns a URL to the entry at the specified path in this bundle.
+ *
+ * @param name The path name of the entry
+ * @return A URL to the entry, or null if no entry could be found
+ */
+ public abstract URL getEntry(String path);
+
+ /**
+ * Find the specified resource from this bundle's class loader.
+ * @param name The name of the resource.
+ * @return A URL to the named resource, or null if the resource could not be found
+ */
+ public abstract URL getResource(String name);
+
+ /**
* Starts this bundle.
*/
public abstract void start() throws BundleException;
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -26,11 +26,13 @@
import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.spi.util.ExportedPackageHelper;
+import org.jboss.osgi.testing.OSGiBundle;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.PackageAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,6 +104,29 @@
}
@Override
+ public URL getEntry(String path)
+ {
+ return bundle.getEntry(path);
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ return bundle.getResource(name);
+ }
+
+ @Override
+ public OSGiBundle loadClass(String name) throws ClassNotFoundException
+ {
+ Class<?> clazz = bundle.loadClass(name);
+ BundleContext context = bundle.getBundleContext();
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = (PackageAdmin)context.getService(sref);
+ Bundle providerBundle = packageAdmin.getBundle(clazz);
+ return getRuntime().getBundle(providerBundle.getBundleId());
+ }
+
+ @Override
public void start() throws BundleException
{
bundle.start();
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -26,6 +26,9 @@
import java.net.URL;
import java.util.Dictionary;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ManagedBundle;
import org.jboss.osgi.spi.management.ManagedBundleMBean;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.spi.util.UnmodifiableDictionary;
@@ -124,6 +127,28 @@
}
@Override
+ public URL getEntry(String path)
+ {
+ assertNotUninstalled();
+ return bundle.getEntry(path);
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ assertNotUninstalled();
+ return bundle.getResource(name);
+ }
+
+ @Override
+ public OSGiBundle loadClass(String name) throws ClassNotFoundException
+ {
+ assertNotUninstalled();
+ ObjectName providerBundle = bundle.loadClass(name);
+ String bundleId = providerBundle.getKeyProperty(ManagedBundle.PROPERTY_ID);
+ return getRuntime().getBundle(new Long(bundleId));
+ }
+ @Override
public void start() throws BundleException
{
assertNotUninstalled();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -73,19 +73,21 @@
public URL getResource(String name)
{
- throw new NotImplementedException();
+ // Null if the resource could not be found or if this bundle is a fragment bundle
+ return null;
}
@SuppressWarnings("rawtypes")
public Enumeration getResources(String name) throws IOException
{
- throw new NotImplementedException();
+ // Null if the resource could not be found or if this bundle is a fragment bundle
+ return null;
}
@SuppressWarnings("rawtypes")
public Class loadClass(String name) throws ClassNotFoundException
{
- throw new NotImplementedException();
+ throw new ClassNotFoundException("Cannot load class from a fragment: " + this);
}
public void start(int options) throws BundleException
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -25,6 +25,7 @@
import static org.jboss.osgi.spi.OSGiConstants.DOMAIN_NAME;
+import java.net.URL;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -32,8 +33,11 @@
import javax.management.ObjectName;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.PackageAdmin;
/**
* The managed view of an OSGi Bundle
@@ -115,6 +119,26 @@
return retHeaders;
}
+ public URL getEntry(String path)
+ {
+ return bundle.getEntry(path);
+ }
+
+ public URL getResource(String name)
+ {
+ return bundle.getResource(name);
+ }
+
+ public ObjectName loadClass(String name) throws ClassNotFoundException
+ {
+ Class<?> clazz = bundle.loadClass(name);
+ BundleContext context = bundle.getBundleContext();
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = (PackageAdmin)context.getService(sref);
+ Bundle providingBundle = packageAdmin.getBundle(clazz);
+ return getObjectName(providingBundle);
+ }
+
public void start() throws BundleException
{
bundle.start();
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -23,6 +23,7 @@
//$Id$
+import java.net.URL;
import java.util.Dictionary;
import javax.management.ObjectName;
@@ -34,7 +35,7 @@
*
* Bundles are registered under the name
*
- * jboss.osgi:bundle=[SymbolicName],id=[BundleId]
+ * jboss.osgi:name=[SymbolicName],id=[BundleId],version=[BundleVersion]
*
* @author thomas.diesler(a)jboss.com
* @since 04-Mar-2009
@@ -79,6 +80,30 @@
String getProperty(String key);
/**
+ * Loads the specified class using this bundle's class loader.
+ *
+ * @param name The name of the class to load
+ * @return The object name of the bundle that is wired to this bundle class loader and contains the class.
+ * @throws ClassNotFoundException If no such class can be found or if this bundle is a fragment bundle
+ */
+ ObjectName loadClass(String name) throws ClassNotFoundException;
+
+ /**
+ * Returns a URL to the entry at the specified path in this bundle.
+ *
+ * @param name The path name of the entry
+ * @return A URL to the entry, or null if no entry could be found
+ */
+ URL getEntry(String path);
+
+ /**
+ * Find the specified resource from this bundle's class loader.
+ * @param name The name of the resource.
+ * @return A URL to the named resource, or null if the resource could not be found
+ */
+ URL getResource(String name);
+
+ /**
* Starts this bundle with no options
*/
void start() throws BundleException;
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 13:25:27 UTC (rev 99158)
@@ -23,11 +23,17 @@
//$Id$
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
+import java.net.URL;
+
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.test.osgi.fragments.frgmA.FragmentService;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -49,6 +55,9 @@
OSGiBundle host = runtime.installBundle("fragments-simple-hostA.jar");
assertBundleState(Bundle.INSTALLED, host.getState());
+ URL resourceURL = host.getResource("resources/resource.txt");
+ assertNull("Resource URL null", resourceURL);
+
host.start();
assertBundleState(Bundle.ACTIVE, host.getState());
@@ -70,6 +79,12 @@
OSGiBundle fragment = runtime.installBundle("fragments-simple-frgmA.jar");
assertBundleState(Bundle.INSTALLED, fragment.getState());
+ URL resourceURL = fragment.getResource("resources/resource.txt");
+ assertNull("Resource URL null", resourceURL);
+
+ URL entryURL = fragment.getEntry("resources/resource.txt");
+ assertNotNull("Entry URL not null", entryURL);
+
try
{
fragment.start();
@@ -105,6 +120,15 @@
assertBundleState(Bundle.ACTIVE, host.getState());
assertBundleState(Bundle.RESOLVED, fragment.getState());
+ OSGiBundle classProvider = host.loadClass(FragmentService.class.getName());
+ assertEquals("Class provided by fragment", host, classProvider);
+
+ URL resourceURL = host.getResource("resources/resource.txt");
+ assertNotNull("Resource URL not null", resourceURL);
+
+ URL entryURL = host.getEntry("resources/resource.txt");
+ assertNull("Entry URL null", entryURL);
+
host.uninstall();
assertBundleState(Bundle.UNINSTALLED, host.getState());
assertBundleState(Bundle.RESOLVED, fragment.getState());
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/resource.txt
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/resource.txt (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/resource.txt 2010-01-08 13:25:27 UTC (rev 99158)
@@ -0,0 +1 @@
+An attached fragment resource.
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/resource.txt
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-frgmA.bnd 2010-01-08 13:25:27 UTC (rev 99158)
@@ -1,6 +1,9 @@
-# bnd build -classpath target/test-classes -output target/test-libs/jbosgi108-bundleA.jar src/test/resources/jbosgi108/jbosgi108-bundleA.bnd
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-frgmA.jar src/test/resources/fragments/simple-frgmA.bnd
Bundle-SymbolicName: simple-frgmA
Fragment-Host: simple-hostA
Export-Package: org.jboss.test.osgi.fragments.frgmA
+Include-Resource: resources/resource.txt=resource.txt
+-removeheaders: Include-Resource
+
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd 2010-01-08 12:33:37 UTC (rev 99157)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/fragments/simple-hostA.bnd 2010-01-08 13:25:27 UTC (rev 99158)
@@ -1,4 +1,4 @@
-# bnd build -classpath target/test-classes -output target/test-libs/jbosgi108-bundleA.jar src/test/resources/jbosgi108/jbosgi108-bundleA.bnd
+# bnd build -classpath target/test-classes -output target/test-libs/fragments-simple-hostA.jar src/test/resources/fragments/simple-hostA.bnd
Bundle-SymbolicName: simple-hostA
Bundle-Activator: org.jboss.test.osgi.fragments.hostA.FragmentHostActivator
15 years, 11 months
JBoss-OSGI SVN: r99156 - in projects/jboss-osgi: trunk/distribution/installer/src/main/resources/jbossas and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 07:23:08 -0500 (Fri, 08 Jan 2010)
New Revision: 99156
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.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/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
Fragments resolve a part of the host bundle.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-08 11:55:23 UTC (rev 99155)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-08 12:23:08 UTC (rev 99156)
@@ -59,7 +59,7 @@
{
// Return if this is not a real bundle (i.e. a fragment)
AbstractBundleState absBundleState = unit.getAttachment(AbstractBundleState.class);
- if (absBundleState.isFragment())
+ if (absBundleState == null || absBundleState.isFragment())
return;
OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
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 2010-01-08 11:55:23 UTC (rev 99155)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2010-01-08 12:23:08 UTC (rev 99156)
@@ -200,5 +200,9 @@
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
+ <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ </bean>
+ <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
</deployment>
\ No newline at end of file
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 2010-01-08 11:55:23 UTC (rev 99155)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2010-01-08 12:23:08 UTC (rev 99156)
@@ -222,6 +222,10 @@
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
+ <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ </bean>
+ <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
<incallback method="addModule" state="Configured" />
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 2010-01-08 11:55:23 UTC (rev 99155)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-08 12:23:08 UTC (rev 99156)
@@ -205,6 +205,10 @@
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
+ <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ </bean>
+ <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
<incallback method="addModule" state="Configured" />
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 11:55:23 UTC (rev 99155)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-08 12:23:08 UTC (rev 99156)
@@ -23,7 +23,7 @@
//$Id$
-import static org.junit.Assert.*;
+import static org.junit.Assert.fail;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
@@ -103,11 +103,11 @@
host.start();
assertBundleState(Bundle.ACTIVE, host.getState());
- //assertBundleState(Bundle.RESOLVED, fragment.getState());
+ assertBundleState(Bundle.RESOLVED, fragment.getState());
host.uninstall();
assertBundleState(Bundle.UNINSTALLED, host.getState());
- //assertBundleState(Bundle.RESOLVED, fragment.getState());
+ assertBundleState(Bundle.RESOLVED, fragment.getState());
fragment.uninstall();
assertBundleState(Bundle.UNINSTALLED, fragment.getState());
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 2010-01-08 11:55:23 UTC (rev 99155)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-08 12:23:08 UTC (rev 99156)
@@ -192,6 +192,10 @@
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
+ <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ </bean>
+ <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
<incallback method="addModule" state="Configured" />
15 years, 11 months