[jboss-cvs] JBossAS SVN: r97666 - in projects/jboss-osgi/projects: bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 10 00:26:08 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-12-10 00:26:04 -0500 (Thu, 10 Dec 2009)
New Revision: 97666
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml
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/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml
projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/deployer/Deployment.java
projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
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/test/java/org/jboss/test/osgi/FrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
Log:
Preserve bundle location on installBundle
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/pom.xml 2009-12-10 05:26:04 UTC (rev 97666)
@@ -41,8 +41,7 @@
<!-- Properties -->
<properties>
<version.jboss.osgi.runtime.felix>2.0.0</version.jboss.osgi.runtime.felix>
- <version.jboss.osgi.spi>1.0.3</version.jboss.osgi.spi>
- <version.jboss.osgi.deployment>1.0.0</version.jboss.osgi.deployment>
+ <version.jboss.osgi.deployment>1.0.1-SNAPSHOT</version.jboss.osgi.deployment>
<version.osgi>4.2.0</version.osgi>
</properties>
@@ -53,11 +52,6 @@
<artifactId>bnd</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-spi</artifactId>
- <version>${version.jboss.osgi.spi}</version>
- </dependency>
- <dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployment</artifactId>
<version>${version.jboss.osgi.deployment}</version>
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 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -23,7 +23,6 @@
// $Id$
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -34,6 +33,8 @@
import javax.management.MBeanServerFactory;
import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentFactory;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.util.BundleInfo;
@@ -67,9 +68,9 @@
public OSGiBundle installBundle(String location) throws BundleException
{
BundleInfo info = BundleInfo.createBundleInfo(location);
+ Deployment dep = DeploymentFactory.createDeployment(info);
String symbolicName = info.getSymbolicName();
Version version = info.getVersion();
- URL rootURL = info.getRootURL();
OSGiBundle bundle;
@@ -79,13 +80,13 @@
{
DeployerService service = (DeployerService)context.getService(sref);
log.debug("Install using DeployerService: " + service.getClass().getName());
- service.deploy(rootURL);
+ service.deploy(new Deployment[] { dep });
bundle = getBundle(symbolicName, version, true);
}
else
{
log.debug("Install using system context");
- Bundle auxBundle = context.installBundle(rootURL.toExternalForm());
+ Bundle auxBundle = context.installBundle(info.getLocation());
bundle = new EmbeddedBundle(this, auxBundle);
}
return registerBundle(bundle.getLocation(), bundle);
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -164,13 +164,13 @@
log.debug("End Shutdown");
}
- protected void deploy(URL archiveURL) throws Exception
+ void deploy(URL archiveURL) throws Exception
{
DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
deployer.deploy(archiveURL);
}
- protected void undeploy(URL archiveURL) throws Exception
+ void undeploy(URL archiveURL) throws Exception
{
DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
deployer.undeploy(archiveURL);
@@ -212,7 +212,7 @@
return sref;
}
- protected OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
+ OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
{
OSGiBundle bundle = null;
List<OSGiBundle> bundles = Arrays.asList(getBundles());
@@ -234,7 +234,7 @@
return bundle;
}
- protected String getManifestEntry(String location, String key)
+ String getManifestEntry(String location, String key)
{
Manifest manifest = getManifest(location);
Attributes attribs = manifest.getMainAttributes();
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -35,6 +35,7 @@
import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentFactory;
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.MBeanProxyException;
import org.jboss.osgi.spi.management.ManagedBundleMBean;
@@ -70,13 +71,11 @@
{
// Get the bundle info from the location
BundleInfo info = BundleInfo.createBundleInfo(location);
-
- // Create the deployment from the info
- DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
- Deployment dep = deployer.createDeployment(info);
+ Deployment dep = DeploymentFactory.createDeployment(info);
dep.setAutoStart(false);
-
+
// Deploy the deployemnt through the DeployerService
+ DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
deployer.deploy(new Deployment[] { dep });
String symbolicName = info.getSymbolicName();
Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/pom.xml 2009-12-10 05:26:04 UTC (rev 97666)
@@ -39,7 +39,7 @@
<!-- Properties -->
<properties>
<version.jboss.deployers>2.0.9.GA</version.jboss.deployers>
- <version.jboss.osgi.spi>1.0.3</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/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/deployer/Deployment.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/deployer/Deployment.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/deployer/Deployment.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -21,8 +21,6 @@
*/
package org.jboss.osgi.deployment.deployer;
-import java.net.URL;
-
import org.jboss.osgi.spi.Attachments;
import org.jboss.virtual.VirtualFile;
@@ -45,7 +43,7 @@
/**
* Get the bundle location
*/
- public URL getLocation();
+ public String getLocation();
/**
* Get the bundle symbolic name
Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -22,7 +22,6 @@
package org.jboss.osgi.deployment.internal;
import java.io.Serializable;
-import java.net.URL;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.spi.util.AttachmentSupport;
@@ -64,9 +63,9 @@
/**
* Get the bundle location
*/
- public URL getLocation()
+ public String getLocation()
{
- return info.getRootURL();
+ return info.getLocation();
}
/**
@@ -146,7 +145,7 @@
{
String symbolicName = getSymbolicName();
String version = getVersion();
- URL url = getLocation();
+ String url = info.getLocation();
return "[" + symbolicName + "-" + version + ",url=" + url + "]";
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -96,9 +96,11 @@
throw new IllegalArgumentException("Cannot obtain bundle deployment for: null");
Deployment dep = null;
+ String urlLocation = url.toExternalForm();
for (Deployment auxDep : deployments)
{
- if (url.equals(auxDep.getLocation()))
+ String auxLocation = auxDep.getLocation();
+ if (urlLocation.equals(auxLocation))
{
dep = auxDep;
break;
Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -103,7 +103,7 @@
{
log.debug("Install: " + dep.getLocation());
- String location = dep.getLocation().toExternalForm();
+ String location = dep.getLocation();
Bundle bundle = context.installBundle(location);
bundleMap.put(dep, bundle);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2009-12-10 05:26:04 UTC (rev 97666)
@@ -54,12 +54,12 @@
<version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
<version.jboss.osgi.common>1.0.3</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
- <version.jboss.osgi.deployment>1.0.0</version.jboss.osgi.deployment>
- <version.jboss.osgi.husky>1.0.2</version.jboss.osgi.husky>
+ <version.jboss.osgi.deployment>1.0.1-SNAPSHOT</version.jboss.osgi.deployment>
+ <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</version.jboss.osgi.jmx>
<version.jboss.osgi.runtime.deployers>1.0.3</version.jboss.osgi.runtime.deployers>
- <version.jboss.osgi.spi>1.0.3</version.jboss.osgi.spi>
+ <version.jboss.osgi.spi>1.0.4-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.osgi.xml.binding>2.0.2.Beta3</version.jboss.osgi.xml.binding>
<version.jboss.test>1.1.4.GA</version.jboss.test>
<version.ops4j.pax.web>0.7.2</version.ops4j.pax.web>
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 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -118,9 +118,6 @@
/** The bundle manager's bean name: OSGiBundleManager */
public static final String BEAN_BUNDLE_MANAGER = "OSGiBundleManager";
- /** The string representation of this bundle's location identifier. */
- public static final String PROPERTY_BUNDLE_LOCATION = "org.jboss.osgi.bundle.location";
-
/** The framework version */
private static String OSGi_FRAMEWORK_VERSION = "r4v42"; // [TODO] externalise
@@ -833,9 +830,10 @@
osgiMetaData = new AbstractOSGiMetaData(manifest);
}
- String location = (String)unit.getAttachment(PROPERTY_BUNDLE_LOCATION);
- if (location == null)
- location = unit.getName();
+ // The bundle location is not necessarily the bundle root url
+ // The framework is expected to preserve the location passed into installBundle(String)
+ Deployment dep = unit.getAttachment(Deployment.class);
+ String location = (dep != null ? dep.getLocation() : unit.getName());
OSGiBundleState bundleState = new OSGiBundleState(location, osgiMetaData, unit);
addBundle(bundleState);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.osgi;
+import static org.junit.Assert.assertEquals;
+
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
@@ -242,6 +244,13 @@
getDelegate().addPath(dir, path, name);
}
+ protected void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
protected void assertClassEquality(Class<?> expected, Class<?> actual)
{
assertTrue("Should be the same " + ClassLoaderUtils.classToString(expected) + " and " + ClassLoaderUtils.classToString(actual), expected == actual);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -22,6 +22,7 @@
package org.jboss.test.osgi.bundle;
import java.io.File;
+import java.net.URL;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.HashSet;
@@ -31,6 +32,7 @@
import junit.framework.Test;
+import org.jboss.osgi.testing.OSGiTestHelper;
import org.jboss.test.osgi.FrameworkTest;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -212,7 +214,49 @@
public void testInstallBundle() throws Exception
{
- // TODO testInstallBundle
+ OSGiTestHelper helper = new OSGiTestHelper();
+ BundleContext context = getBundleManager().getSystemContext();
+
+ // Test URL location
+ URL url = helper.getTestArchiveURL("bundles/jboss-osgi-common.jar");
+ Bundle bundle = context.installBundle(url.toExternalForm());
+ try
+ {
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
+ assertEquals(url.toExternalForm(), bundle.getLocation());
+ }
+ finally
+ {
+ bundle.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
+ }
+
+ // Test file location
+ String location = helper.getTestArchivePath("bundles/jboss-osgi-common.jar");
+ bundle = context.installBundle(location);
+ try
+ {
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
+ assertEquals(location, bundle.getLocation());
+ }
+ finally
+ {
+ bundle.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
+ }
+
+ // Test symbolic location
+ bundle = context.installBundle("/symbolic/location", url.openStream());
+ try
+ {
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
+ assertEquals("/symbolic/location", bundle.getLocation());
+ }
+ finally
+ {
+ bundle.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
+ }
}
public void testServiceListener() throws Exception
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-10 05:13:04 UTC (rev 97665)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-10 05:26:04 UTC (rev 97666)
@@ -67,7 +67,7 @@
if (url == null)
throw new IllegalArgumentException("Cannot obtain root url from: " + location);
- return new BundleInfo(toVirtualFile(url), location);
+ return new BundleInfo(toVirtualFile(url), url.toExternalForm());
}
public static BundleInfo createBundleInfo(URL url)
@@ -179,6 +179,18 @@
return manifest;
}
+ private static VirtualFile toVirtualFile(URL url)
+ {
+ try
+ {
+ return VFS.getRoot(url);
+ }
+ catch (IOException e)
+ {
+ throw new IllegalArgumentException("Invalid root url: " + url, e);
+ }
+ }
+
private static URL getRealLocation(String location)
{
// Try location as URL
@@ -217,19 +229,7 @@
return url;
}
-
- private static VirtualFile toVirtualFile(URL url)
- {
- try
- {
- return VFS.getRoot(url);
- }
- catch (IOException e)
- {
- throw new IllegalArgumentException("Invalid root url: " + url, e);
- }
- }
-
+
private static URL toURL(VirtualFile file)
{
try
More information about the jboss-cvs-commits
mailing list