Author: thomas.diesler(a)jboss.com
Date: 2009-11-12 16:35:42 -0500 (Thu, 12 Nov 2009)
New Revision: 96315
Modified:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.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
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java
Log:
Fix missing deployment registring when deployed through the DeployerService
Modified:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java 2009-11-12
19:39:18 UTC (rev 96314)
+++
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java 2009-11-12
21:35:42 UTC (rev 96315)
@@ -24,6 +24,7 @@
//$Id: DeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
import java.net.URL;
+import java.util.List;
import org.osgi.framework.Version;
@@ -36,6 +37,12 @@
public interface DeploymentRegistryService
{
/**
+ * Get the list of registered deployments.
+ * @return An empty list if this service does not maintain any bundle deployments
+ */
+ List<Deployment> getDeployments();
+
+ /**
* Get the bundle deployment for the given bundle URL
* @return null, if this service does not maintain the bundle deployment
*/
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-11-12
19:39:18 UTC (rev 96314)
+++
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-11-12
21:35:42 UTC (rev 96315)
@@ -24,14 +24,17 @@
//$Id: SystemDeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi
framework without going through the MC registered deployers.
@@ -41,19 +44,29 @@
*/
public class DeploymentRegistryServiceImpl implements DeploymentRegistryService
{
- private Set<Deployment> deployments = new HashSet<Deployment>();
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(DeploymentRegistryServiceImpl.class);
+
+ private List<Deployment> deployments = new
CopyOnWriteArrayList<Deployment>();
public DeploymentRegistryServiceImpl(BundleContext context)
{
}
+ public List<Deployment> getDeployments()
+ {
+ return Collections.unmodifiableList(deployments);
+ }
+
public void registerDeployment(Deployment dep)
{
+ log.debug("Register: " + dep);
deployments.add(dep);
}
public void unregisterDeployment(Deployment dep)
{
+ log.debug("Unregister: " + dep);
deployments.remove(dep);
}
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-11-12
19:39:18 UTC (rev 96314)
+++
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-11-12
21:35:42 UTC (rev 96315)
@@ -114,7 +114,7 @@
}
catch (BundleException ex)
{
- log.error( "Cannot install bundle: " + dep, ex);
+ log.error("Cannot install bundle: " + dep, ex);
}
}
@@ -147,7 +147,7 @@
{
try
{
- log.debug( "Start: " + bundle);
+ log.debug("Start: " + bundle);
// Added support for Bundle.START_ACTIVATION_POLICY on start
//
http://issues.apache.org/jira/browse/FELIX-1317
@@ -160,7 +160,7 @@
}
catch (BundleException ex)
{
- log.error( "Cannot start bundle: " + bundle, ex);
+ log.error("Cannot start bundle: " + bundle, ex);
}
}
}
@@ -184,7 +184,7 @@
}
else
{
- log.warn( "Cannot obtain bundle for: " + dep);
+ log.warn("Cannot obtain bundle for: " + dep);
}
}
}
@@ -205,7 +205,7 @@
}
else
{
- log.warn( "Cannot find deployment for: " + url);
+ log.warn("Cannot find deployment for: " + url);
}
}
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-11-12
19:39:18 UTC (rev 96314)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java 2009-11-12
21:35:42 UTC (rev 96315)
@@ -39,6 +39,7 @@
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
/**
* A plugin that manages bundle deployments.
@@ -93,14 +94,20 @@
public void deploy(Deployment[] bundleDeps) throws BundleException
{
+ DeploymentRegistryService registry = getDeploymentRegistry();
for (Deployment dep : bundleDeps)
+ {
getBundleManager().installBundle(dep);
+ registry.registerDeployment(dep);
+ }
}
public void deploy(URL url) throws BundleException
{
+ DeploymentRegistryService registry = getDeploymentRegistry();
Deployment dep = createDeployment(url);
getBundleManager().installBundle(dep);
+ registry.registerDeployment(dep);
}
public void undeploy(Deployment[] bundleDeps) throws BundleException
@@ -112,4 +119,14 @@
{
delegate.undeploy(url);
}
+
+ private DeploymentRegistryService getDeploymentRegistry()
+ {
+ BundleContext context = getSystemContext();
+ ServiceReference sref =
context.getServiceReference(DeploymentRegistryService.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("Cannot obtain
DeploymentRegistryService");
+
+ return (DeploymentRegistryService)context.getService(sref);
+ }
}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java 2009-11-12
19:39:18 UTC (rev 96314)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java 2009-11-12
21:35:42 UTC (rev 96315)
@@ -34,7 +34,6 @@
import org.jboss.osgi.webapp.WebAppCapability;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -45,7 +44,6 @@
* @author thomas.diesler(a)jboss.com
* @since 26-Oct-2009
*/
-@Ignore("[JBOSGI-204] Failure in Bundle.start() uninstalls the bundle in AS")
public class WebAppNegativeTestCase extends AbstractWebAppTestCase
{
private static OSGiRuntime runtime;