[jboss-cvs] JBossAS SVN: r95191 - in projects/jboss-osgi: projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 20 13:33:04 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-20 13:33:04 -0400 (Tue, 20 Oct 2009)
New Revision: 95191
Modified:
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
Log:
Preserve bundle location in Deployment
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/hotdeploy/internal/DeploymentScannerImpl.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -246,7 +246,7 @@
try
{
// hot-deploy bundles are started automatically
- dep = deployer.createDeployment(bundleURL.toExternalForm());
+ dep = deployer.createDeployment(bundleURL);
dep.setAutoStart(true);
deploymentCache.put(bundleURL.toExternalForm(), dep);
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -108,7 +108,7 @@
public void deploy(URL url) throws BundleException
{
- Deployment dep = createDeployment(url.toExternalForm());
+ Deployment dep = createDeployment(url);
deploy(new Deployment[] { dep });
}
@@ -116,22 +116,20 @@
{
DeploymentRegistryService registry = getDeploymentRegistry();
Deployment dep = registry.getDeployment(url);
- if (dep == null)
+ if (dep != null)
{
- logWarning("Package not deployed: " + url);
+ try
+ {
+ MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
+ VFSDeployment vfsdep = dep.getAttachment(VFSDeployment.class);
+ mainDeployer.removeDeployment(vfsdep.getName());
+ mainDeployer.process();
+ }
+ catch (Exception ex)
+ {
+ logWarning("Cannot undeploy bundle", ex);
+ }
}
-
- try
- {
- MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
- VFSDeployment vfsdep = dep.getAttachment(VFSDeployment.class);
- mainDeployer.removeDeployment(vfsdep.getName());
- mainDeployer.process();
- }
- catch (Exception ex)
- {
- logWarning("Cannot undeploy bundle", ex);
- }
}
public void deploy(Deployment[] depArr) throws BundleException
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -23,23 +23,13 @@
//$Id$
-import java.net.URL;
-
import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.spi.framework.BundleContextWrapper;
-import org.jboss.osgi.spi.util.BundleInfo;
-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;
/**
* The FelixBundleContextWrapper wrapps the BundleContext provided by the Felix implemenation.
*
- * It provides additional functionality on bundle install.
- *
* @author thomas.diesler at jboss.com
* @since 15-Oct-2009
*/
@@ -52,50 +42,4 @@
{
super(context);
}
-
- @Override
- public Bundle installBundle(String location) throws BundleException
- {
- BundleInfo info = BundleInfo.createBundleInfo(location);
- URL bundleURL = info.getLocation();
- String symbolicName = info.getSymbolicName();
- Version version = Version.parseVersion(info.getVersion());
-
- Bundle bundle;
-
- ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
- if (sref != null)
- {
- DeployerService service = (DeployerService)context.getService(sref);
- service.deploy(bundleURL);
- bundle = getBundle(symbolicName, version, true);
- }
- else
- {
- bundle = context.installBundle(bundleURL.toExternalForm());
- }
-
- return bundle;
- }
-
- private Bundle getBundle(String symbolicName, Version version, boolean mustExist)
- {
- Bundle bundle = null;
- for (Bundle aux : getBundles())
- {
- if (aux.getSymbolicName().equals(symbolicName))
- {
- if (version == null || version.equals(aux.getVersion()))
- {
- bundle = aux;
- break;
- }
- }
- }
-
- if (bundle == null && mustExist == true)
- throw new IllegalStateException("Cannot obtain bundle: " + symbolicName + "-" + version);
-
- return bundle;
- }
}
\ No newline at end of file
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-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -45,6 +45,7 @@
public class BundleInfo
{
private VirtualFile root;
+ private String location;
private Manifest manifest;
private String symbolicName;
private String version;
@@ -83,7 +84,17 @@
if (url == null)
throw new IllegalArgumentException("Invalid bundle location: " + location);
- return createBundleInfo(url);
+ VirtualFile root;
+ try
+ {
+ root = VFS.getRoot(url);
+ }
+ catch (IOException e)
+ {
+ throw new BundleException("Invalid bundle location=" + url, e);
+ }
+
+ return new BundleInfo(root, location);
}
public static BundleInfo createBundleInfo(URL url) throws BundleException
@@ -100,23 +111,37 @@
{
throw new BundleException("Invalid bundle location=" + url, e);
}
- return createBundleInfo(root);
+
+ return new BundleInfo(root, url.toExternalForm());
}
public static BundleInfo createBundleInfo(VirtualFile root) throws BundleException
{
- if (root == null)
- throw new IllegalArgumentException("VirtualFile cannot be null");
-
- return new BundleInfo(root);
+ return new BundleInfo(root, null);
}
- private BundleInfo(VirtualFile root) throws BundleException
+ private BundleInfo(VirtualFile root, String location) throws BundleException
{
if (root == null)
throw new IllegalArgumentException("VirtualFile cannot be null");
+
this.root = root;
+
+ // Derive the location from the root
+ if (location == null)
+ {
+ try
+ {
+ location = root.toURL().toExternalForm();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Cannot obtain URL from: " + root);
+ }
+ }
+ this.location = location;
+ // Get the Manifest
try
{
manifest = VFSUtils.getManifest(root);
@@ -148,16 +173,9 @@
/**
* Get the bundle location
*/
- public URL getLocation()
+ public String getLocation()
{
- try
- {
- return root.toURL();
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Cannot obtain URL from: " + root);
- }
+ return location;
}
/**
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-20 17:33:04 UTC (rev 95191)
@@ -320,8 +320,13 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <!-- argLine>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine -->
<systemProperties>
<property>
+ <name>framework</name>
+ <value>${framework}</value>
+ </property>
+ <property>
<name>java.protocol.handler.pkgs</name>
<value>org.jboss.net.protocol|org.jboss.virtual.protocol</value>
</property>
@@ -345,10 +350,6 @@
<name>test.archive.directory</name>
<value>${project.build.directory}/test-libs</value>
</property>
- <property>
- <name>framework</name>
- <value>${framework}</value>
- </property>
</systemProperties>
</configuration>
</plugin>
@@ -374,6 +375,10 @@
<configuration>
<systemProperties>
<property>
+ <name>framework</name>
+ <value>${framework}</value>
+ </property>
+ <property>
<name>java.protocol.handler.pkgs</name>
<value>org.jboss.net.protocol|org.jboss.virtual.protocol</value>
</property>
@@ -382,18 +387,6 @@
<value>${jboss.bind.address}</value>
</property>
<property>
- <name>jndi.server.port</name>
- <value>1099</value>
- </property>
- <property>
- <name>log4j.output.dir</name>
- <value>${project.build.directory}</value>
- </property>
- <property>
- <name>org.apache.xerces.xni.parser.XMLParserConfiguration</name>
- <value>org.apache.xerces.parsers.XIncludeAwareParserConfiguration</value>
- </property>
- <property>
<name>jboss.osgi.framework.properties</name>
<value>${jboss.osgi.framework.properties}</value>
</property>
@@ -410,10 +403,18 @@
<value>5401</value>
</property>
<property>
- <name>framework</name>
- <value>${framework}</value>
+ <name>jndi.server.port</name>
+ <value>1099</value>
</property>
<property>
+ <name>log4j.output.dir</name>
+ <value>${project.build.directory}</value>
+ </property>
+ <property>
+ <name>org.apache.xerces.xni.parser.XMLParserConfiguration</name>
+ <value>org.apache.xerces.parsers.XIncludeAwareParserConfiguration</value>
+ </property>
+ <property>
<name>target.container</name>
<value>${target.container}</value>
</property>
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -21,13 +21,15 @@
*/
package org.jboss.osgi.deployment.deployer;
+//$Id$
+
+import java.net.URL;
+
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.internal.DeploymentImpl;
import org.jboss.osgi.spi.util.BundleInfo;
import org.osgi.framework.BundleException;
-//$Id$
-
/**
* An abstract base implementation of the DeployerService.
*
@@ -36,9 +38,9 @@
*/
public abstract class AbstractDeployerService implements DeployerService
{
- public Deployment createDeployment(String location) throws BundleException
+ public Deployment createDeployment(URL url) throws BundleException
{
- BundleInfo info = BundleInfo.createBundleInfo(location);
+ BundleInfo info = BundleInfo.createBundleInfo(url);
return new DeploymentImpl(info);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -47,7 +47,7 @@
/**
* Create a deployment from the given location.
*/
- Deployment createDeployment(String location) throws BundleException;
+ Deployment createDeployment(URL url) throws BundleException;
/**
* Deploy an array of bundles
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -22,6 +22,7 @@
package org.jboss.osgi.deployment.internal;
import java.io.Serializable;
+import java.net.MalformedURLException;
import java.net.URL;
import org.jboss.osgi.deployment.common.Deployment;
@@ -41,6 +42,7 @@
private static final long serialVersionUID = 1L;
private BundleInfo info;
+ private URL location;
private int startLevel;
private boolean autoStart;
@@ -50,6 +52,15 @@
throw new IllegalArgumentException("Bundle info cannot be null");
this.info = info;
+
+ try
+ {
+ this.location = new URL(info.getLocation());
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Malformed URL location: " + info.getLocation());
+ }
}
/**
@@ -65,7 +76,7 @@
*/
public URL getLocation()
{
- return info.getLocation();
+ return location;
}
/**
@@ -137,7 +148,6 @@
{
String symbolicName = getSymbolicName();
String version = getVersion();
- URL location = getLocation();
return "[" + symbolicName + "-" + version + ",url=" + location + "]";
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -85,7 +85,7 @@
Deployment dep = null;
for (Deployment auxDep : deployments)
{
- if (url.equals(auxDep.getLocation()))
+ if (url.toExternalForm().equals(auxDep.getLocation()))
{
dep = auxDep;
break;
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -170,7 +170,7 @@
public void deploy(URL url) throws BundleException
{
- Deployment dep = createDeployment(url.toExternalForm());
+ Deployment dep = createDeployment(url);
deploy(new Deployment[] { dep });
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java 2009-10-20 17:01:15 UTC (rev 95190)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java 2009-10-20 17:33:04 UTC (rev 95191)
@@ -72,9 +72,9 @@
}
}
- public Deployment createDeployment(String location) throws BundleException
+ public Deployment createDeployment(URL url) throws BundleException
{
- BundleInfo info = BundleInfo.createBundleInfo(location);
+ BundleInfo info = BundleInfo.createBundleInfo(url);
return new DeploymentImpl(info);
}
More information about the jboss-cvs-commits
mailing list