JBoss-OSGI SVN: r95192 - in projects/jboss-osgi/trunk: reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-20 14:07:48 -0400 (Tue, 20 Oct 2009)
New Revision: 95192
Modified:
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java
Log:
Fix deployment registry cache lookup
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-20 17:33:04 UTC (rev 95191)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-20 18:07:48 UTC (rev 95192)
@@ -305,6 +305,29 @@
</profile>
<!--
+ Name: jpda
+ Descr: Enable JPDA remote debuging
+ -->
+ <profile>
+ <id>jpda</id>
+ <activation>
+ <property>
+ <name>jpda</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
Name: embedded-testing
Descr: Setup for embedded integration testing
-->
@@ -320,7 +343,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <!-- argLine>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine -->
<systemProperties>
<property>
<name>framework</name>
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:33:04 UTC (rev 95191)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-20 18:07:48 UTC (rev 95192)
@@ -85,7 +85,7 @@
Deployment dep = null;
for (Deployment auxDep : deployments)
{
- if (url.toExternalForm().equals(auxDep.getLocation()))
+ if (url.equals(auxDep.getLocation()))
{
dep = auxDep;
break;
16 years, 9 months
JBoss-OSGI SVN: r95191 - in projects/jboss-osgi: projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration and 6 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)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(a)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);
}
16 years, 9 months
JBoss-OSGI SVN: r95177 - in projects/jboss-osgi/trunk: distribution/installer/src/main/resources/runtime/server/conf and 20 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-20 11:14:31 -0400 (Tue, 20 Oct 2009)
New Revision: 95177
Added:
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintProcessor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/AttachmentSupport.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/DeployerServicePlugin.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorServicePlugin.java
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/LifecycleInterceptorServiceImpl.java
Removed:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java
Modified:
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/reactor/deployment/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/interceptor/AbstractLifecycleInterceptorService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/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/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Use interceptor instead of Extender for Blueprint
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -123,6 +123,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -117,6 +117,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/pom.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -72,6 +72,8 @@
org.jboss.dependency.spi*,
org.jboss.kernel.spi*,
org.jboss.osgi.common.log;version=1.0,
+ org.jboss.osgi.deployment.common;version=1.0,
+ org.jboss.osgi.deployment.interceptor;version=1.0,
org.jboss.osgi.jbossxb;version=2.0,
org.jboss.osgi.microcontainer;version=1.0,
org.jboss.osgi.spi;version=1.0,
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -38,6 +38,7 @@
public class BlueprintActivator implements BundleActivator
{
private BlueprintExtender extender;
+ private BlueprintInterceptor interceptor;
public void start(BundleContext context) throws Exception
{
@@ -45,15 +46,25 @@
BlueprintService service = new BlueprintService(){};
context.registerService(BlueprintService.class.getName(), service, null);
- extender = new BlueprintExtender(new BlueprintContextImpl(context));
- context.addBundleListener(extender);
+ BlueprintProcessor processor = new BlueprintProcessor(new BlueprintContextImpl(context));
+
+ interceptor = new BlueprintInterceptor(processor);
+ interceptor.start();
+
+ extender = new BlueprintExtender(processor);
+ extender.start();
}
public void stop(BundleContext context) throws Exception
{
+ if (interceptor != null)
+ {
+ interceptor.stop();
+ interceptor = null;
+ }
+
if (extender != null)
{
- context.removeBundleListener(extender);
extender.stop();
extender = null;
}
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -23,19 +23,9 @@
//$Id$
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
import org.jboss.osgi.blueprint.BlueprintContext;
-import org.jboss.osgi.blueprint.container.BlueprintContainerImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
-import org.osgi.framework.Constants;
import org.osgi.framework.SynchronousBundleListener;
/**
@@ -46,70 +36,49 @@
*/
public class BlueprintExtender implements SynchronousBundleListener
{
- private BlueprintContext context;
- private Map<String, BlueprintContainerImpl> containers = new LinkedHashMap<String, BlueprintContainerImpl>();
+ private BlueprintProcessor processor;
- public BlueprintExtender(BlueprintContext context)
+ public BlueprintExtender(BlueprintProcessor processor)
{
- this.context = context;
+ this.processor = processor;
}
- @SuppressWarnings("unchecked")
+ /**
+ * Start the BlueprintExtender
+ */
+ public void start()
+ {
+ BlueprintContext bpContext = processor.getBlueprintContext();
+ bpContext.getBundleContext().addBundleListener(this);
+ }
+
+ /**
+ * Stop the BlueprintExtender
+ */
+ public void stop()
+ {
+ BlueprintContext bpContext = processor.getBlueprintContext();
+ bpContext.getBundleContext().removeBundleListener(this);
+ processor.stopAllContainers();
+ }
+
+ /**
+ * Handle the bundle event
+ */
public void bundleChanged(BundleEvent event)
{
Bundle bundle = event.getBundle();
- String key = getBundleKey(bundle);
- int eventType = event.getType();
+ int eventType = event.getType();
if (eventType == BundleEvent.STARTING)
{
- // If a Bundle-Blueprint manifest header is defined, then this header contains a list of paths.
- // If this header is not defined, then resources ending in .xml in the bundle’s
- // OSGI-INF/blueprint directory must be used. These are the resources that
- // would be found by calling the Bundle findEntries("OSGI-INF/blueprint", "*.xml", false) method.
-
- boolean hasBlueprintMetadata = false;
-
- String descriptorPaths = (String)bundle.getHeaders().get(BlueprintContainerImpl.HEADER_BUNDLE_BLUEPRINT);
- hasBlueprintMetadata = (descriptorPaths != null);
-
- Enumeration foundEntries = bundle.findEntries("OSGI-INF/blueprint", "*.xml", false);
- hasBlueprintMetadata |= (foundEntries != null);
-
- if (hasBlueprintMetadata == true)
- {
- BlueprintContainerImpl container = new BlueprintContainerImpl(context, bundle);
- container.initialize();
-
- containers.put(key, container);
- }
+ if (processor.hasContainer(bundle) == false)
+ processor.createContainer(bundle);
}
-
else if (eventType == BundleEvent.STOPPED)
{
- BlueprintContainerImpl container = containers.remove(key);
- if (container != null)
- container.shutdown();
+ if (processor.hasContainer(bundle))
+ processor.stopContainer(bundle);
}
}
-
- /**
- * Stop the BlueprintExtender
- */
- public void stop()
- {
- Collection<BlueprintContainerImpl> values = containers.values();
- List<BlueprintContainerImpl> list = new ArrayList<BlueprintContainerImpl>(values);
- Collections.reverse(list);
-
- for (BlueprintContainerImpl container : list)
- container.shutdown();
- }
-
- private String getBundleKey(Bundle bundle)
- {
- String symbolicName = bundle.getSymbolicName();
- String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
- return symbolicName + "-" + version;
- }
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,107 @@
+/*
+ * 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.osgi.blueprint.extender;
+
+//$Id$
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * The Blueprint extender
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class BlueprintInterceptor extends AbstractLifecycleInterceptor implements LifecycleInterceptor
+{
+ private BlueprintProcessor processor;
+ private ServiceTracker serviceTracker;
+
+ public BlueprintInterceptor(BlueprintProcessor processor)
+ {
+ this.processor = processor;
+ }
+
+ /**
+ * Start the BlueprintExtender
+ */
+ public void start()
+ {
+ BlueprintContext bpContext = processor.getBlueprintContext();
+ BundleContext context = bpContext.getBundleContext();
+
+ final LifecycleInterceptor interceptor = this;
+ serviceTracker = new ServiceTracker(context, LifecycleInterceptorService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ LifecycleInterceptorService service = (LifecycleInterceptorService)super.addingService(reference);
+ service.addInterceptor(interceptor);
+ return service;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ ((LifecycleInterceptorService)service).removeInterceptor(interceptor);
+ super.removedService(reference, service);
+ }
+ };
+ serviceTracker.open();
+ }
+
+ /**
+ * Stop the BlueprintExtender
+ */
+ public void stop()
+ {
+ processor.stopAllContainers();
+ if (serviceTracker != null)
+ {
+ serviceTracker.close();
+ serviceTracker = null;
+ }
+ }
+
+ public void invoke(int state, Deployment dep) throws LifecycleInterceptorException
+ {
+ Bundle bundle = dep.getAttachment(Bundle.class);
+ if (state == Bundle.STARTING)
+ {
+ processor.createContainer(bundle);
+ }
+ else if (state == Bundle.STOPPING)
+ {
+ processor.stopContainer(bundle);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintProcessor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintProcessor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintProcessor.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,116 @@
+/*
+ * 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.osgi.blueprint.extender;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.container.BlueprintContainerImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * The Blueprint metadata processor
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 20-Oct-2009
+ */
+class BlueprintProcessor
+{
+ private BlueprintContext bpContext;
+ private Map<String, BlueprintContainerImpl> containers = new LinkedHashMap<String, BlueprintContainerImpl>();
+
+ public BlueprintProcessor(BlueprintContext bpContext)
+ {
+ this.bpContext = bpContext;
+ }
+
+ public BlueprintContext getBlueprintContext()
+ {
+ return bpContext;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createContainer(Bundle bundle)
+ {
+ // If a Bundle-Blueprint manifest header is defined, then this header contains a list of paths.
+ // If this header is not defined, then resources ending in .xml in the bundle’s
+ // OSGI-INF/blueprint directory must be used. These are the resources that
+ // would be found by calling the Bundle findEntries("OSGI-INF/blueprint", "*.xml", false) method.
+
+ boolean hasBlueprintMetadata = false;
+
+ String descriptorPaths = (String)bundle.getHeaders().get(BlueprintContainerImpl.HEADER_BUNDLE_BLUEPRINT);
+ hasBlueprintMetadata = (descriptorPaths != null);
+
+ Enumeration foundEntries = bundle.findEntries("OSGI-INF/blueprint", "*.xml", false);
+ hasBlueprintMetadata |= (foundEntries != null);
+
+ if (hasBlueprintMetadata)
+ {
+ BlueprintContainerImpl container = new BlueprintContainerImpl(bpContext, bundle);
+ container.initialize();
+
+ String key = getBundleKey(bundle);
+ containers.put(key, container);
+ }
+ }
+
+ protected boolean hasContainer(Bundle bundle)
+ {
+ String key = getBundleKey(bundle);
+ return containers.containsKey(key);
+ }
+
+ protected void stopContainer(Bundle bundle)
+ {
+ String key = getBundleKey(bundle);
+ BlueprintContainerImpl container = containers.remove(key);
+ if (container != null)
+ container.shutdown();
+ }
+
+ protected void stopAllContainers()
+ {
+ Collection<BlueprintContainerImpl> values = containers.values();
+ List<BlueprintContainerImpl> list = new ArrayList<BlueprintContainerImpl>(values);
+ Collections.reverse(list);
+
+ for (BlueprintContainerImpl container : list)
+ container.shutdown();
+ }
+
+ private String getBundleKey(Bundle bundle)
+ {
+ String symbolicName = bundle.getSymbolicName();
+ String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ return symbolicName + "-" + version;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -10,16 +10,12 @@
<!-- ====================================================================== -->
<!-- $Id$ -->
-
- <!--
- Set these VM properties in your IDE debugger
-
- -Dlog4j.output.dir=${workspace_loc:jboss-osgi-blueprint-testsuite/target}
- -Djboss.osgi.framework.properties=jboss-osgi-felix.properties
- -Dorg.jboss.osgi.husky.Invoker=org.jboss.osgi.husky.internal.OSGiInvoker
- -Dtest.archive.directory=${workspace_loc:jboss-osgi-blueprint-testsuite/target}/test-libs
+
+ <!--
+ Set these VM properties in your IDE debugger -Dlog4j.output.dir=${workspace_loc:jboss-osgi-blueprint-testsuite/target}
+ -Dorg.jboss.osgi.husky.Invoker=org.jboss.osgi.husky.internal.OSGiInvoker -Dtest.archive.directory=${workspace_loc:jboss-osgi-blueprint-testsuite/target}/test-libs
-->
-
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -39,7 +35,7 @@
<properties>
<jboss.osgi.framework.properties>jboss-osgi-felix.properties</jboss.osgi.framework.properties>
</properties>
-
+
<!-- Dependencies -->
<dependencies>
<dependency>
@@ -52,8 +48,8 @@
<version>${version}</version>
<scope>provided</scope>
</dependency>
-
- <!-- Bundle Dependencies -->
+
+ <!-- Bundle Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.log</artifactId>
@@ -89,7 +85,7 @@
<artifactId>jboss-osgi-jmx</artifactId>
<scope>provided</scope>
</dependency>
-
+
<!-- Test Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -145,7 +141,7 @@
<!-- Profiles -->
<profiles>
-
+
<!--
Name: framework-equinox
Descr: Setup for Equinox framework integration testing
@@ -218,7 +214,7 @@
</execution>
</executions>
</plugin>
- </plugins>
+ </plugins>
</build>
</profile>
@@ -243,7 +239,7 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
<build>
@@ -268,7 +264,7 @@
</execution>
</executions>
</plugin>
- </plugins>
+ </plugins>
</build>
</profile>
<profile>
@@ -287,7 +283,7 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
<build>
@@ -312,7 +308,7 @@
</execution>
</executions>
</plugin>
- </plugins>
+ </plugins>
</build>
</profile>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -100,9 +100,12 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/reactor/deployment/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -10,7 +10,7 @@
<!-- ====================================================================== -->
<!-- $Id$ -->
-
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -56,6 +56,13 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
+
+ <!-- Test Dependecies -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -82,5 +89,5 @@
</plugin>
</plugins>
</build>
-
+
</project>
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -1,121 +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.osgi.deployment.common;
-
-// $Id$
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * Basic attachments.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 20-Apr-2007
- */
-public abstract class DeploymentBase implements Attachments
-{
- private Map<Key, Object> attachments = new HashMap<Key, Object>();
-
- /** Construct the execution context with no attachments */
- public DeploymentBase()
- {
-
- }
-
- /** Construct the execution context with given attachments */
- public DeploymentBase(Attachments att)
- {
- if (att != null)
- {
- for (Key key : att.getAttachmentKeys())
- {
- Object value = att.getAttachment(key.getClassPart(), key.getNamePart());
- this.attachments.put(key, value);
- }
- }
- }
-
- public Collection<Key> getAttachmentKeys()
- {
- return attachments.keySet();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(Class<T> clazz)
- {
- return (T)attachments.get(new Key(clazz, null));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(Class<T> clazz, String name)
- {
- return (T)attachments.get(new Key(clazz, name));
- }
-
- public Object getAttachment(String name)
- {
- return attachments.get(new Key(null, name));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(Class<T> clazz, Object obj)
- {
- return (T)attachments.put(new Key(clazz, null), obj);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(Class<T> clazz, String name, Object obj)
- {
- return (T)attachments.put(new Key(clazz, name), obj);
- }
-
- public Object addAttachment(String name, Object obj)
- {
- return attachments.put(new Key(null, name), obj);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(Class<T> clazz)
- {
- return (T)attachments.remove(new Key(clazz, null));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(Class<T> clazz, String name)
- {
- return (T)attachments.remove(new Key(clazz, name));
- }
-
- public Object removeAttachment(String name)
- {
- return attachments.remove(new Key(null, name));
- }
-
- public String toString()
- {
- return attachments.toString();
- }
-}
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 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -21,10 +21,6 @@
*/
package org.jboss.osgi.deployment.deployer;
-import java.io.File;
-import java.net.MalformedURLException;
-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;
@@ -42,41 +38,7 @@
{
public Deployment createDeployment(String location) throws BundleException
{
- // Try location as URL
- URL url = null;
- try
- {
- url = new URL(location);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try location as File
- if (url == null)
- {
- try
- {
- File file = new File(location);
- if (file.exists())
- url = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- if (url == null)
- throw new IllegalArgumentException("Invalid bundle location: " + location);
-
- return createDeploymentInternal(url);
- }
-
- private Deployment createDeploymentInternal(URL url) throws BundleException
- {
- BundleInfo info = BundleInfo.createBundleInfo(url);
+ BundleInfo info = BundleInfo.createBundleInfo(location);
return new DeploymentImpl(info);
}
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java (from rev 95159, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,90 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An abstract implementation of a LifecycleInterceptor.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public abstract class AbstractLifecycleInterceptor implements LifecycleInterceptor
+{
+ private Set<Class<?>> input;
+ private Set<Class<?>> output;
+
+ /**
+ * No relative order
+ * @return 0
+ */
+ public int getRelativeOrder()
+ {
+ return 0;
+ }
+
+ /**
+ * Get the required set of inputs.
+ *
+ * @return null if there are no inputs required
+ */
+ public Set<Class<?>> getInput()
+ {
+ return input;
+ }
+
+ /**
+ * Get the provided set of outputs.
+ *
+ * @return null if there are no outputs provided
+ */
+ public Set<Class<?>> getOutput()
+ {
+ return output;
+ }
+
+ /**
+ * Add an input requirement.
+ */
+ public void addInput(Class<?> in)
+ {
+ if (input == null)
+ input = new HashSet<Class<?>>();
+
+ input.add(in);
+ }
+
+ /**
+ * Add an output capability.
+ */
+ public void addOutput(Class<?> out)
+ {
+ if (output == null)
+ output = new HashSet<Class<?>>();
+
+ output.add(out);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -31,8 +31,11 @@
import java.util.Set;
import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A basic service that manages bundle lifecycle interceptors.
@@ -42,6 +45,9 @@
*/
public abstract class AbstractLifecycleInterceptorService implements LifecycleInterceptorService
{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(AbstractLifecycleInterceptorService.class);
+
// The interceptor chain
private List<LifecycleInterceptor> interceptorChain = new ArrayList<LifecycleInterceptor>();
@@ -189,9 +195,29 @@
dep.addAttachment(Bundle.class, bundle);
// Call the interceptor chain
- for (LifecycleInterceptor interceptor : interceptorChain)
+ for (LifecycleInterceptor aux : interceptorChain)
{
- interceptor.invoke(state, dep);
+ Set<Class<?>> input = aux.getInput();
+ boolean doInvocation = true;
+ if (input != null)
+ {
+ // Check if all required input is available
+ for (Class<?> clazz : input)
+ {
+ if (dep.getAttachment(clazz) == null)
+ {
+ doInvocation = false;
+ break;
+ }
+ }
+ }
+ if (doInvocation)
+ {
+ String className = aux.getClass().getName();
+ String stateName = ConstantsHelper.bundleState(state);
+ log.debug("Invoke: " + className + " with state " + stateName + " on " + dep.getLocation());
+ aux.invoke(state, dep);
+ }
}
}
}
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -1,101 +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.osgi.deployment.interceptor;
-
-//$Id$
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.osgi.deployment.common.Deployment;
-
-/**
- * A basic implementation of a LifecycleInterceptor.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public class BasicLifecycleInterceptor implements LifecycleInterceptor
-{
- private Set<Class<?>> input;
- private Set<Class<?>> output;
-
- /**
- * No relative order
- * @return 0
- */
- public int getRelativeOrder()
- {
- return 0;
- }
-
- /**
- * Get the required set of inputs.
- *
- * @return null if there are no inputs required
- */
- public Set<Class<?>> getInput()
- {
- return input;
- }
-
- /**
- * Get the provided set of outputs.
- *
- * @return null if there are no outputs provided
- */
- public Set<Class<?>> getOutput()
- {
- return output;
- }
-
- /**
- * Add an input requirement.
- */
- public void addInput(Class<?> in)
- {
- if (input == null)
- input = new HashSet<Class<?>>();
-
- input.add(in);
- }
-
- /**
- * Add an output capability.
- */
- public void addOutput(Class<?> out)
- {
- if (output == null)
- output = new HashSet<Class<?>>();
-
- output.add(out);
- }
-
- /**
- * Does nothing.
- * Overwrite to provide a meaningful implementation.
- */
- public void invoke(int state, Deployment dep)
- {
- // do nothing
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/AttachmentSupport.java (from rev 95159, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/DeploymentBase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/AttachmentSupport.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/AttachmentSupport.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,121 @@
+/*
+ * 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.osgi.deployment.internal;
+
+// $Id$
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.osgi.deployment.common.Attachments;
+
+/**
+ * Basic attachment support.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public abstract class AttachmentSupport implements Attachments
+{
+ private Map<Key, Object> attachments = new HashMap<Key, Object>();
+
+ /** Construct the execution context with no attachments */
+ public AttachmentSupport()
+ {
+
+ }
+
+ /** Construct the execution context with given attachments */
+ public AttachmentSupport(Attachments att)
+ {
+ if (att != null)
+ {
+ for (Key key : att.getAttachmentKeys())
+ {
+ Object value = att.getAttachment(key.getClassPart(), key.getNamePart());
+ this.attachments.put(key, value);
+ }
+ }
+ }
+
+ public Collection<Key> getAttachmentKeys()
+ {
+ return attachments.keySet();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttachment(Class<T> clazz)
+ {
+ return (T)attachments.get(new Key(clazz, null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttachment(Class<T> clazz, String name)
+ {
+ return (T)attachments.get(new Key(clazz, name));
+ }
+
+ public Object getAttachment(String name)
+ {
+ return attachments.get(new Key(null, name));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T addAttachment(Class<T> clazz, Object obj)
+ {
+ return (T)attachments.put(new Key(clazz, null), obj);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T addAttachment(Class<T> clazz, String name, Object obj)
+ {
+ return (T)attachments.put(new Key(clazz, name), obj);
+ }
+
+ public Object addAttachment(String name, Object obj)
+ {
+ return attachments.put(new Key(null, name), obj);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttachment(Class<T> clazz)
+ {
+ return (T)attachments.remove(new Key(clazz, null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T removeAttachment(Class<T> clazz, String name)
+ {
+ return (T)attachments.remove(new Key(clazz, name));
+ }
+
+ public Object removeAttachment(String name)
+ {
+ return attachments.remove(new Key(null, name));
+ }
+
+ public String toString()
+ {
+ return attachments.toString();
+ }
+}
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 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -25,7 +25,6 @@
import java.net.URL;
import org.jboss.osgi.deployment.common.Deployment;
-import org.jboss.osgi.deployment.common.DeploymentBase;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.virtual.VirtualFile;
@@ -37,7 +36,7 @@
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
-public class DeploymentImpl extends DeploymentBase implements Deployment, Serializable
+public class DeploymentImpl extends AttachmentSupport implements Deployment, Serializable
{
private static final long serialVersionUID = 1L;
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -27,8 +27,10 @@
import java.util.List;
+import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
-import org.jboss.osgi.deployment.interceptor.BasicLifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
import org.jboss.osgi.deployment.internal.LifecycleInterceptorServiceImpl;
import org.junit.Test;
@@ -81,10 +83,10 @@
{
}
- BasicLifecycleInterceptor inA = new BasicLifecycleInterceptor();
+ AbstractLifecycleInterceptor inA = new BasicLifecycleInterceptor();
inA.addInput(A.class);
- BasicLifecycleInterceptor outA = new BasicLifecycleInterceptor();
+ AbstractLifecycleInterceptor outA = new BasicLifecycleInterceptor();
outA.addOutput(A.class);
// Add ordered
@@ -107,4 +109,12 @@
assertEquals(outA, chain.get(0));
assertEquals(inA, chain.get(1));
}
+
+ class BasicLifecycleInterceptor extends AbstractLifecycleInterceptor
+ {
+ public void invoke(int state, Deployment dep) throws LifecycleInterceptorException
+ {
+ // do nothing
+ }
+ }
}
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -1,18 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!-- ======================================================================
--->
+ <!-- ====================================================================== -->
<!-- -->
<!-- JBoss, the OpenSource J2EE webOS -->
<!-- -->
<!-- Distributable under LGPL license. -->
<!-- See terms of license at http://www.gnu.org. -->
<!-- -->
- <!-- ======================================================================
--->
+ <!-- ====================================================================== -->
- <!-- $Id$
--->
+ <!-- $Id$ -->
<!--
Set these VM properties in your IDE debugger
@@ -29,7 +26,7 @@
<packaging>bundle</packaging>
<version>1.0.0.Alpha2</version>
-
+
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi</artifactId>
@@ -42,7 +39,6 @@
<version.jboss.aop>2.1.0.CR3</version.jboss.aop>
<version.jboss.classloading>2.0.7.CR2</version.jboss.classloading>
<version.jboss.deployers>2.0.8.GA</version.jboss.deployers>
- <version.jboss.logging.log4j>2.1.0.GA</version.jboss.logging.log4j>
<version.jboss.microcontainer>2.0.9.GA</version.jboss.microcontainer>
<version.jboss.test>1.1.4.GA</version.jboss.test>
</properties>
@@ -147,6 +143,13 @@
<artifactId>jboss-osgi-deployers</artifactId>
</dependency>
+ <!-- Provided Dependencies -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
@@ -288,9 +291,9 @@
<descriptors>
<descriptor>scripts/assembly-all.xml</descriptor>
</descriptors>
- <archive>
+ <archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
+ </archive>
</configuration>
</execution>
</executions>
@@ -342,12 +345,12 @@
<Bundle-SymbolicName>org.jboss.osgi.framework</Bundle-SymbolicName>
<Bundle-Version>${version}</Bundle-Version>
<Export-Package>
- org.osgi.framework;version="1.5",
- org.osgi.framework.launch;version="1.0",
- org.osgi.framework.hooks.service;version="1.0",
- org.osgi.service.packageadmin;version="1.2",
- org.osgi.service.startlevel;version="1.1",
- org.osgi.util.tracker;version="1.4"
+ org.osgi.framework;version="1.5",
+ org.osgi.framework.launch;version="1.0",
+ org.osgi.framework.hooks.service;version="1.0",
+ org.osgi.service.packageadmin;version="1.2",
+ org.osgi.service.startlevel;version="1.1",
+ org.osgi.util.tracker;version="1.4"
</Export-Package>
</instructions>
</configuration>
@@ -373,7 +376,7 @@
</plugin>
</plugins>
</build>
-
+
<!-- Repositories -->
<repositories>
<repository>
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -39,7 +39,7 @@
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
-import org.jboss.osgi.framework.plugins.LifecycleInterceptorPlugin;
+import org.jboss.osgi.framework.plugins.LifecycleInterceptorServicePlugin;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.util.collection.ConcurrentSet;
@@ -690,7 +690,7 @@
// Invoke the bundle lifecycle interceptors
if (getBundleManager().isActive() && getBundleId() != 0)
{
- LifecycleInterceptorPlugin plugin = getBundleManager().getPlugin(LifecycleInterceptorPlugin.class);
+ LifecycleInterceptorServicePlugin plugin = getBundleManager().getPlugin(LifecycleInterceptorServicePlugin.class);
plugin.handleStateChange(state, getBundleInternal());
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -1037,7 +1037,6 @@
registeredServices.add(result);
FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
plugin.fireServiceEvent(bundleState, ServiceEvent.REGISTERED, result);
- log.debug("Registered service : " + result.toLongString());
return result;
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -25,12 +25,10 @@
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
-import java.util.Vector;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -72,7 +70,6 @@
return getClass().getClassLoader().loadClass(name);
}
- @SuppressWarnings("unchecked")
public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
{
log.warn("[JBOSGI-138] findEntries(" + path + "," + filePattern + "," + recurse + ")");
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -33,7 +33,6 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.virtual.VirtualFile;
@@ -47,9 +46,6 @@
*/
public class OSGiClassLoaderFactory implements ClassLoaderFactory
{
- /** The log */
- private static final Logger log = Logger.getLogger(OSGiClassLoaderFactory.class);
-
/** The classloader system */
private ClassLoaderSystem system;
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/DeployerServicePlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/DeployerServicePlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/DeployerServicePlugin.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,34 @@
+/*
+ * 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.osgi.framework.plugins;
+
+import org.jboss.osgi.deployment.deployer.DeployerService;
+
+/**
+ * The DeployerService service plugin
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public interface DeployerServicePlugin extends ServicePlugin, DeployerService
+{
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/DeployerServicePlugin.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -1,34 +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.osgi.framework.plugins;
-
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
-
-/**
- * The LifecycleInterceptorService service plugin
- *
- * @author thomas.diesler(a)jboss.com
- * @since 19-Oct-2009
- */
-public interface LifecycleInterceptorPlugin extends ServicePlugin, LifecycleInterceptorService
-{
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorServicePlugin.java (from rev 95159, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorServicePlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorServicePlugin.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,34 @@
+/*
+ * 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.osgi.framework.plugins;
+
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+
+/**
+ * The LifecycleInterceptorService service plugin
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public interface LifecycleInterceptorServicePlugin extends ServicePlugin, LifecycleInterceptorService
+{
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -85,6 +85,9 @@
allPackages.add("javax.xml.transform.sax");
allPackages.add("javax.xml.transform.stream");
+ allPackages.add("org.jboss.osgi.deployment.common");
+ allPackages.add("org.jboss.osgi.deployment.deployer");
+ allPackages.add("org.jboss.osgi.deployment.interceptor");
allPackages.add("org.jboss.osgi.microcontainer");
allPackages.add("org.jboss.virtual");
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,102 @@
+/*
+ * 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.osgi.framework.service.internal;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.internal.DeploymentImpl;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.plugins.DeployerServicePlugin;
+import org.jboss.osgi.framework.plugins.internal.AbstractServicePluginImpl;
+import org.jboss.osgi.spi.NotImplementedException;
+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.ServiceRegistration;
+
+/**
+ * A plugin that manages bundle deployments.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public class DeployerServiceImpl extends AbstractServicePluginImpl implements DeployerServicePlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(DeployerServiceImpl.class);
+
+ private ServiceRegistration registration;
+
+ public DeployerServiceImpl(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+ }
+
+ public void startService()
+ {
+ BundleContext context = getSystemContext();
+ registration = context.registerService(DeployerService.class.getName(), this, null);
+ }
+
+ public void stopService()
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+
+ public Deployment createDeployment(String location) throws BundleException
+ {
+ BundleInfo info = BundleInfo.createBundleInfo(location);
+ return new DeploymentImpl(info);
+ }
+
+ public void deploy(URL url) throws BundleException
+ {
+ bundleManager.install(url);
+ }
+
+ public void undeploy(URL url) throws BundleException
+ {
+ Bundle bundle = bundleManager.getBundleByLocation(url.toExternalForm());
+ if (bundle != null)
+ bundle.uninstall();
+ }
+
+ public void deploy(Deployment[] bundleDeps) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void undeploy(Deployment[] bundleDeps) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -1,111 +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.osgi.framework.service.internal;
-
-//$Id$
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.deployment.common.Deployment;
-import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.plugins.LifecycleInterceptorPlugin;
-import org.jboss.osgi.framework.plugins.internal.AbstractPluginImpl;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.Version;
-
-/**
- * A plugin that manages bundle lifecycle interceptors.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 19-Oct-2009
- */
-public class LifecycleInterceptorPluginImpl extends AbstractPluginImpl implements LifecycleInterceptorPlugin
-{
- // Provide logging
- final Logger log = Logger.getLogger(LifecycleInterceptorPluginImpl.class);
-
- private LifecycleInterceptorService service;
- private ServiceRegistration registration;
-
- public LifecycleInterceptorPluginImpl(OSGiBundleManager bundleManager)
- {
- super(bundleManager);
- }
-
- public BundleContext getSystemContext()
- {
- return bundleManager.getSystemBundle();
- }
-
- public void startService()
- {
- BundleContext context = getSystemContext();
- service = new AbstractLifecycleInterceptorService()
- {
- protected Deployment getDeployment(String name, Version version)
- {
- OSGiBundleState bundle = (OSGiBundleState)bundleManager.getBundle(name, version);
- if (bundle == null)
- throw new IllegalStateException("Cannot obtain bundle for: " + name + "-" + version);
-
- DeploymentUnit unit = bundle.getDeploymentUnit();
- Deployment dep = unit.getAttachment(Deployment.class);
- if (dep == null)
- throw new IllegalStateException("Cannot obtain deployment for: " + bundle);
-
- return dep;
- }
- };
- registration = context.registerService(LifecycleInterceptorService.class.getName(), service, null);
- }
-
- public void stopService()
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- service = null;
- }
- }
-
- public void addInterceptor(LifecycleInterceptor interceptor)
- {
- service.addInterceptor(interceptor);
- }
-
- public void removeInterceptor(LifecycleInterceptor interceptor)
- {
- service.removeInterceptor(interceptor);
- }
-
- public void handleStateChange(int state, Bundle bundle)
- {
- service.handleStateChange(state, bundle);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java (from rev 95159, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2009-10-20 15:14:31 UTC (rev 95177)
@@ -0,0 +1,106 @@
+/*
+ * 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.osgi.framework.service.internal;
+
+//$Id$
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+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.AbstractServicePluginImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
+
+/**
+ * A plugin that manages bundle lifecycle interceptors.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public class LifecycleInterceptorServiceImpl extends AbstractServicePluginImpl implements LifecycleInterceptorServicePlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(LifecycleInterceptorServiceImpl.class);
+
+ private LifecycleInterceptorService service;
+ private ServiceRegistration registration;
+
+ public LifecycleInterceptorServiceImpl(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+ }
+
+ public void startService()
+ {
+ BundleContext context = getSystemContext();
+ service = new AbstractLifecycleInterceptorService()
+ {
+ protected Deployment getDeployment(String name, Version version)
+ {
+ OSGiBundleState bundle = (OSGiBundleState)bundleManager.getBundle(name, version);
+ if (bundle == null)
+ throw new IllegalStateException("Cannot obtain bundle for: " + name + "-" + version);
+
+ DeploymentUnit unit = bundle.getDeploymentUnit();
+ Deployment dep = unit.getAttachment(Deployment.class);
+ if (dep == null)
+ throw new IllegalStateException("Cannot obtain deployment for: " + bundle);
+
+ return dep;
+ }
+ };
+ registration = context.registerService(LifecycleInterceptorService.class.getName(), service, null);
+ }
+
+ public void stopService()
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ service = null;
+ }
+ }
+
+ public void addInterceptor(LifecycleInterceptor interceptor)
+ {
+ service.addInterceptor(interceptor);
+ }
+
+ public void removeInterceptor(LifecycleInterceptor interceptor)
+ {
+ service.removeInterceptor(interceptor);
+ }
+
+ public void handleStateChange(int state, Bundle bundle)
+ {
+ service.handleStateChange(state, bundle);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -72,9 +72,12 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -100,9 +100,12 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -99,9 +99,12 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-10-20 15:06:31 UTC (rev 95176)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-10-20 15:14:31 UTC (rev 95177)
@@ -252,6 +252,11 @@
<artifactId>jboss-osgi-framework</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -277,6 +282,11 @@
<artifactId>jboss-osgi-framework</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
16 years, 9 months
JBoss-OSGI SVN: r95170 - projects/jboss-osgi/projects/parent/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-20 10:15:47 -0400 (Tue, 20 Oct 2009)
New Revision: 95170
Modified:
projects/jboss-osgi/projects/parent/trunk/pom.xml
Log:
Update to jboss-logging-2.1.0
Modified: projects/jboss-osgi/projects/parent/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-10-20 13:14:00 UTC (rev 95169)
+++ projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-10-20 14:15:47 UTC (rev 95170)
@@ -20,7 +20,7 @@
<!-- Properties -->
<properties>
- <version.jboss.logging>2.0.5.GA</version.jboss.logging>
+ <version.jboss.logging>2.1.0.GA</version.jboss.logging>
<version.junit>4.6</version.junit>
<version.slf4j>1.5.8</version.slf4j>
</properties>
16 years, 9 months
JBoss-OSGI SVN: r95167 - in projects/jboss-osgi: projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-20 06:33:38 -0400 (Tue, 20 Oct 2009)
New Revision: 95167
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java
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/internal/DeploymentImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Expose VirtualFile on Deployment
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 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -53,7 +53,6 @@
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -148,8 +147,8 @@
for (Deployment dep : depArr)
{
- VirtualFile file = VFS.createNewRoot(dep.getLocation());
- VFSDeployment vfsdep = deploymentFactory.createVFSDeployment(file);
+ VirtualFile root = dep.getRoot();
+ VFSDeployment vfsdep = deploymentFactory.createVFSDeployment(root);
dep.addAttachment(VFSDeployment.class, vfsdep);
registry.registerDeployment(dep);
depList.add(vfsdep);
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 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -28,9 +28,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.jar.Attributes;
-import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleException;
@@ -44,13 +44,16 @@
*/
public class BundleInfo
{
- private URL location;
+ private VirtualFile root;
private Manifest manifest;
private String symbolicName;
private String version;
public static BundleInfo createBundleInfo(String location) throws BundleException
{
+ if (location == null)
+ throw new IllegalArgumentException("Location cannot be null");
+
// Try location as URL
URL url = null;
try
@@ -85,51 +88,47 @@
public static BundleInfo createBundleInfo(URL url) throws BundleException
{
- Manifest manifest;
+ if (url == null)
+ throw new IllegalArgumentException("URL cannot be null");
+
+ VirtualFile root;
try
{
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
+ root = VFS.getRoot(url);
}
- catch (IOException ex)
+ catch (IOException e)
{
- throw new BundleException("Cannot get manifest from: " + url, ex);
-
+ throw new BundleException("Invalid bundle location=" + url, e);
}
-
- return new BundleInfo(url, manifest);
+ return createBundleInfo(root);
}
- public static BundleInfo createBundleInfo(VirtualFile vFile) throws BundleException
+ public static BundleInfo createBundleInfo(VirtualFile root) throws BundleException
{
- URL url;
- Manifest manifest;
+ if (root == null)
+ throw new IllegalArgumentException("VirtualFile cannot be null");
+
+ return new BundleInfo(root);
+ }
+
+ private BundleInfo(VirtualFile root) throws BundleException
+ {
+ if (root == null)
+ throw new IllegalArgumentException("VirtualFile cannot be null");
+ this.root = root;
+
try
{
- manifest = VFSUtils.getManifest(vFile);
- url = vFile.toURL();
+ manifest = VFSUtils.getManifest(root);
}
catch (Exception ex)
{
- throw new BundleException("Cannot get manifest from: " + vFile, ex);
+ throw new BundleException("Cannot get manifest from: " + root, ex);
}
- return new BundleInfo(url, manifest);
- }
-
- private BundleInfo(URL location, Manifest manifest) throws BundleException
- {
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (manifest == null)
- throw new IllegalArgumentException("Manifest cannot be null");
- this.manifest = manifest;
- this.location = location;
-
symbolicName = getManifestHeader(Constants.BUNDLE_SYMBOLICNAME);
if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + location);
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + root);
version = getManifestHeader(Constants.BUNDLE_VERSION);
if (version == null)
@@ -151,8 +150,23 @@
*/
public URL getLocation()
{
- return location;
+ try
+ {
+ return root.toURL();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Cannot obtain URL from: " + root);
+ }
}
+
+ /**
+ * Get the bundle root file
+ */
+ public VirtualFile getRoot()
+ {
+ return root;
+ }
/**
* Get the bundle symbolic name
@@ -171,8 +185,24 @@
}
@Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof BundleInfo))
+ return false;
+
+ BundleInfo other = (BundleInfo)obj;
+ return root.equals(other.root);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
public String toString()
{
- return "[" + symbolicName + "-" + version + ",url=" + location + "]";
+ return "[" + symbolicName + "-" + version + ",url=" + root + "]";
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/common/Deployment.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -23,7 +23,9 @@
import java.net.URL;
+import org.jboss.virtual.VirtualFile;
+
//$Id$
/**
@@ -35,6 +37,11 @@
public interface Deployment extends Attachments
{
/**
+ * Get the root virtual file
+ */
+ public VirtualFile getRoot();
+
+ /**
* Get the bundle location
*/
public URL getLocation();
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 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -22,17 +22,13 @@
package org.jboss.osgi.deployment.deployer;
import java.io.File;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
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;
-import org.osgi.framework.Constants;
//$Id$
@@ -80,25 +76,7 @@
private Deployment createDeploymentInternal(URL url) throws BundleException
{
- Manifest manifest;
- try
- {
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new BundleException("Cannot get manifest from: " + url);
-
- }
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
- String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new DeploymentImpl(url, symbolicName, version);
+ 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/internal/DeploymentImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -27,6 +27,7 @@
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.common.DeploymentBase;
import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.virtual.VirtualFile;
//$Id$
@@ -40,36 +41,24 @@
{
private static final long serialVersionUID = 1L;
- private URL location;
- private String symbolicName;
- private String version;
+ private BundleInfo info;
private int startLevel;
private boolean autoStart;
- private Object metadata;
public DeploymentImpl(BundleInfo info)
{
if (info == null)
throw new IllegalArgumentException("Bundle info cannot be null");
- this.symbolicName = info.getSymbolicName();
- this.location = info.getLocation();
- this.version = info.getVersion().toString();
+ this.info = info;
}
- public DeploymentImpl(URL location, String symbolicName, String version)
+ /**
+ * Get the root virtual file
+ */
+ public VirtualFile getRoot()
{
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (symbolicName == null)
- throw new IllegalArgumentException("Symbolic name cannot be null");
-
- if (version == null)
- version = "0.0.0";
-
- this.symbolicName = symbolicName;
- this.location = location;
- this.version = version;
+ return info.getRoot();
}
/**
@@ -77,7 +66,7 @@
*/
public URL getLocation()
{
- return location;
+ return info.getLocation();
}
/**
@@ -85,7 +74,7 @@
*/
public String getSymbolicName()
{
- return symbolicName;
+ return info.getSymbolicName();
}
/**
@@ -93,7 +82,7 @@
*/
public String getVersion()
{
- return version;
+ return info.getVersion();
}
/**
@@ -128,22 +117,6 @@
this.autoStart = autoStart;
}
- /**
- * Get extra meta data associated with this deployment
- */
- public Object getMetadata()
- {
- return metadata;
- }
-
- /**
- * Set extra meta data associated with this deployment
- */
- public void setMetadata(Object metadata)
- {
- this.metadata = metadata;
- }
-
@Override
public boolean equals(Object obj)
{
@@ -151,7 +124,7 @@
return false;
DeploymentImpl other = (DeploymentImpl)obj;
- return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+ return info.equals(other.info);
}
@Override
@@ -163,6 +136,9 @@
@Override
public String toString()
{
+ 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/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -86,6 +86,7 @@
allPackages.add("javax.xml.transform.stream");
allPackages.add("org.jboss.osgi.microcontainer");
+ allPackages.add("org.jboss.virtual");
allPackages.add("org.w3c.dom");
allPackages.add("org.w3c.dom.bootstrap");
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java 2009-10-20 09:40:47 UTC (rev 95166)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/bundle/OSGI161Activator.java 2009-10-20 10:33:38 UTC (rev 95167)
@@ -53,6 +53,7 @@
String loggerClass = log.getClass().getName();
List<String> expected = new ArrayList<String>();
+ expected.add("org.apache.commons.logging.impl.SLF4JLog");
expected.add("org.apache.commons.logging.impl.Log4JLogger");
expected.add("org.apache.commons.logging.impl.SLF4JLocationAwareLog");
16 years, 9 months
JBoss-OSGI SVN: r95166 - in projects/jboss-osgi/trunk/testsuite: functional/src/test/resources and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-20 05:40:47 -0400 (Tue, 20 Oct 2009)
New Revision: 95166
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties
Log:
Fix felix/equinox syscp for deployment
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties 2009-10-20 09:29:36 UTC (rev 95165)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-equinox.properties 2009-10-20 09:40:47 UTC (rev 95166)
@@ -16,7 +16,8 @@
org.apache.log4j;version=1.2, \
org.jboss.logging, \
org.jboss.net.protocol, \
- org.jboss.osgi.deployment;version=1.0, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.framework;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties 2009-10-20 09:29:36 UTC (rev 95165)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-equinox.properties 2009-10-20 09:40:47 UTC (rev 95166)
@@ -17,7 +17,8 @@
org.apache.log4j;version=1.2, \
org.jboss.logging, \
org.jboss.net.protocol, \
- org.jboss.osgi.deployment;version=1.0, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;version=1.0, \
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties 2009-10-20 09:29:36 UTC (rev 95165)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jboss-osgi-felix.properties 2009-10-20 09:40:47 UTC (rev 95166)
@@ -16,7 +16,8 @@
org.apache.log4j;version=1.2, \
org.jboss.logging, \
org.jboss.net.protocol, \
- org.jboss.osgi.deployment;version=1.0, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;version=1.0, \
16 years, 9 months
JBoss-OSGI SVN: r95160 - projects/jboss-osgi/projects/bundles/microcontainer/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-20 04:06:33 -0400 (Tue, 20 Oct 2009)
New Revision: 95160
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml
Log:
Fix bnd import for deployment
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml 2009-10-20 07:01:26 UTC (rev 95159)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/pom.xml 2009-10-20 08:06:33 UTC (rev 95160)
@@ -30,6 +30,13 @@
<version>1.0.4-SNAPSHOT</version>
</parent>
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
<!-- Properties -->
<properties>
<version.jboss.deployers>2.0.5.SP1</version.jboss.deployers>
@@ -130,7 +137,8 @@
org.jboss.joinpoint.*,
org.jboss.logging,
org.jboss.osgi.common.log;version=1.0,
- org.jboss.osgi.deployment;version=1.0,
+ org.jboss.osgi.deployment.common;version=1.0,
+ org.jboss.osgi.deployment.deployer;version=1.0,
org.jboss.osgi.jbossxb;version=2.0,
org.jboss.osgi.spi;version=1.0,
org.jboss.osgi.spi.management;version=1.0,
@@ -181,11 +189,4 @@
</plugins>
</build>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi/projects/bundles/microcontaine...</url>
- </scm>
-
</project>
16 years, 9 months
JBoss-OSGI SVN: r95119 - in projects/jboss-osgi/trunk/distribution/installer/src/main/resources: runtime/server/conf and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 11:50:56 -0400 (Mon, 19 Oct 2009)
New Revision: 95119
Modified:
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
Log:
Add LifecycleInterceptorPluging to runtime config
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-10-19 15:14:50 UTC (rev 95118)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-10-19 15:50:56 UTC (rev 95119)
@@ -123,6 +123,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-10-19 15:14:50 UTC (rev 95118)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-10-19 15:50:56 UTC (rev 95119)
@@ -117,6 +117,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
16 years, 9 months
JBoss-OSGI SVN: r95116 - in projects/jboss-osgi: projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 10:48:13 -0400 (Mon, 19 Oct 2009)
New Revision: 95116
Added:
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/interceptor/AbstractLifecycleInterceptorService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorException.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java
Removed:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelServicePlugin.java
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
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/DeploymentRegistryService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.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/LifecycleInterceptorServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/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/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Call lifecycle plugins from MC framework
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-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -48,7 +48,7 @@
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.osgi.deployment.common.Deployment;
-import org.jboss.osgi.deployment.deployer.DeployerServiceBase;
+import org.jboss.osgi.deployment.deployer.AbstractDeployerService;
import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
@@ -65,7 +65,7 @@
* @author thomas.diesler(a)jboss.com
* @since 23-Jan-2009
*/
-public abstract class AbstractMicrocontainerService extends DeployerServiceBase implements MicrocontainerService
+public abstract class AbstractMicrocontainerService extends AbstractDeployerService implements MicrocontainerService
{
private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
private ServiceTracker registryTracker;
@@ -113,14 +113,13 @@
deploy(new Deployment[] { dep });
}
- public boolean undeploy(URL url) throws BundleException
+ public void undeploy(URL url) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
Deployment dep = registry.getDeployment(url);
if (dep == null)
{
logWarning("Package not deployed: " + url);
- return false;
}
try
@@ -129,12 +128,10 @@
VFSDeployment vfsdep = dep.getAttachment(VFSDeployment.class);
mainDeployer.removeDeployment(vfsdep.getName());
mainDeployer.process();
- return true;
}
catch (Exception ex)
{
logWarning("Cannot undeploy bundle", ex);
- return false;
}
}
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-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -31,6 +31,8 @@
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -92,13 +94,29 @@
}
catch (IOException ex)
{
- throw new BundleException("Cannot get manifest from: " + url);
+ throw new BundleException("Cannot get manifest from: " + url, ex);
}
return new BundleInfo(url, manifest);
}
+ public static BundleInfo createBundleInfo(VirtualFile vFile) throws BundleException
+ {
+ URL url;
+ Manifest manifest;
+ try
+ {
+ manifest = VFSUtils.getManifest(vFile);
+ url = vFile.toURL();
+ }
+ catch (Exception ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + vFile, ex);
+ }
+ return new BundleInfo(url, manifest);
+ }
+
private BundleInfo(URL location, Manifest manifest) throws BundleException
{
if (location == null)
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:48:13 UTC (rev 95116)
@@ -100,6 +100,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java (from rev 95096, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/AbstractDeployerService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,104 @@
+/*
+ * 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.osgi.deployment.deployer;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.internal.DeploymentImpl;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+//$Id$
+
+/**
+ * An abstract base implementation of the DeployerService.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 16-Oct-2009
+ */
+public abstract class AbstractDeployerService implements DeployerService
+{
+ public Deployment createDeployment(String location) throws BundleException
+ {
+ // Try location as URL
+ URL url = null;
+ try
+ {
+ url = new URL(location);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try location as File
+ if (url == null)
+ {
+ try
+ {
+ File file = new File(location);
+ if (file.exists())
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ if (url == null)
+ throw new IllegalArgumentException("Invalid bundle location: " + location);
+
+ return createDeploymentInternal(url);
+ }
+
+ private Deployment createDeploymentInternal(URL url) throws BundleException
+ {
+ Manifest manifest;
+ try
+ {
+ JarFile jarFile = new JarFile(url.getPath());
+ manifest = jarFile.getManifest();
+ jarFile.close();
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + url);
+
+ }
+
+ Attributes attribs = manifest.getMainAttributes();
+ String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ if (symbolicName == null)
+ throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
+
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+ return new DeploymentImpl(url, symbolicName, version);
+ }
+}
\ 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-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -66,15 +66,6 @@
/**
* Undeploy bundle from URL.
- *
- * Note, due to the dynamic nature of OSGi services it is
- * possible that a {@link DeployerService} is asked to undeploy
- * a bundle URL which it did not deploy itself.
- *
- * In this case this method should return false, so that
- * another {@link DeployerService} can be tried.
- *
- * @return true if this service could undeploy the bundle
*/
- boolean undeploy(URL url) throws BundleException;
+ void undeploy(URL url) throws BundleException;
}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeployerServiceBase.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -1,104 +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.osgi.deployment.deployer;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.jboss.osgi.deployment.common.Deployment;
-import org.jboss.osgi.deployment.internal.DeploymentImpl;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-//$Id$
-
-/**
- * An abstract base implementation of the DeployerService.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 16-Oct-2009
- */
-public abstract class DeployerServiceBase implements DeployerService
-{
- public Deployment createDeployment(String location) throws BundleException
- {
- // Try location as URL
- URL url = null;
- try
- {
- url = new URL(location);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try location as File
- if (url == null)
- {
- try
- {
- File file = new File(location);
- if (file.exists())
- url = file.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- if (url == null)
- throw new IllegalArgumentException("Invalid bundle location: " + location);
-
- return createDeploymentInternal(url);
- }
-
- private Deployment createDeploymentInternal(URL url) throws BundleException
- {
- Manifest manifest;
- try
- {
- JarFile jarFile = new JarFile(url.getPath());
- manifest = jarFile.getManifest();
- jarFile.close();
- }
- catch (IOException ex)
- {
- throw new BundleException("Cannot get manifest from: " + url);
-
- }
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
-
- String version = attribs.getValue(Constants.BUNDLE_VERSION);
- return new DeploymentImpl(url, symbolicName, version);
- }
-}
\ No newline at end of file
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-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -37,7 +37,7 @@
public interface DeploymentRegistryService
{
/**
- * Create a bundle deployment from the given bundle URL
+ * Get the bundle deployment for the given bundle URL
* @return null, if this service does not maintain the bundle deployment
*/
Deployment getDeployment(URL url);
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,203 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * A basic service that manages bundle lifecycle interceptors.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public abstract class AbstractLifecycleInterceptorService implements LifecycleInterceptorService
+{
+ // The interceptor chain
+ private List<LifecycleInterceptor> interceptorChain = new ArrayList<LifecycleInterceptor>();
+
+ /**
+ * Add a LifecycleInterceptor to the service.
+ *
+ * The interceptor is added according to its input requirements
+ * and relative order.
+ *
+ * @param interceptor The interceptor
+ */
+ public void addInterceptor(LifecycleInterceptor interceptor)
+ {
+ synchronized (interceptorChain)
+ {
+ Set<LifecycleInterceptor> unsortedSet = new HashSet<LifecycleInterceptor>();
+ unsortedSet.addAll(interceptorChain);
+ unsortedSet.add(interceptor);
+
+ List<LifecycleInterceptor> sortedList = new ArrayList<LifecycleInterceptor>();
+
+ // Add interceptors with no inputs first
+ Iterator<LifecycleInterceptor> itUnsorted = unsortedSet.iterator();
+ while(itUnsorted.hasNext())
+ {
+ LifecycleInterceptor aux = itUnsorted.next();
+ if (aux.getInput() == null)
+ {
+ addWithRelativeOrder(sortedList, aux);
+ itUnsorted.remove();
+ }
+ }
+
+ // Get the set of provided outputs
+ Set<Class<?>> providedOutputs = new HashSet<Class<?>>();
+ for (LifecycleInterceptor aux : sortedList)
+ {
+ Set<Class<?>> auxOutput = aux.getOutput();
+ if (auxOutput != null)
+ providedOutputs.addAll(auxOutput);
+ }
+
+ // Add interceptors with sattisfied inputs
+ itUnsorted = unsortedSet.iterator();
+ while(itUnsorted.hasNext())
+ {
+ LifecycleInterceptor aux = itUnsorted.next();
+ Set<Class<?>> input = aux.getInput();
+ if (input == null)
+ throw new IllegalStateException("Interceptor with no inputs should have been added already");
+
+ if (providedOutputs.containsAll(input))
+ {
+ addWithRelativeOrder(sortedList, aux);
+ itUnsorted.remove();
+ }
+ }
+
+ // Add the remaining interceptors
+ for (LifecycleInterceptor aux : unsortedSet)
+ {
+ addWithRelativeOrder(sortedList, aux);
+ }
+
+ // Use the sorted result as the new interceptor chain
+ interceptorChain.clear();
+ interceptorChain.addAll(sortedList);
+ }
+ }
+
+ private void addWithRelativeOrder(List<LifecycleInterceptor> sortedList, LifecycleInterceptor interceptor)
+ {
+ Set<Class<?>> providedOutputs = new HashSet<Class<?>>();
+ int relOrder = interceptor.getRelativeOrder();
+ Set<Class<?>> input = interceptor.getInput();
+
+ for (int i = 0; i < sortedList.size(); i++)
+ {
+ LifecycleInterceptor aux = sortedList.get(i);
+ int auxOrder = aux.getRelativeOrder();
+
+ // Add if all inputs are satisfied and the rel order is less or equal
+ boolean inputsProvided = (input == null || providedOutputs.containsAll(input));
+ if (inputsProvided && relOrder <= auxOrder)
+ {
+ sortedList.add(i, interceptor);
+ return;
+ }
+
+ // Add the this interceptor output the list
+ Set<Class<?>> auxOutput = aux.getOutput();
+ if (auxOutput != null)
+ providedOutputs.addAll(auxOutput);
+ }
+
+ // If not added yet, add at end
+ sortedList.add(interceptor);
+ }
+
+ /**
+ * Remove an LifecycleInterceptor to the service.
+ *
+ * @param interceptor The interceptor
+ */
+ public void removeInterceptor(LifecycleInterceptor interceptor)
+ {
+ synchronized (interceptorChain)
+ {
+ interceptorChain.remove(interceptor);
+ }
+ }
+
+ protected List<LifecycleInterceptor> getInterceptorChain()
+ {
+ synchronized (interceptorChain)
+ {
+ return Collections.unmodifiableList(interceptorChain);
+ }
+ }
+
+ /**
+ * Invoke the registered set of interceptors for the given bundle state change.
+ *
+ * @param state The future state of the bundle
+ * @param bundle The bundle that changes state
+ * @throws LifecycleInterceptorException if the invocation of an interceptor fails
+ */
+ public void handleStateChange(int state, Bundle bundle)
+ {
+ synchronized (interceptorChain)
+ {
+ // Nothing to do
+ if (interceptorChain.size() == 0)
+ return;
+
+ String name = bundle.getSymbolicName();
+ Version version = bundle.getVersion();
+ Deployment dep = getDeployment(name, version);
+ if (dep == null)
+ throw new IllegalStateException("Cannot get deployment for: " + name + "-" + version);
+
+ // Attach the bundle if not already done so
+ Bundle attBundle = dep.getAttachment(Bundle.class);
+ if (attBundle == null)
+ dep.addAttachment(Bundle.class, bundle);
+
+ // Call the interceptor chain
+ for (LifecycleInterceptor interceptor : interceptorChain)
+ {
+ interceptor.invoke(state, dep);
+ }
+ }
+ }
+
+ /**
+ * Get the deployment for the given bundle symbolic name and version
+ */
+ protected abstract Deployment getDeployment(String symbolicName, Version version);
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java (from rev 95111, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/BasicLifecycleInterceptor.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,101 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.osgi.deployment.common.Deployment;
+
+/**
+ * A basic implementation of a LifecycleInterceptor.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public class BasicLifecycleInterceptor implements LifecycleInterceptor
+{
+ private Set<Class<?>> input;
+ private Set<Class<?>> output;
+
+ /**
+ * No relative order
+ * @return 0
+ */
+ public int getRelativeOrder()
+ {
+ return 0;
+ }
+
+ /**
+ * Get the required set of inputs.
+ *
+ * @return null if there are no inputs required
+ */
+ public Set<Class<?>> getInput()
+ {
+ return input;
+ }
+
+ /**
+ * Get the provided set of outputs.
+ *
+ * @return null if there are no outputs provided
+ */
+ public Set<Class<?>> getOutput()
+ {
+ return output;
+ }
+
+ /**
+ * Add an input requirement.
+ */
+ public void addInput(Class<?> in)
+ {
+ if (input == null)
+ input = new HashSet<Class<?>>();
+
+ input.add(in);
+ }
+
+ /**
+ * Add an output capability.
+ */
+ public void addOutput(Class<?> out)
+ {
+ if (output == null)
+ output = new HashSet<Class<?>>();
+
+ output.add(out);
+ }
+
+ /**
+ * Does nothing.
+ * Overwrite to provide a meaningful implementation.
+ */
+ public void invoke(int state, Deployment dep)
+ {
+ // do nothing
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -26,7 +26,7 @@
import java.util.Set;
import org.jboss.osgi.deployment.common.Deployment;
-import org.osgi.framework.BundleException;
+import org.osgi.framework.Bundle;
/**
* An OSGi bundle lifecycle interceptor.
@@ -64,6 +64,7 @@
*
* @param state The future state of the bundle
* @param dep The deployment that represents the bundle
+ * @throws LifecycleInterceptorException if the invocation of the interceptor fails
*/
- void invoke(int state, Deployment dep) throws BundleException;
+ void invoke(int state, Deployment dep) throws LifecycleInterceptorException;
}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -1,102 +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.osgi.deployment.interceptor;
-
-//$Id$
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.osgi.deployment.common.Deployment;
-import org.osgi.framework.BundleException;
-
-/**
- * A basic implementation of a LifecycleInterceptor.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public class LifecycleInterceptorBase implements LifecycleInterceptor
-{
- private Set<Class<?>> input;
- private Set<Class<?>> output;
-
- /**
- * No relative order
- * @return 0
- */
- public int getRelativeOrder()
- {
- return 0;
- }
-
- /**
- * Get the required set of inputs.
- *
- * @return null if there are no inputs required
- */
- public Set<Class<?>> getInput()
- {
- return input;
- }
-
- /**
- * Get the provided set of outputs.
- *
- * @return null if there are no outputs provided
- */
- public Set<Class<?>> getOutput()
- {
- return output;
- }
-
- /**
- * Add an input requirement.
- */
- public void addInput(Class<?> in)
- {
- if (input == null)
- input = new HashSet<Class<?>>();
-
- input.add(in);
- }
-
- /**
- * Add an output capability.
- */
- public void addOutput(Class<?> out)
- {
- if (output == null)
- output = new HashSet<Class<?>>();
-
- output.add(out);
- }
-
- /**
- * Does nothing.
- * Overwrite to provide a meaningful implementation.
- */
- public void invoke(int state, Deployment dep) throws BundleException
- {
- // do nothing
- }
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorException.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorException.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorException.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,45 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+
+/**
+ * A runtime exception that may be thrown from a lifecycle interceptor.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+@SuppressWarnings("serial")
+public class LifecycleInterceptorException extends RuntimeException
+{
+ private LifecycleInterceptorException(String message)
+ {
+ super(message);
+ }
+
+ private LifecycleInterceptorException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -24,7 +24,6 @@
//$Id$
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
/**
* A service that manages bundle lifecycle interceptors.
@@ -52,11 +51,11 @@
void removeInterceptor(LifecycleInterceptor interceptor);
/**
- * Invoke the interceptor chain for the given bundle state change.
+ * Invoke the registered set of interceptors for the given bundle state change.
*
* @param state The future state of the bundle
* @param bundle The bundle that changes state
- * @throws BundleException
+ * @throws LifecycleInterceptorException if the invocation of an interceptor fails
*/
- void invokeInterceptorChain(int state, Bundle bundle) throws BundleException;
+ void handleStateChange(int state, Bundle bundle);
}
\ No newline at end of file
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-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentImpl.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -26,6 +26,7 @@
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.common.DeploymentBase;
+import org.jboss.osgi.spi.util.BundleInfo;
//$Id$
@@ -46,6 +47,16 @@
private boolean autoStart;
private Object metadata;
+ public DeploymentImpl(BundleInfo info)
+ {
+ if (info == null)
+ throw new IllegalArgumentException("Bundle info cannot be null");
+
+ this.symbolicName = info.getSymbolicName();
+ this.location = info.getLocation();
+ this.version = info.getVersion().toString();
+ }
+
public DeploymentImpl(URL location, String symbolicName, String version)
{
if (location == null)
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -23,20 +23,13 @@
//$Id$
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
-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;
@@ -46,142 +39,26 @@
* @author thomas.diesler(a)jboss.com
* @since 15-Oct-2009
*/
-public class LifecycleInterceptorServiceImpl implements LifecycleInterceptorService
+public class LifecycleInterceptorServiceImpl extends AbstractLifecycleInterceptorService
{
private BundleContext context;
- // The interceptor chain
- private List<LifecycleInterceptor> interceptorChain = new ArrayList<LifecycleInterceptor>();
-
public LifecycleInterceptorServiceImpl(BundleContext context)
{
this.context = context;
}
-
- public void addInterceptor(LifecycleInterceptor interceptor)
- {
- synchronized (interceptorChain)
- {
- Set<LifecycleInterceptor> unsortedSet = new HashSet<LifecycleInterceptor>();
- unsortedSet.addAll(interceptorChain);
- unsortedSet.add(interceptor);
-
- List<LifecycleInterceptor> sortedList = new ArrayList<LifecycleInterceptor>();
-
- // Add interceptors with no inputs first
- Iterator<LifecycleInterceptor> itUnsorted = unsortedSet.iterator();
- while(itUnsorted.hasNext())
- {
- LifecycleInterceptor aux = itUnsorted.next();
- if (aux.getInput() == null)
- {
- addWithRelativeOrder(sortedList, aux);
- itUnsorted.remove();
- }
- }
-
- // Get the set of provided outputs
- Set<Class<?>> providedOutputs = new HashSet<Class<?>>();
- for (LifecycleInterceptor aux : sortedList)
- {
- Set<Class<?>> auxOutput = aux.getOutput();
- if (auxOutput != null)
- providedOutputs.addAll(auxOutput);
- }
-
- // Add interceptors with sattisfied inputs
- itUnsorted = unsortedSet.iterator();
- while(itUnsorted.hasNext())
- {
- LifecycleInterceptor aux = itUnsorted.next();
- Set<Class<?>> input = aux.getInput();
- if (input == null)
- throw new IllegalStateException("Interceptor with no inputs should have been added already");
-
- if (providedOutputs.containsAll(input))
- {
- addWithRelativeOrder(sortedList, aux);
- itUnsorted.remove();
- }
- }
-
- // Add the remaining interceptors
- for (LifecycleInterceptor aux : unsortedSet)
- {
- addWithRelativeOrder(sortedList, aux);
- }
-
- // Use the sorted result as the new interceptor chain
- interceptorChain.clear();
- interceptorChain.addAll(sortedList);
- }
- }
-
- private void addWithRelativeOrder(List<LifecycleInterceptor> sortedList, LifecycleInterceptor interceptor)
- {
- Set<Class<?>> providedOutputs = new HashSet<Class<?>>();
- int relOrder = interceptor.getRelativeOrder();
- Set<Class<?>> input = interceptor.getInput();
-
- for (int i = 0; i < sortedList.size(); i++)
- {
- LifecycleInterceptor aux = sortedList.get(i);
- int auxOrder = aux.getRelativeOrder();
-
- // Add if all inputs are satisfied and the rel order is less or equal
- boolean inputsProvided = (input == null || providedOutputs.containsAll(input));
- if (inputsProvided && relOrder <= auxOrder)
- {
- sortedList.add(i, interceptor);
- return;
- }
-
- // Add the this interceptor output the list
- Set<Class<?>> auxOutput = aux.getOutput();
- if (auxOutput != null)
- providedOutputs.addAll(auxOutput);
- }
-
- // If not added yet, add at end
- sortedList.add(interceptor);
- }
- public void removeInterceptor(LifecycleInterceptor interceptor)
- {
- synchronized (interceptorChain)
- {
- interceptorChain.remove(interceptor);
- }
- }
-
+ @Override
public List<LifecycleInterceptor> getInterceptorChain()
{
- synchronized (interceptorChain)
- {
- return Collections.unmodifiableList(interceptorChain);
- }
+ return super.getInterceptorChain();
}
- public void invokeInterceptorChain(int state, Bundle bundle) throws BundleException
+ @Override
+ protected Deployment getDeployment(String symbolicName, Version version)
{
- String name = bundle.getSymbolicName();
- Version version = bundle.getVersion();
- Deployment dep = getDeploymentRegistryService().getDeployment(name, version);
- if (dep == null)
- throw new IllegalStateException("Cannot get deployment for: " + name + "-" + version);
-
- // Attach the bundle if not already done so
- Bundle attBundle = dep.getAttachment(Bundle.class);
- if (attBundle == null)
- dep.addAttachment(Bundle.class, bundle);
-
- synchronized (interceptorChain)
- {
- for (LifecycleInterceptor interceptor : interceptorChain)
- {
- interceptor.invoke(state, dep);
- }
- }
+ DeploymentRegistryService service = getDeploymentRegistryService();
+ return service.getDeployment(symbolicName, version);
}
private DeploymentRegistryService getDeploymentRegistryService()
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-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -32,7 +32,7 @@
import org.jboss.osgi.deployment.common.Deployment;
import org.jboss.osgi.deployment.deployer.DeployerService;
-import org.jboss.osgi.deployment.deployer.DeployerServiceBase;
+import org.jboss.osgi.deployment.deployer.AbstractDeployerService;
import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.jboss.osgi.spi.management.ManagedBundleService;
@@ -53,7 +53,7 @@
* @author thomas.diesler(a)jboss.com
* @since 27-May-2009
*/
-public class SystemDeployerService extends DeployerServiceBase
+public class SystemDeployerService extends AbstractDeployerService
{
// Provide logging
private Logger log = LoggerFactory.getLogger(SystemDeployerService.class);
@@ -174,19 +174,17 @@
deploy(new Deployment[] { dep });
}
- public boolean undeploy(URL url) throws BundleException
+ public void undeploy(URL url) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
Deployment dep = registry.getDeployment(url);
if (dep != null)
{
undeploy(new Deployment[] { dep });
- return true;
}
else
{
log.warn( "Cannot find deployment for: " + url);
- return false;
}
}
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -28,7 +28,7 @@
import java.util.List;
import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorBase;
+import org.jboss.osgi.deployment.interceptor.BasicLifecycleInterceptor;
import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
import org.jboss.osgi.deployment.internal.LifecycleInterceptorServiceImpl;
import org.junit.Test;
@@ -44,8 +44,8 @@
@Test
public void testRelativeOrder()
{
- LifecycleInterceptor rel000 = new LifecycleInterceptorBase();
- LifecycleInterceptor rel100 = new LifecycleInterceptorBase()
+ LifecycleInterceptor rel000 = new BasicLifecycleInterceptor();
+ LifecycleInterceptor rel100 = new BasicLifecycleInterceptor()
{
public int getRelativeOrder()
{
@@ -81,10 +81,10 @@
{
}
- LifecycleInterceptorBase inA = new LifecycleInterceptorBase();
+ BasicLifecycleInterceptor inA = new BasicLifecycleInterceptor();
inA.addInput(A.class);
- LifecycleInterceptorBase outA = new LifecycleInterceptorBase();
+ BasicLifecycleInterceptor outA = new BasicLifecycleInterceptor();
outA.addOutput(A.class);
// Add ordered
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-10-19 14:48:13 UTC (rev 95116)
@@ -137,12 +137,14 @@
<dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
- <version>${version.jboss.osgi.spi}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-deployment</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployers</artifactId>
- <version>${version.jboss.osgi.runtime.deployers}</version>
</dependency>
<!-- OSGi Dependencies -->
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -39,6 +39,7 @@
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
+import org.jboss.osgi.framework.plugins.LifecycleInterceptorPlugin;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.util.collection.ConcurrentSet;
@@ -649,47 +650,58 @@
public void changeState(int state)
{
int previous = getState();
- int type = 0;
+
+ // Get the corresponding bundle event type
+ int bundleEventType = 0;
switch (state)
{
case Bundle.STARTING:
- type = BundleEvent.STARTING;
+ bundleEventType = BundleEvent.STARTING;
break;
case Bundle.ACTIVE:
- type = BundleEvent.STARTED;
+ bundleEventType = BundleEvent.STARTED;
break;
case Bundle.STOPPING:
- type = BundleEvent.STOPPING;
+ bundleEventType = BundleEvent.STOPPING;
break;
case Bundle.UNINSTALLED:
- type = BundleEvent.UNINSTALLED;
+ bundleEventType = BundleEvent.UNINSTALLED;
break;
case Bundle.INSTALLED:
{
if (previous == Bundle.RESOLVED)
- type = BundleEvent.UNRESOLVED;
+ bundleEventType = BundleEvent.UNRESOLVED;
else
- type = BundleEvent.INSTALLED;
+ bundleEventType = BundleEvent.INSTALLED;
break;
}
case Bundle.RESOLVED:
{
if (previous == Bundle.STOPPING)
- type = BundleEvent.STOPPED;
+ bundleEventType = BundleEvent.STOPPED;
else
- type = BundleEvent.RESOLVED;
+ bundleEventType = BundleEvent.RESOLVED;
break;
}
default:
throw new IllegalArgumentException("Unknown bundle state: " + state);
}
+
+ // Invoke the bundle lifecycle interceptors
+ if (getBundleManager().isActive() && getBundleId() != 0)
+ {
+ LifecycleInterceptorPlugin plugin = getBundleManager().getPlugin(LifecycleInterceptorPlugin.class);
+ plugin.handleStateChange(state, getBundleInternal());
+ }
+
this.state.set(state);
log.debug(this + " change state=" + ConstantsHelper.bundleState(state));
+ // Fire the bundle event
if (getBundleManager().isActive())
{
FrameworkEventsPlugin plugin = getBundleManager().getPlugin(FrameworkEventsPlugin.class);
- plugin.fireBundleEvent(this, type);
+ plugin.fireBundleEvent(this, bundleEventType);
}
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -63,6 +63,8 @@
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.internal.DeploymentImpl;
import org.jboss.osgi.framework.filter.NoFilter;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
@@ -73,6 +75,7 @@
import org.jboss.osgi.framework.plugins.Plugin;
import org.jboss.osgi.framework.plugins.ServicePlugin;
import org.jboss.osgi.framework.resolver.BundleResolver;
+import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.util.collection.ConcurrentSet;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
@@ -87,6 +90,7 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
import org.osgi.service.packageadmin.PackageAdmin;
/**
@@ -471,6 +475,11 @@
att.addAttachment(PROPERTY_AUTO_START, Boolean.FALSE);
att.addAttachment(PROPERTY_BUNDLE_LOCATION, location);
+ // Add the deployment used by lifecycle interceptors
+ BundleInfo info = BundleInfo.createBundleInfo(root);
+ Deployment dep = new DeploymentImpl(info);
+ att.addAttachment(Deployment.class, dep);
+
deployerClient.deploy(deployment);
try
{
@@ -635,9 +644,11 @@
}
bundleState.setBundleManager(this);
+ bundles.add(bundleState);
+
bundleState.changeState(Bundle.INSTALLED);
- bundles.add(bundleState);
- log.debug("Added " + bundleState.getCanonicalName() + " id=" + bundleState.getBundleId());
+
+ log.debug("Added: " + bundleState);
}
/**
@@ -717,6 +728,29 @@
}
/**
+ * Get a bundle by symbolic name and version
+ *
+ * @param symbolicName the symbolic name of the bundle
+ * @param version the version of the bundle
+ * @return the bundle or null if there is no bundle with that id
+ */
+ public AbstractBundleState getBundle(String symbolicName, Version version)
+ {
+ AbstractBundleState result = null;
+ for (AbstractBundleState aux : bundles)
+ {
+ String auxName = aux.getSymbolicName();
+ Version auxVersion = aux.getVersion();
+ if (auxName.equals(symbolicName) && auxVersion.equals(version))
+ {
+ result = aux;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
* Get a bundle by location
*
* @param location the location of the bundle
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,34 @@
+/*
+ * 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.osgi.framework.plugins;
+
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+
+/**
+ * The LifecycleInterceptorService service plugin
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public interface LifecycleInterceptorPlugin extends ServicePlugin, LifecycleInterceptorService
+{
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/LifecycleInterceptorPlugin.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java (from rev 95091, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelServicePlugin.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,34 @@
+/*
+ * 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.osgi.framework.plugins;
+
+import org.osgi.service.startlevel.StartLevel;
+
+/**
+ * The StartLevel service plugin
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 07-Sep-2009
+ */
+public interface StartLevelPlugin extends ServicePlugin, StartLevel
+{
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelServicePlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelServicePlugin.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/StartLevelServicePlugin.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -1,34 +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.osgi.framework.plugins;
-
-import org.osgi.service.startlevel.StartLevel;
-
-/**
- * The StartLevel service plugin
- *
- * @author thomas.diesler(a)jboss.com
- * @since 07-Sep-2009
- */
-public interface StartLevelServicePlugin extends ServicePlugin, StartLevel
-{
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -0,0 +1,111 @@
+/*
+ * 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.osgi.framework.service.internal;
+
+//$Id$
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.plugins.LifecycleInterceptorPlugin;
+import org.jboss.osgi.framework.plugins.internal.AbstractPluginImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
+
+/**
+ * A plugin that manages bundle lifecycle interceptors.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public class LifecycleInterceptorPluginImpl extends AbstractPluginImpl implements LifecycleInterceptorPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(LifecycleInterceptorPluginImpl.class);
+
+ private LifecycleInterceptorService service;
+ private ServiceRegistration registration;
+
+ public LifecycleInterceptorPluginImpl(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+ }
+
+ public BundleContext getSystemContext()
+ {
+ return bundleManager.getSystemBundle();
+ }
+
+ public void startService()
+ {
+ BundleContext context = getSystemContext();
+ service = new AbstractLifecycleInterceptorService()
+ {
+ protected Deployment getDeployment(String name, Version version)
+ {
+ OSGiBundleState bundle = (OSGiBundleState)bundleManager.getBundle(name, version);
+ if (bundle == null)
+ throw new IllegalStateException("Cannot obtain bundle for: " + name + "-" + version);
+
+ DeploymentUnit unit = bundle.getDeploymentUnit();
+ Deployment dep = unit.getAttachment(Deployment.class);
+ if (dep == null)
+ throw new IllegalStateException("Cannot obtain deployment for: " + bundle);
+
+ return dep;
+ }
+ };
+ registration = context.registerService(LifecycleInterceptorService.class.getName(), service, null);
+ }
+
+ public void stopService()
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ service = null;
+ }
+ }
+
+ public void addInterceptor(LifecycleInterceptor interceptor)
+ {
+ service.addInterceptor(interceptor);
+ }
+
+ public void removeInterceptor(LifecycleInterceptor interceptor)
+ {
+ service.removeInterceptor(interceptor);
+ }
+
+ public void handleStateChange(int state, Bundle bundle)
+ {
+ service.handleStateChange(state, bundle);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorPluginImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java 2009-10-19 14:48:13 UTC (rev 95116)
@@ -25,7 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.plugins.StartLevelServicePlugin;
+import org.jboss.osgi.framework.plugins.StartLevelPlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractServicePluginImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceRegistration;
@@ -39,7 +39,7 @@
* @author thomas.diesler(a)jboss.com
* @since 31-Aug-2009
*/
-public class StartLevelImpl extends AbstractServicePluginImpl implements StartLevelServicePlugin
+public class StartLevelImpl extends AbstractServicePluginImpl implements StartLevelPlugin
{
/** The log */
private static final Logger log = Logger.getLogger(StartLevelImpl.class);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:48:13 UTC (rev 95116)
@@ -72,6 +72,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:48:13 UTC (rev 95116)
@@ -100,6 +100,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:39:15 UTC (rev 95115)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-10-19 14:48:13 UTC (rev 95116)
@@ -99,6 +99,9 @@
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<!--
********************************
16 years, 9 months
JBoss-OSGI SVN: r95111 - in projects/jboss-osgi: trunk/reactor/deployment and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-10-19 08:41:12 -0400 (Mon, 19 Oct 2009)
New Revision: 95111
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java
projects/jboss-osgi/trunk/reactor/deployment/src/test/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/
projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
Removed:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java
projects/jboss-osgi/trunk/reactor/deployment/.classpath
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/DeploymentServicesActivator.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Add initial interceptor impl
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-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/integration/AbstractMicrocontainerService.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -116,7 +116,7 @@
public boolean undeploy(URL url) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
- Deployment dep = registry.getBundleDeployment(url);
+ Deployment dep = registry.getDeployment(url);
if (dep == null)
{
logWarning("Package not deployed: " + url);
@@ -154,7 +154,7 @@
VirtualFile file = VFS.createNewRoot(dep.getLocation());
VFSDeployment vfsdep = deploymentFactory.createVFSDeployment(file);
dep.addAttachment(VFSDeployment.class, vfsdep);
- registry.registerBundleDeployment(dep);
+ registry.registerDeployment(dep);
depList.add(vfsdep);
MutableAttachments att = (MutableAttachments)vfsdep.getPredeterminedManagedObjects();
@@ -194,7 +194,7 @@
for (Deployment dep : depArr)
{
- registry.unregisterBundleDeployment(dep);
+ registry.unregisterDeployment(dep);
VFSDeployment vfsdep = dep.getAttachment(VFSDeployment.class);
mainDeployer.removeDeployment(vfsdep.getName());
}
Modified: projects/jboss-osgi/trunk/reactor/deployment/.classpath
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/.classpath 2009-10-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/.classpath 2009-10-19 12:41:12 UTC (rev 95111)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
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-10-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/deployer/DeploymentRegistryService.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -40,21 +40,21 @@
* Create a bundle deployment from the given bundle URL
* @return null, if this service does not maintain the bundle deployment
*/
- Deployment getBundleDeployment(URL url);
+ Deployment getDeployment(URL url);
/**
* Get the bundle deployment for the given bundle symbolicName and version
* @return null, if this service does not maintain the bundle deployment
*/
- Deployment getBundleDeployment(String symbolicName, Version version);
+ Deployment getDeployment(String symbolicName, Version version);
/**
* Register a bundle deployment
*/
- void registerBundleDeployment(Deployment dep);
+ void registerDeployment(Deployment dep);
/**
* Unregister a bundle deployment
*/
- void unregisterBundleDeployment(Deployment dep);
+ void unregisterDeployment(Deployment dep);
}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java 2009-10-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -1,49 +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.osgi.deployment.interceptor;
-
-import org.jboss.osgi.deployment.common.Deployment;
-
-//$Id$
-
-
-/**
- * An OSGi deployer
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface DeploymentInterceptor
-{
- enum Phase {
- BEFORE_INSTALLED,
- AFTER_INSTALLED,
- BEFORE_RESOLVED,
- AFTER_RESOLVED,
- BEFORE_ACTIVE,
- AFTER_ACTIVE
- }
-
- void deploy(Deployment dep);
-
- void undeploy(Deployment dep);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java 2009-10-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -1,39 +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.osgi.deployment.interceptor;
-
-
-//$Id$
-
-
-/**
- * The deployers service
- *
- * @author thomas.diesler(a)jboss.com
- * @since 15-Oct-2009
- */
-public interface DeploymentInterceptorService
-{
- void addInterceptor(DeploymentInterceptor deployer);
-
- void removeInterceptor(DeploymentInterceptor deployer);
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java (from rev 95096, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptor.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptor.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -0,0 +1,69 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+import java.util.Set;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.osgi.framework.BundleException;
+
+/**
+ * An OSGi bundle lifecycle interceptor.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public interface LifecycleInterceptor
+{
+ /**
+ * Get the relative order of this interceptor
+ */
+ int getRelativeOrder();
+
+ /**
+ * Get the required set of inputs.
+ *
+ * @return null if there are no inputs required
+ */
+ Set<Class<?>> getInput();
+
+ /**
+ * Get the provided set of outputs.
+ *
+ * @return null if there are no outputs provided
+ */
+ Set<Class<?>> getOutput();
+
+ /**
+ * Called by the {@link LifecycleInterceptorService} when the
+ * given bundle is about to change to the given state
+ *
+ * The deployment that represents the bundle has the {@link Bundle}
+ * object attached.
+ *
+ * @param state The future state of the bundle
+ * @param dep The deployment that represents the bundle
+ */
+ void invoke(int state, Deployment dep) throws BundleException;
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -0,0 +1,102 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.osgi.framework.BundleException;
+
+/**
+ * A basic implementation of a LifecycleInterceptor.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public class LifecycleInterceptorBase implements LifecycleInterceptor
+{
+ private Set<Class<?>> input;
+ private Set<Class<?>> output;
+
+ /**
+ * No relative order
+ * @return 0
+ */
+ public int getRelativeOrder()
+ {
+ return 0;
+ }
+
+ /**
+ * Get the required set of inputs.
+ *
+ * @return null if there are no inputs required
+ */
+ public Set<Class<?>> getInput()
+ {
+ return input;
+ }
+
+ /**
+ * Get the provided set of outputs.
+ *
+ * @return null if there are no outputs provided
+ */
+ public Set<Class<?>> getOutput()
+ {
+ return output;
+ }
+
+ /**
+ * Add an input requirement.
+ */
+ public void addInput(Class<?> in)
+ {
+ if (input == null)
+ input = new HashSet<Class<?>>();
+
+ input.add(in);
+ }
+
+ /**
+ * Add an output capability.
+ */
+ public void addOutput(Class<?> out)
+ {
+ if (output == null)
+ output = new HashSet<Class<?>>();
+
+ output.add(out);
+ }
+
+ /**
+ * Does nothing.
+ * Overwrite to provide a meaningful implementation.
+ */
+ public void invoke(int state, Deployment dep) throws BundleException
+ {
+ // do nothing
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorBase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java (from rev 95096, projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/DeploymentInterceptorService.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/LifecycleInterceptorService.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -0,0 +1,62 @@
+/*
+ * 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.osgi.deployment.interceptor;
+
+//$Id$
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * A service that manages bundle lifecycle interceptors.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public interface LifecycleInterceptorService
+{
+ /**
+ * Add a LifecycleInterceptor to the service.
+ *
+ * The interceptor is added according to its input requirements
+ * and relative order.
+ *
+ * @param interceptor The interceptor
+ */
+ void addInterceptor(LifecycleInterceptor interceptor);
+
+ /**
+ * Remove an LifecycleInterceptor to the service.
+ *
+ * @param interceptor The interceptor
+ */
+ void removeInterceptor(LifecycleInterceptor interceptor);
+
+ /**
+ * Invoke the interceptor chain for the given bundle state change.
+ *
+ * @param state The future state of the bundle
+ * @param bundle The bundle that changes state
+ * @throws BundleException
+ */
+ void invokeInterceptorChain(int state, Bundle bundle) throws BundleException;
+}
\ 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-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentRegistryServiceImpl.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -47,17 +47,17 @@
{
}
- public void registerBundleDeployment(Deployment dep)
+ public void registerDeployment(Deployment dep)
{
deployments.add(dep);
}
- public void unregisterBundleDeployment(Deployment dep)
+ public void unregisterDeployment(Deployment dep)
{
deployments.remove(dep);
}
- public Deployment getBundleDeployment(String symbolicName, Version version)
+ public Deployment getDeployment(String symbolicName, Version version)
{
if (symbolicName == null)
throw new IllegalArgumentException("Cannot obtain bundle deployment for null symbolic name");
@@ -77,7 +77,7 @@
return dep;
}
- public Deployment getBundleDeployment(URL url)
+ public Deployment getDeployment(URL url)
{
if (url == null)
throw new IllegalArgumentException("Cannot obtain bundle deployment for: null");
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java 2009-10-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/DeploymentServicesActivator.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -31,9 +31,7 @@
import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
-import org.jboss.osgi.deployment.interceptor.DeploymentInterceptor;
-import org.jboss.osgi.deployment.interceptor.DeploymentInterceptorService;
-import org.jboss.osgi.spi.NotImplementedException;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -51,25 +49,15 @@
{
// Provide logging
private Logger log = LoggerFactory.getLogger(DeploymentServicesActivator.class);
-
+
public void start(BundleContext context) throws Exception
{
// Register the deployer related services
registerDeployerService(context);
-
- DeploymentInterceptorService service = new DeploymentInterceptorService()
- {
- public void removeInterceptor(DeploymentInterceptor deployer)
- {
- throw new NotImplementedException();
- }
-
- public void addInterceptor(DeploymentInterceptor deployer)
- {
- throw new NotImplementedException();
- }
- };
- context.registerService(DeploymentInterceptorService.class.getName(), service, null);
+
+ // Register the lifecycle interceptor related services
+ LifecycleInterceptorService service = new LifecycleInterceptorServiceImpl(context);
+ context.registerService(LifecycleInterceptorService.class.getName(), service, null);
}
public void stop(BundleContext context) throws Exception
@@ -81,7 +69,7 @@
// Register the DeploymentRegistryService
DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
context.registerService(DeploymentRegistryService.class.getName(), registry, null);
-
+
// Register the SystemDeployerService
Properties props = new Properties();
props.put("provider", "system");
@@ -148,11 +136,11 @@
ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
if (sref == null)
throw new IllegalStateException("Cannot obtain deployer service");
-
+
// Unregister the DeployerService with a potentialy lower ranking
if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
-
+
// Register the DeployerService with the highest ranking
DeployerService service = (DeployerService)context.getService(sref);
StandardMBean mbean = new StandardMBean(service, DeployerService.class);
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -0,0 +1,195 @@
+/*
+ * 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.osgi.deployment.internal;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+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;
+
+/**
+ * A basic service that manages bundle lifecycle interceptors.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 15-Oct-2009
+ */
+public class LifecycleInterceptorServiceImpl implements LifecycleInterceptorService
+{
+ private BundleContext context;
+
+ // The interceptor chain
+ private List<LifecycleInterceptor> interceptorChain = new ArrayList<LifecycleInterceptor>();
+
+ public LifecycleInterceptorServiceImpl(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void addInterceptor(LifecycleInterceptor interceptor)
+ {
+ synchronized (interceptorChain)
+ {
+ Set<LifecycleInterceptor> unsortedSet = new HashSet<LifecycleInterceptor>();
+ unsortedSet.addAll(interceptorChain);
+ unsortedSet.add(interceptor);
+
+ List<LifecycleInterceptor> sortedList = new ArrayList<LifecycleInterceptor>();
+
+ // Add interceptors with no inputs first
+ Iterator<LifecycleInterceptor> itUnsorted = unsortedSet.iterator();
+ while(itUnsorted.hasNext())
+ {
+ LifecycleInterceptor aux = itUnsorted.next();
+ if (aux.getInput() == null)
+ {
+ addWithRelativeOrder(sortedList, aux);
+ itUnsorted.remove();
+ }
+ }
+
+ // Get the set of provided outputs
+ Set<Class<?>> providedOutputs = new HashSet<Class<?>>();
+ for (LifecycleInterceptor aux : sortedList)
+ {
+ Set<Class<?>> auxOutput = aux.getOutput();
+ if (auxOutput != null)
+ providedOutputs.addAll(auxOutput);
+ }
+
+ // Add interceptors with sattisfied inputs
+ itUnsorted = unsortedSet.iterator();
+ while(itUnsorted.hasNext())
+ {
+ LifecycleInterceptor aux = itUnsorted.next();
+ Set<Class<?>> input = aux.getInput();
+ if (input == null)
+ throw new IllegalStateException("Interceptor with no inputs should have been added already");
+
+ if (providedOutputs.containsAll(input))
+ {
+ addWithRelativeOrder(sortedList, aux);
+ itUnsorted.remove();
+ }
+ }
+
+ // Add the remaining interceptors
+ for (LifecycleInterceptor aux : unsortedSet)
+ {
+ addWithRelativeOrder(sortedList, aux);
+ }
+
+ // Use the sorted result as the new interceptor chain
+ interceptorChain.clear();
+ interceptorChain.addAll(sortedList);
+ }
+ }
+
+ private void addWithRelativeOrder(List<LifecycleInterceptor> sortedList, LifecycleInterceptor interceptor)
+ {
+ Set<Class<?>> providedOutputs = new HashSet<Class<?>>();
+ int relOrder = interceptor.getRelativeOrder();
+ Set<Class<?>> input = interceptor.getInput();
+
+ for (int i = 0; i < sortedList.size(); i++)
+ {
+ LifecycleInterceptor aux = sortedList.get(i);
+ int auxOrder = aux.getRelativeOrder();
+
+ // Add if all inputs are satisfied and the rel order is less or equal
+ boolean inputsProvided = (input == null || providedOutputs.containsAll(input));
+ if (inputsProvided && relOrder <= auxOrder)
+ {
+ sortedList.add(i, interceptor);
+ return;
+ }
+
+ // Add the this interceptor output the list
+ Set<Class<?>> auxOutput = aux.getOutput();
+ if (auxOutput != null)
+ providedOutputs.addAll(auxOutput);
+ }
+
+ // If not added yet, add at end
+ sortedList.add(interceptor);
+ }
+
+ public void removeInterceptor(LifecycleInterceptor interceptor)
+ {
+ synchronized (interceptorChain)
+ {
+ interceptorChain.remove(interceptor);
+ }
+ }
+
+ public List<LifecycleInterceptor> getInterceptorChain()
+ {
+ synchronized (interceptorChain)
+ {
+ return Collections.unmodifiableList(interceptorChain);
+ }
+ }
+
+ public void invokeInterceptorChain(int state, Bundle bundle) throws BundleException
+ {
+ String name = bundle.getSymbolicName();
+ Version version = bundle.getVersion();
+ Deployment dep = getDeploymentRegistryService().getDeployment(name, version);
+ if (dep == null)
+ throw new IllegalStateException("Cannot get deployment for: " + name + "-" + version);
+
+ // Attach the bundle if not already done so
+ Bundle attBundle = dep.getAttachment(Bundle.class);
+ if (attBundle == null)
+ dep.addAttachment(Bundle.class, bundle);
+
+ synchronized (interceptorChain)
+ {
+ for (LifecycleInterceptor interceptor : interceptorChain)
+ {
+ interceptor.invoke(state, dep);
+ }
+ }
+ }
+
+ private DeploymentRegistryService getDeploymentRegistryService()
+ {
+ ServiceReference sref = context.getServiceReference(DeploymentRegistryService.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("Cannot obtain deployment registry service");
+
+ return (DeploymentRegistryService)context.getService(sref);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/LifecycleInterceptorServiceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-19 12:23:47 UTC (rev 95110)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -88,7 +88,7 @@
if (dep.isAutoStart())
resolvableBundles.add(bundle);
- registry.registerBundleDeployment(dep);
+ registry.registerDeployment(dep);
}
catch (BundleException ex)
{
@@ -155,7 +155,7 @@
Bundle bundle = getBundle(dep);
if (bundle != null)
{
- registry.unregisterBundleDeployment(dep);
+ registry.unregisterDeployment(dep);
unregisterManagedBundle(bundle);
bundle.uninstall();
@@ -177,7 +177,7 @@
public boolean undeploy(URL url) throws BundleException
{
DeploymentRegistryService registry = getDeploymentRegistry();
- Deployment dep = registry.getBundleDeployment(url);
+ Deployment dep = registry.getDeployment(url);
if (dep != null)
{
undeploy(new Deployment[] { dep });
Added: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java 2009-10-19 12:41:12 UTC (rev 95111)
@@ -0,0 +1,110 @@
+/*
+ * 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.deployment.interceptor;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorBase;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+import org.jboss.osgi.deployment.internal.LifecycleInterceptorServiceImpl;
+import org.junit.Test;
+
+/**
+ * Test the {@link LifecycleInterceptorService}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Oct-2009
+ */
+public class LifecycleInterceptorTestCase
+{
+ @Test
+ public void testRelativeOrder()
+ {
+ LifecycleInterceptor rel000 = new LifecycleInterceptorBase();
+ LifecycleInterceptor rel100 = new LifecycleInterceptorBase()
+ {
+ public int getRelativeOrder()
+ {
+ return 100;
+ }
+ };
+
+ // Add ordered
+ LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(null);
+ service.addInterceptor(rel000);
+ service.addInterceptor(rel100);
+
+ List<LifecycleInterceptor> chain = service.getInterceptorChain();
+ assertEquals(2, chain.size());
+ assertEquals(0, chain.get(0).getRelativeOrder());
+ assertEquals(100, chain.get(1).getRelativeOrder());
+
+ // Add unordered
+ service = new LifecycleInterceptorServiceImpl(null);
+ service.addInterceptor(rel100);
+ service.addInterceptor(rel000);
+
+ chain = service.getInterceptorChain();
+ assertEquals(2, chain.size());
+ assertEquals(0, chain.get(0).getRelativeOrder());
+ assertEquals(100, chain.get(1).getRelativeOrder());
+ }
+
+ @Test
+ public void testInputOutput()
+ {
+ class A
+ {
+ }
+
+ LifecycleInterceptorBase inA = new LifecycleInterceptorBase();
+ inA.addInput(A.class);
+
+ LifecycleInterceptorBase outA = new LifecycleInterceptorBase();
+ outA.addOutput(A.class);
+
+ // Add ordered
+ LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(null);
+ service.addInterceptor(outA);
+ service.addInterceptor(inA);
+
+ List<LifecycleInterceptor> chain = service.getInterceptorChain();
+ assertEquals(2, chain.size());
+ assertEquals(outA, chain.get(0));
+ assertEquals(inA, chain.get(1));
+
+ // Add unordered
+ service = new LifecycleInterceptorServiceImpl(null);
+ service.addInterceptor(inA);
+ service.addInterceptor(outA);
+
+ chain = service.getInterceptorChain();
+ assertEquals(2, chain.size());
+ assertEquals(outA, chain.get(0));
+ assertEquals(inA, chain.get(1));
+ }
+}
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
16 years, 9 months