JBoss-OSGI SVN: r90950 - in projects/jboss-osgi/trunk/distribution: src/main/resources/installer and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 16:38:39 -0400 (Wed, 08 Jul 2009)
New Revision: 90950
Modified:
projects/jboss-osgi/trunk/distribution/pom.xml
projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
Log:
Install husky in runtime
Modified: projects/jboss-osgi/trunk/distribution/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/pom.xml 2009-07-08 20:02:53 UTC (rev 90949)
+++ projects/jboss-osgi/trunk/distribution/pom.xml 2009-07-08 20:38:39 UTC (rev 90950)
@@ -44,6 +44,22 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
+ <version>${version.jboss.osgi.husky}</version>
+ <classifier>sources</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
+ <version>${version.jboss.osgi.husky}</version>
+ <classifier>javadoc</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-integration-jbossas</artifactId>
</dependency>
<dependency>
Modified: projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-07-08 20:02:53 UTC (rev 90949)
+++ projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-07-08 20:38:39 UTC (rev 90950)
@@ -121,6 +121,7 @@
<include name="jboss-osgi-runtime-felix.jar" />
<include name="jboss-osgi-spi.jar" />
<include name="jboss-osgi-common.jar" />
+ <include name="jboss-osgi-husky-harness.jar" />
<include name="jboss-osgi-webconsole.jar" />
<include name="org.apache.felix.framework.jar" />
<include name="org.apache.felix.configadmin.jar" />
@@ -187,6 +188,7 @@
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/default/deploy" override="true">
<!-- default -->
<include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-husky-harness.jar" />
<include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-jndi.jar" />
</fileset>
@@ -196,6 +198,7 @@
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/web/deploy" override="true">
<!-- default -->
<include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-husky-harness.jar" />
<include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-jndi.jar" />
<!-- web -->
@@ -210,6 +213,7 @@
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/all/deploy" override="true">
<!-- default -->
<include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-husky-harness.jar" />
<include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-jndi.jar" />
<!-- web -->
16 years, 11 months
JBoss-OSGI SVN: r90947 - projects/jboss-osgi/trunk/hudson.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 15:08:47 -0400 (Wed, 08 Jul 2009)
New Revision: 90947
Modified:
projects/jboss-osgi/trunk/hudson/ant.properties.example
Log:
Downgrade to hudson 1.300
https://hudson.dev.java.net/issues/show_bug.cgi?id=3936
Modified: projects/jboss-osgi/trunk/hudson/ant.properties.example
===================================================================
--- projects/jboss-osgi/trunk/hudson/ant.properties.example 2009-07-08 18:57:10 UTC (rev 90946)
+++ projects/jboss-osgi/trunk/hudson/ant.properties.example 2009-07-08 19:08:47 UTC (rev 90947)
@@ -31,7 +31,6 @@
hudson.mail.recipients=
hudson.smtp.host=localhost
-# Hudson (1.314)
-apache-tomcat=6.0.18
-sun-hudson=2402/137854
-~
+# Hudson (1.300)
+apache-tomcat=5.5.20
+sun-hudson=2402/132585
\ No newline at end of file
16 years, 11 months
JBoss-OSGI SVN: r90946 - projects/jboss-osgi/trunk/hudson.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 14:57:10 -0400 (Wed, 08 Jul 2009)
New Revision: 90946
Modified:
projects/jboss-osgi/trunk/hudson/build.xml
Log:
overwrite hudson.war on update
Modified: projects/jboss-osgi/trunk/hudson/build.xml
===================================================================
--- projects/jboss-osgi/trunk/hudson/build.xml 2009-07-08 18:33:34 UTC (rev 90945)
+++ projects/jboss-osgi/trunk/hudson/build.xml 2009-07-08 18:57:10 UTC (rev 90946)
@@ -125,7 +125,7 @@
<target name="hudson-update" depends="init-thirdparty">
<get src="https://hudson.dev.java.net/files/documents/${sun-hudson}/hudson.war" dest="${thirdparty.dir}/hudson.war" usetimestamp="false" verbose="true"/>
<delete dir="${hudson.tomcat}/webapps/hudson"/>
- <copy todir="${hudson.tomcat}/webapps" file="${thirdparty.dir}/hudson.war"/>
+ <copy todir="${hudson.tomcat}/webapps" file="${thirdparty.dir}/hudson.war" overwrite="true"/>
</target>
<!--
16 years, 11 months
JBoss-OSGI SVN: r90936 - projects/jboss-osgi/trunk/hudson/hudson-home.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 10:43:10 -0400 (Wed, 08 Jul 2009)
New Revision: 90936
Modified:
projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
Log:
Revert to runtime all, because of web console
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-07-08 14:36:05 UTC (rev 90935)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-07-08 14:43:10 UTC (rev 90936)
@@ -10,22 +10,6 @@
HUDSONDIR=$OSGIDIR/hudson
HUDSONBIN=$HUDSONDIR/hudson-home/bin
-case "$FRAMEWORK" in
- 'equinox')
- RUNTIME_SERVER=minimal
- ;;
- 'felix')
- RUNTIME_SERVER=all
- ;;
- 'knopflerfish')
- RUNTIME_SERVER=minimal
- ;;
- *)
- echo "Unsupported framework: $FRAMEWORK"
- exit 1
- ;;
-esac
-
case "$CONTAINER" in
'jboss501')
SERVER_NAME=default
@@ -68,7 +52,7 @@
cp $HUDSONBIN/run-with-pid.sh $RUNTIME_HOME/bin/run.sh
;;
'runtime')
- SERVER_NAME=$RUNTIME_SERVER
+ SERVER_NAME=all
RUNTIME_HOME=$DISTRODIR/auto-install-dest/runtime
RUNTIME_LOG=$RUNTIME_HOME/server/$SERVER_NAME/log/server.log
;;
16 years, 11 months
JBoss-OSGI SVN: r90935 - projects/jboss-osgi/trunk/hudson/hudson-home.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 10:36:05 -0400 (Wed, 08 Jul 2009)
New Revision: 90935
Modified:
projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
Log:
Add RUNTIME_SERVER
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-07-08 14:07:46 UTC (rev 90934)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-07-08 14:36:05 UTC (rev 90935)
@@ -10,6 +10,22 @@
HUDSONDIR=$OSGIDIR/hudson
HUDSONBIN=$HUDSONDIR/hudson-home/bin
+case "$FRAMEWORK" in
+ 'equinox')
+ RUNTIME_SERVER=minimal
+ ;;
+ 'felix')
+ RUNTIME_SERVER=all
+ ;;
+ 'knopflerfish')
+ RUNTIME_SERVER=minimal
+ ;;
+ *)
+ echo "Unsupported framework: $FRAMEWORK"
+ exit 1
+ ;;
+esac
+
case "$CONTAINER" in
'jboss501')
SERVER_NAME=default
@@ -52,7 +68,7 @@
cp $HUDSONBIN/run-with-pid.sh $RUNTIME_HOME/bin/run.sh
;;
'runtime')
- SERVER_NAME=all
+ SERVER_NAME=$RUNTIME_SERVER
RUNTIME_HOME=$DISTRODIR/auto-install-dest/runtime
RUNTIME_LOG=$RUNTIME_HOME/server/$SERVER_NAME/log/server.log
;;
16 years, 11 months
JBoss-OSGI SVN: r90934 - projects/jboss-osgi/trunk/hudson.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 10:07:46 -0400 (Wed, 08 Jul 2009)
New Revision: 90934
Modified:
projects/jboss-osgi/trunk/hudson/ant.properties.example
Log:
Upgrade to hudson=1.314
Modified: projects/jboss-osgi/trunk/hudson/ant.properties.example
===================================================================
--- projects/jboss-osgi/trunk/hudson/ant.properties.example 2009-07-08 13:46:51 UTC (rev 90933)
+++ projects/jboss-osgi/trunk/hudson/ant.properties.example 2009-07-08 14:07:46 UTC (rev 90934)
@@ -31,7 +31,7 @@
hudson.mail.recipients=
hudson.smtp.host=localhost
-# Hudson (1.307)
+# Hudson (1.314)
apache-tomcat=6.0.18
-sun-hudson=2402/135231
+sun-hudson=2402/137854
~
16 years, 11 months
JBoss-OSGI SVN: r90927 - in projects/jboss-osgi: projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 07:56:32 -0400 (Wed, 08 Jul 2009)
New Revision: 90927
Added:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java
Modified:
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
Log:
[JBOSGI-99] No explicit control over bundle.start()
Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -23,20 +23,14 @@
//$Id: SystemDeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
-import java.io.IOException;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
import org.jboss.osgi.spi.service.DeployerService;
import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
/**
* A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
@@ -52,30 +46,6 @@
{
}
- public BundleDeployment createBundleDeployment(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 BundleDeployment(url, symbolicName, version);
- }
-
public void registerBundleDeployment(BundleDeployment dep)
{
deployments.add(dep);
Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -32,6 +32,7 @@
import org.jboss.osgi.spi.service.DeployerService;
import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -134,8 +135,7 @@
public void deploy(URL url) throws BundleException
{
- DeploymentRegistryService registry = getDeploymentRegistry();
- BundleDeployment dep = registry.createBundleDeployment(url);
+ BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
deploy(new BundleDeployment[] { dep });
}
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -38,9 +38,9 @@
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.service.DeploymentScannerService;
import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -64,7 +64,6 @@
private long scanCount;
private long lastChange;
- private DeploymentRegistryService registry;
private DeployerService deployer;
private ScannerThread scannerThread;
private List<BundleDeployment> lastScan = new ArrayList<BundleDeployment>();
@@ -81,10 +80,6 @@
ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
deployer = (DeployerService)context.getService(sref);
- // Get the DeploymentRegistryService
- sref = context.getServiceReference(DeploymentRegistryService.class.getName());
- registry = (DeploymentRegistryService)context.getService(sref);
-
initScanner(context);
}
@@ -260,7 +255,7 @@
try
{
// hot-deploy bundles are started automatically
- dep = registry.createBundleDeployment(bundleURL);
+ dep = BundleDeploymentFactory.createBundleDeployment(bundleURL);
dep.setAutoStart(true);
deploymentCache.put(bundleURL.toExternalForm(), dep);
Modified: projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -30,8 +30,8 @@
import org.apache.felix.webconsole.internal.core.InstallAction;
import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -60,16 +60,13 @@
}
final DeployerService deployer = (DeployerService)context.getService(sref);
- sref = context.getServiceReference(DeploymentRegistryService.class.getName());
- final DeploymentRegistryService registry = (DeploymentRegistryService)context.getService(sref);
-
Thread t = new InstallHelper(this, "Background Install " + bundleFile, bundleFile, refreshPackages)
{
protected Bundle doRun(InputStream bundleStream) throws BundleException
{
URL bundleURL = getBundleURL(bundleFile);
- BundleDeployment dep = registry.createBundleDeployment(bundleURL);
+ BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(bundleURL);
dep.setStartLevel(startlevel);
dep.setAutoStart(doStart);
Modified: projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -67,7 +67,7 @@
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
Boolean propAutoStart = unit.getAttachment(Constants.PROPERTY_AUTO_START, Boolean.class);
- if (propAutoStart == null || propAutoStart == Boolean.TRUE)
+ if (propAutoStart == null || Boolean.TRUE.equals(propAutoStart))
{
String propDeferredStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
if (Boolean.parseBoolean(propDeferredStart != null ? propDeferredStart : "true") == true)
Modified: projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -54,6 +54,7 @@
import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.jboss.osgi.spi.util.BundleDeployment;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleContext;
@@ -110,8 +111,7 @@
public void deploy(URL url) throws BundleException
{
- DeploymentRegistryService registry = getDeploymentRegistry();
- BundleDeployment dep = registry.createBundleDeployment(url);
+ BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
deploy(new BundleDeployment[] { dep });
}
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -26,7 +26,6 @@
import java.net.URL;
import org.jboss.osgi.spi.util.BundleDeployment;
-import org.osgi.framework.BundleException;
/**
* A Service to register/unregister bundle deployments.
@@ -38,11 +37,6 @@
{
/**
* Create a bundle deployment from the given bundle URL
- */
- BundleDeployment createBundleDeployment(URL url) throws BundleException;
-
- /**
- * Create a bundle deployment from the given bundle URL
* @return null, if this service does not maintain the bundle deployment
*/
BundleDeployment getBundleDeployment(URL url);
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -197,7 +197,7 @@
invokeDeployerService("undeploy", archiveURL);
}
- private void invokeDeployerService(String method, URL archiveURL) throws Exception
+ protected void invokeDeployerService(String method, URL archiveURL) throws Exception
{
ObjectName oname = new ObjectName("jboss.osgi:service=DeployerService");
getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -23,6 +23,7 @@
// $Id$
+import java.net.URL;
import java.util.HashSet;
import java.util.Set;
@@ -44,6 +45,7 @@
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiServiceReference;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.osgi.spi.util.BundleDeploymentFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
@@ -94,15 +96,39 @@
@Override
public void deploy(String location) throws Exception
{
- super.deploy(location);
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+
+ if (isBundleArchive(location))
+ invokeDeployerService("deploy", archiveURL);
+ else
+ invokeMainDeployer("deploy", archiveURL);
}
@Override
public void undeploy(String location) throws Exception
{
- super.undeploy(location);
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+
+ if (isBundleArchive(location))
+ invokeDeployerService("undeploy", archiveURL);
+ else
+ invokeMainDeployer("undeploy", archiveURL);
}
+ private boolean isBundleArchive(String location)
+ {
+ try
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ BundleDeploymentFactory.createBundleDeployment(archiveURL);
+ return true;
+ }
+ catch (BundleException ex)
+ {
+ return false;
+ }
+ }
+
public OSGiBundle[] getBundles()
{
try
@@ -283,4 +309,10 @@
}
};
}
+
+ private void invokeMainDeployer(String method, URL archiveURL) throws Exception
+ {
+ ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
+ getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
+ }
}
Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeploymentFactory.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -0,0 +1,66 @@
+/*
+ * 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.spi.util;
+
+//$Id: BundleDeployment.java 90925 2009-07-08 10:12:31Z thomas.diesler(a)jboss.com $
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * A factory for bundle deployments.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public abstract class BundleDeploymentFactory
+{
+ public static BundleDeployment createBundleDeployment(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 BundleDeployment(url, symbolicName, version);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java 2009-07-08 10:16:16 UTC (rev 90926)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java 2009-07-08 11:56:32 UTC (rev 90927)
@@ -71,9 +71,6 @@
{
((RemoteRuntime)runtime).undeploy("jbosgi36-mbean.jar");
- if (bundle != null)
- bundle.uninstall();
-
runtime.shutdown();
}
16 years, 11 months
JBoss-OSGI SVN: r90926 - projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 06:16:16 -0400 (Wed, 08 Jul 2009)
New Revision: 90926
Modified:
projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
Log:
[JBOSGI-99] No explicit control over bundle.start()
Modified: projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-07-08 10:12:31 UTC (rev 90925)
+++ projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-07-08 10:16:16 UTC (rev 90926)
@@ -67,7 +67,7 @@
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
Boolean propAutoStart = unit.getAttachment(Constants.PROPERTY_AUTO_START, Boolean.class);
- if (propAutoStart == Boolean.TRUE)
+ if (propAutoStart == null || propAutoStart == Boolean.TRUE)
{
String propDeferredStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
if (Boolean.parseBoolean(propDeferredStart != null ? propDeferredStart : "true") == true)
16 years, 11 months
JBoss-OSGI SVN: r90925 - in projects/jboss-osgi: projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal and 13 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 06:12:31 -0400 (Wed, 08 Jul 2009)
New Revision: 90925
Added:
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi99-bundleA.bnd
Removed:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI108TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/SomeBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/SomeBeanMBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleB/
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi108-bundleA.bnd
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi108-bundleB.bnd
Modified:
projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/BundlesPlugin.java
projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/Constants.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java
projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java
Log:
[JBOSGI-99] No explicit control over bundle.start()
Modified: projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2009-07-08 10:12:31 UTC (rev 90925)
@@ -76,6 +76,7 @@
org.jboss.osgi.spi.util;version="1.0",
org.osgi.framework;version=1.4,
org.osgi.service.log;version=1.3,
+ org.osgi.service.startlevel;version=1.1,
org.osgi.util.tracker
</Import-Package>
</instructions>
Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -30,6 +30,7 @@
import javax.management.StandardMBean;
import org.jboss.osgi.spi.service.DeployerService;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
@@ -62,6 +63,10 @@
protected DeployerService registerDeployerServices(BundleContext context)
{
+ // 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");
Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -26,8 +26,7 @@
import java.net.URL;
import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.osgi.framework.Bundle;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
@@ -50,27 +49,9 @@
this.context = context;
}
- public Bundle getBundle(BundleInfo info)
+ public void deploy(BundleDeployment[] bundles) throws BundleException
{
DeployerService service = getDefaultDeployerService();
- return service.getBundle(info);
- }
-
- public BundleInfo getBundleInfo(URL url) throws BundleException
- {
- DeployerService service = getDefaultDeployerService();
- return service.getBundleInfo(url);
- }
-
- public BundleInfo getBundleInfo(Bundle bundle)
- {
- DeployerService service = getDefaultDeployerService();
- return service.getBundleInfo(bundle);
- }
-
- public void deploy(BundleInfo[] bundles) throws BundleException
- {
- DeployerService service = getDefaultDeployerService();
service.deploy(bundles);
}
@@ -80,9 +61,9 @@
service.deploy(url);
}
- public void undeploy(BundleInfo[] bundles) throws BundleException
+ public void undeploy(BundleDeployment[] bundles) throws BundleException
{
- for (BundleInfo info : bundles)
+ for (BundleDeployment info : bundles)
undeploy(info.getLocation());
}
Added: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -0,0 +1,126 @@
+/*
+ * 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.common.internal;
+
+//$Id: SystemDeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.jboss.osgi.spi.service.DeployerService;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
+import org.jboss.osgi.spi.util.BundleDeployment;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class DeploymentRegistryServiceImpl implements DeploymentRegistryService
+{
+ private Set<BundleDeployment> deployments = new HashSet<BundleDeployment>();
+
+ public DeploymentRegistryServiceImpl(BundleContext context)
+ {
+ }
+
+ public BundleDeployment createBundleDeployment(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 BundleDeployment(url, symbolicName, version);
+ }
+
+ public void registerBundleDeployment(BundleDeployment dep)
+ {
+ deployments.add(dep);
+ }
+
+ public void unregisterBundleDeployment(BundleDeployment dep)
+ {
+ deployments.remove(dep);
+ }
+
+ public BundleDeployment getBundleDeployment(String symbolicName, String version)
+ {
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Cannot obtain bundle deployment for null symbolic name");
+
+ BundleDeployment dep = null;
+ for (BundleDeployment auxDep : deployments)
+ {
+ String auxName = auxDep.getSymbolicName();
+ String auxVersion = auxDep.getVersion();
+ if (symbolicName.equals(auxName) && (version == null || version.equals(auxVersion)))
+ {
+ dep = auxDep;
+ break;
+ }
+ }
+
+ return dep;
+ }
+
+ public BundleDeployment getBundleDeployment(URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("Cannot obtain bundle deployment for: null");
+
+ BundleDeployment dep = null;
+ for (BundleDeployment auxDep : deployments)
+ {
+ if (url.equals(auxDep.getLocation()))
+ {
+ dep = auxDep;
+ break;
+ }
+ }
+
+ return dep;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -23,27 +23,23 @@
//$Id$
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.spi.management.ManagedBundleService;
import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
/**
* A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
@@ -55,7 +51,8 @@
{
private LogServiceTracker log;
private BundleContext context;
- private Map<String, Bundle> deployments = new HashMap<String, Bundle>();
+ private ServiceTracker registryTracker;
+ private ServiceTracker startLevelTracker;
public SystemDeployerService(BundleContext context)
{
@@ -63,165 +60,122 @@
this.context = context;
}
- public BundleInfo getBundleInfo(URL url) throws BundleException
+ public void deploy(BundleDeployment[] depArr) 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 BundleInfo(url, symbolicName, version);
- }
-
- public BundleInfo getBundleInfo(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Cannot obtain bundle info for: null");
+ DeploymentRegistryService registry = getDeploymentRegistry();
- URL location = null;
- for (String auxLoc : deployments.keySet())
+ Map<BundleDeployment, Bundle> bundleMap = new HashMap<BundleDeployment, Bundle>();
+ for (BundleDeployment dep : depArr)
{
- Bundle auxBnd = deployments.get(auxLoc);
- if (auxBnd.equals(bundle))
- {
- location = toURL(auxLoc);
- break;
- }
- }
-
- BundleInfo info = null;
- if (location != null)
- {
- String symbolicName = bundle.getSymbolicName();
- String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
- info = new BundleInfo(location, symbolicName, version);
- }
- return info;
- }
-
- public Bundle getBundle(BundleInfo info)
- {
- String symbolicName = info.getSymbolicName();
- String version = info.getVersion();
-
- Bundle bundle = null;
- for (Bundle aux : context.getBundles())
- {
- if (aux.getSymbolicName().equals(symbolicName))
- {
- String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
- if (version == null || version.equals(auxVersion))
- {
- bundle = aux;
- break;
- }
- }
- }
- return bundle;
- }
-
- public void deploy(BundleInfo[] bundleInfos) throws BundleException
- {
- // Install the NEW bundles
- List<Bundle> bundles = new ArrayList<Bundle>();
- for (BundleInfo info : bundleInfos)
- {
try
{
- String location = info.getLocation().toExternalForm();
+ String location = dep.getLocation().toExternalForm();
Bundle bundle = context.installBundle(location);
log.log(LogService.LOG_INFO, "Installed: " + bundle);
-
- deployments.put(location, bundle);
+
registerManagedBundle(bundle);
- bundles.add(bundle);
+ bundleMap.put(dep, bundle);
+
+ registry.registerBundleDeployment(dep);
}
catch (BundleException ex)
{
- log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info, ex);
+ log.log(LogService.LOG_ERROR, "Cannot install bundle: " + dep, ex);
}
}
// Start the installed bundles
- for (Bundle bundle : bundles)
+ for (BundleDeployment dep : depArr)
{
- try
+ Bundle bundle = bundleMap.get(dep);
+
+ StartLevel startLevel = getStartLevel();
+ if (dep.getStartLevel() > 0)
{
- log.log(LogService.LOG_DEBUG, "Start: " + bundle);
- bundle.start();
+ startLevel.setBundleStartLevel(bundle, dep.getStartLevel());
}
- catch (BundleException ex)
+
+ if (dep.isAutoStart())
{
- log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle, ex);
+ try
+ {
+ log.log(LogService.LOG_DEBUG, "Start: " + bundle);
+ bundle.start();
+ }
+ catch (BundleException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle, ex);
+ }
}
}
}
- public void undeploy(BundleInfo[] bundleInfos) throws BundleException
+ public void undeploy(BundleDeployment[] depArr) throws BundleException
{
- for (BundleInfo info : bundleInfos)
+ DeploymentRegistryService registry = getDeploymentRegistry();
+
+ for (BundleDeployment dep : depArr)
{
- URL location = info.getLocation();
- if (location != null)
+ Bundle bundle = getBundle(dep);
+ if (bundle != null)
{
- undeploy(location);
- }
- else
- {
- Bundle bundle = getBundle(info);
- if (bundle == null)
- throw new IllegalStateException("Cannot obtain bundle for: " + info);
+ registry.unregisterBundleDeployment(dep);
unregisterManagedBundle(bundle);
bundle.uninstall();
-
log.log(LogService.LOG_INFO, "Uninstalled: " + bundle);
}
+ else
+ {
+ log.log(LogService.LOG_WARNING, "Cannot obtain bundle for: " + dep);
+ }
}
}
- // Note, in contrary to deploy(BundleInfo[]) this
- // method does not start the bundle. The client
- // is expected to do that
public void deploy(URL url) throws BundleException
{
- Bundle bundle = context.installBundle(url.toExternalForm());
- log.log(LogService.LOG_INFO, "Installed: " + bundle);
- deployments.put(url.toExternalForm(), bundle);
- registerManagedBundle(bundle);
+ DeploymentRegistryService registry = getDeploymentRegistry();
+ BundleDeployment dep = registry.createBundleDeployment(url);
+ deploy(new BundleDeployment[] { dep });
}
- public boolean undeploy(URL url) throws BundleException
+ public boolean undeploy(URL url) throws BundleException
{
- Bundle bundle = deployments.remove(url.toExternalForm());
- if (bundle != null)
+ DeploymentRegistryService registry = getDeploymentRegistry();
+ BundleDeployment dep = registry.getBundleDeployment(url);
+ if (dep != null)
{
- unregisterManagedBundle(bundle);
- bundle.uninstall();
- log.log(LogService.LOG_INFO, "Uninstalled: " + bundle);
+ undeploy(new BundleDeployment[] { dep });
return true;
}
else
{
- log.log(LogService.LOG_WARNING, "Cannot find bundle for: " + url);
+ log.log(LogService.LOG_WARNING, "Cannot find deployment for: " + url);
return false;
}
}
+ private Bundle getBundle(BundleDeployment dep)
+ {
+ String symbolicName = dep.getSymbolicName();
+ String version = dep.getVersion();
+
+ Bundle bundle = null;
+ for (Bundle aux : context.getBundles())
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (version == null || version.equals(auxVersion))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+ return bundle;
+ }
+
private void registerManagedBundle(Bundle bundle)
{
ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
@@ -249,16 +203,24 @@
log.log(LogService.LOG_DEBUG, "No ManagedBundleService. Cannot unregister managed bundle: " + bundle);
}
}
-
- private URL toURL(String location)
+
+ private DeploymentRegistryService getDeploymentRegistry()
{
- try
+ if (registryTracker == null)
{
- return new URL(location);
+ registryTracker = new ServiceTracker(context, DeploymentRegistryService.class.getName(), null);
+ registryTracker.open();
}
- catch (MalformedURLException e)
+ return (DeploymentRegistryService)registryTracker.getService();
+ }
+
+ private StartLevel getStartLevel()
+ {
+ if (startLevelTracker == null)
{
- throw new IllegalArgumentException("Invalid URL location: " + location);
+ startLevelTracker = new ServiceTracker(context, StartLevel.class.getName(), null);
+ startLevelTracker.open();
}
+ return (StartLevel)startLevelTracker.getService();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -38,11 +38,13 @@
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.spi.service.DeployerService;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.service.DeploymentScannerService;
-import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -62,11 +64,12 @@
private long scanCount;
private long lastChange;
+ private DeploymentRegistryService registry;
private DeployerService deployer;
private ScannerThread scannerThread;
- private List<BundleInfo> lastScan = new ArrayList<BundleInfo>();
+ private List<BundleDeployment> lastScan = new ArrayList<BundleDeployment>();
private Set<ScanListener> listeners = new LinkedHashSet<ScanListener>();
- private Map<String, BundleInfo> bundleInfoCache = new HashMap<String, BundleInfo>();
+ private Map<String, BundleDeployment> deploymentCache = new HashMap<String, BundleDeployment>();
private boolean traceBundles = false;
public DeploymentScannerImpl(BundleContext context)
@@ -74,10 +77,14 @@
this.log = new LogServiceTracker(context);
this.context = context;
- // Get the DeployerServiceDelegate
+ // Get the DeployerService
ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
deployer = (DeployerService)context.getService(sref);
+ // Get the DeploymentRegistryService
+ sref = context.getServiceReference(DeploymentRegistryService.class.getName());
+ registry = (DeploymentRegistryService)context.getService(sref);
+
initScanner(context);
}
@@ -141,10 +148,10 @@
for (ScanListener listener : scanListeners)
listener.beforeScan(this);
- List<BundleInfo> currScan = Arrays.asList(getBundleInfos());
+ List<BundleDeployment> currScan = Arrays.asList(getBundleDeployments());
if (traceBundles)
- logBundleInfos("Current Scan", currScan);
+ logBundleDeployments("Current Scan", currScan);
int oldDiff = processOldDeployments(currScan);
int newDiff = processNewDeployments(currScan);
@@ -159,42 +166,42 @@
listener.afterScan(this);
}
- private void logBundleInfos(String message, List<BundleInfo> bundleInfos)
+ private void logBundleDeployments(String message, List<BundleDeployment> bundleDeps)
{
System.out.println(message);
- for (BundleInfo info : bundleInfos)
+ for (BundleDeployment dep : bundleDeps)
{
- System.out.println(" " + info);
+ System.out.println(" " + dep);
}
}
- private int processOldDeployments(List<BundleInfo> currScan)
+ private int processOldDeployments(List<BundleDeployment> currScan)
{
- List<BundleInfo> diff = new ArrayList<BundleInfo>();
+ List<BundleDeployment> diff = new ArrayList<BundleDeployment>();
// Detect OLD bundles that are not in the current scan
- for (BundleInfo info : lastScan)
+ for (BundleDeployment dep : lastScan)
{
- if (currScan.contains(info) == false)
+ if (currScan.contains(dep) == false)
{
- Bundle bundle = deployer.getBundle(info);
+ Bundle bundle = getBundle(dep);
int state = bundle.getState();
if (state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.ACTIVE)
{
- bundleInfoCache.remove(info.getLocation().toExternalForm());
- diff.add(info);
+ deploymentCache.remove(dep.getLocation().toExternalForm());
+ diff.add(dep);
}
}
}
if (traceBundles)
- logBundleInfos("OLD diff", diff);
+ logBundleDeployments("OLD diff", diff);
// Undeploy the bundles through the DeployerService
try
{
- BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
- deployer.undeploy(infoArr);
+ BundleDeployment[] depArr = diff.toArray(new BundleDeployment[diff.size()]);
+ deployer.undeploy(depArr);
}
catch (Exception ex)
{
@@ -204,27 +211,27 @@
return diff.size();
}
- private int processNewDeployments(List<BundleInfo> currScan)
+ private int processNewDeployments(List<BundleDeployment> currScan)
{
- List<BundleInfo> diff = new ArrayList<BundleInfo>();
+ List<BundleDeployment> diff = new ArrayList<BundleDeployment>();
// Detect NEW bundles that are not in the last scan
- for (BundleInfo info : currScan)
+ for (BundleDeployment dep : currScan)
{
- if (lastScan.contains(info) == false && deployer.getBundle(info) == null)
+ if (lastScan.contains(dep) == false && getBundle(dep) == null)
{
- diff.add(info);
+ diff.add(dep);
}
}
if (traceBundles)
- logBundleInfos("NEW diff", diff);
+ logBundleDeployments("NEW diff", diff);
// Deploy the bundles through the DeployerService
try
{
- BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
- deployer.deploy(infoArr);
+ BundleDeployment[] depArr = diff.toArray(new BundleDeployment[diff.size()]);
+ deployer.deploy(depArr);
}
catch (Exception ex)
{
@@ -234,9 +241,9 @@
return diff.size();
}
- public BundleInfo[] getBundleInfos()
+ public BundleDeployment[] getBundleDeployments()
{
- List<BundleInfo> bundles = new ArrayList<BundleInfo>();
+ List<BundleDeployment> bundles = new ArrayList<BundleDeployment>();
File[] listFiles = scanLocation.listFiles();
if (listFiles == null)
@@ -247,24 +254,27 @@
for (File file : listFiles)
{
URL bundleURL = toURL(file);
- BundleInfo info = bundleInfoCache.get(bundleURL.toExternalForm());
- if (info == null)
+ BundleDeployment dep = deploymentCache.get(bundleURL.toExternalForm());
+ if (dep == null)
{
try
{
- info = deployer.getBundleInfo(bundleURL);
- bundleInfoCache.put(bundleURL.toExternalForm(), info);
+ // hot-deploy bundles are started automatically
+ dep = registry.createBundleDeployment(bundleURL);
+ dep.setAutoStart(true);
+
+ deploymentCache.put(bundleURL.toExternalForm(), dep);
}
catch (BundleException ex)
{
- log.log(LogService.LOG_WARNING, "Cannot obtain bundle info for: " + file);
+ log.log(LogService.LOG_WARNING, "Cannot obtain bundle deployment for: " + file);
}
}
- bundles.add(info);
+ bundles.add(dep);
}
}
- BundleInfo[] arr = new BundleInfo[bundles.size()];
+ BundleDeployment[] arr = new BundleDeployment[bundles.size()];
return bundles.toArray(arr);
}
@@ -303,6 +313,27 @@
scanLocation = scanFile;
}
+ private Bundle getBundle(BundleDeployment dep)
+ {
+ String symbolicName = dep.getSymbolicName();
+ String version = dep.getVersion();
+
+ Bundle bundle = null;
+ for (Bundle aux : context.getBundles())
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (version == null || version.equals(auxVersion))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+ return bundle;
+ }
+
private URL toURL(File file)
{
try
Modified: projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/BundlesPlugin.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/BundlesPlugin.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/BundlesPlugin.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -29,10 +29,12 @@
import org.apache.felix.webconsole.internal.core.BundlesServlet;
import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -62,18 +64,23 @@
getLog().log(LogService.LOG_WARNING, "Cannot obtain service: " + DeployerService.class.getName());
return super.actionUninstall(bundle);
}
-
DeployerService service = (DeployerService)context.getService(sref);
- BundleInfo info = service.getBundleInfo(bundle);
- if (info == null)
+
+ sref = context.getServiceReference(DeploymentRegistryService.class.getName());
+ DeploymentRegistryService registry = (DeploymentRegistryService)context.getService(sref);
+
+ String symbolicName = bundle.getSymbolicName();
+ String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ BundleDeployment dep = registry.getBundleDeployment(symbolicName, version);
+ if (dep == null)
{
- getLog().log(LogService.LOG_WARNING, "Cannot find bundle info for: " + bundle);
+ getLog().log(LogService.LOG_WARNING, "Cannot find bundle deployment for: " + bundle);
return super.actionUninstall(bundle);
}
try
{
- service.undeploy(new BundleInfo[] { info });
+ service.undeploy(new BundleDeployment[] { dep });
return true;
}
catch (BundleException be)
Modified: projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -30,13 +30,14 @@
import org.apache.felix.webconsole.internal.core.InstallAction;
import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
-import org.osgi.service.startlevel.StartLevel;
/**
* A Console plugin
@@ -49,42 +50,35 @@
@Override
protected void installBackground(final File bundleFile, final String location, final int startlevel, final boolean doStart, boolean refreshPackages)
{
- final BundleContext context = getBundleContext();
- final ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+ BundleContext context = getBundleContext();
+ ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
if (sref == null)
{
getLog().log(LogService.LOG_WARNING, "Cannot obtain service: " + DeployerService.class.getName());
super.installBackground(bundleFile, location, startlevel, doStart, refreshPackages);
return;
}
-
+ final DeployerService deployer = (DeployerService)context.getService(sref);
+
+ sref = context.getServiceReference(DeploymentRegistryService.class.getName());
+ final DeploymentRegistryService registry = (DeploymentRegistryService)context.getService(sref);
+
Thread t = new InstallHelper(this, "Background Install " + bundleFile, bundleFile, refreshPackages)
{
protected Bundle doRun(InputStream bundleStream) throws BundleException
{
- DeployerService service = (DeployerService)context.getService(sref);
URL bundleURL = getBundleURL(bundleFile);
- BundleInfo info = service.getBundleInfo(bundleURL);
+
+ BundleDeployment dep = registry.createBundleDeployment(bundleURL);
+ dep.setStartLevel(startlevel);
+ dep.setAutoStart(doStart);
- service.deploy(new BundleInfo[] { info });
- Bundle bundle = service.getBundle(info);
+ deployer.deploy(new BundleDeployment[] { dep });
+
+ Bundle bundle = getBundle(dep);
if (bundle == null)
- throw new IllegalStateException("Cannot obtain installed bundle: " + info);
+ throw new IllegalStateException("Cannot obtain installed bundle: " + dep);
- if (startlevel > 0)
- {
- StartLevel sl = getStartLevel();
- if (sl != null)
- {
- sl.setBundleStartLevel(bundle, startlevel);
- }
- }
-
- if (doStart)
- {
- bundle.start();
- }
-
return bundle;
}
@@ -93,6 +87,27 @@
t.start();
}
+ private Bundle getBundle(BundleDeployment info)
+ {
+ String symbolicName = info.getSymbolicName();
+ String version = info.getVersion();
+
+ Bundle bundle = null;
+ for (Bundle aux : getBundleContext().getBundles())
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (version == null || version.equals(auxVersion))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+ return bundle;
+ }
+
private URL getBundleURL(final File bundleFile) throws BundleException
{
URL bundleURL;
Added: projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java
===================================================================
--- projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java (rev 0)
+++ projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartLevelDeployer.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployer;
+
+// $Id: $
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * This is the Bundle start level Deployer
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public class BundleStartLevelDeployer extends AbstractSimpleRealDeployer<Bundle>
+{
+ private BundleContext systemContext;
+ private ServiceTracker startLevelTracker;
+
+ public BundleStartLevelDeployer()
+ {
+ super(Bundle.class);
+ addOutput(Constants.PROPERTY_START_LEVEL);
+ }
+
+ public void setSystemContext(BundleContext systemContext)
+ {
+ this.systemContext = systemContext;
+ }
+
+ public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
+ {
+ Integer propStart = unit.getAttachment(Constants.PROPERTY_START_LEVEL, Integer.class);
+ StartLevel startLevel = getStartLevel();
+ if (propStart != null && startLevel != null)
+ {
+ startLevel.setBundleStartLevel(bundle, propStart);
+ }
+ }
+
+ private StartLevel getStartLevel()
+ {
+ if (startLevelTracker == null)
+ {
+ startLevelTracker = new ServiceTracker(systemContext, StartLevel.class.getName(), null);
+ startLevelTracker.open();
+ }
+ return (StartLevel)startLevelTracker.getService();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/integration/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -56,6 +56,7 @@
public BundleStartStopDeployer()
{
super(Bundle.class);
+ addInput(Constants.PROPERTY_START_LEVEL);
}
public void setSystemContext(BundleContext systemContext)
@@ -65,15 +66,19 @@
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
- String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
- if (Boolean.parseBoolean(propStart != null ? propStart : "true") == true)
+ Boolean propAutoStart = unit.getAttachment(Constants.PROPERTY_AUTO_START, Boolean.class);
+ if (propAutoStart == Boolean.TRUE)
{
- deferredStart(unit, bundle);
+ String propDeferredStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
+ if (Boolean.parseBoolean(propDeferredStart != null ? propDeferredStart : "true") == true)
+ {
+ deferredStart(unit, bundle);
+ }
+ else
+ {
+ simpleStart(unit, bundle);
+ }
}
- else
- {
- simpleStart(unit, bundle);
- }
}
@Override
Modified: projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -25,17 +25,10 @@
import static org.jboss.osgi.spi.management.MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE;
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
import javax.management.MBeanServer;
import javax.management.StandardMBean;
@@ -49,21 +42,23 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.spi.Constants;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.DeployerService;
+import org.jboss.osgi.spi.service.DeploymentRegistryService;
import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
+import org.osgi.util.tracker.ServiceTracker;
/**
* An OSGi Service the gives access to the Kernel.
@@ -74,7 +69,7 @@
public abstract class AbstractMicrocontainerService implements DeployerService, MicrocontainerService
{
private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
- private Map<String, BundleDeployment> deployments = Collections.synchronizedMap(new HashMap<String, BundleDeployment>());
+ private ServiceTracker registryTracker;
public abstract Kernel getKernel();
@@ -113,88 +108,17 @@
return (T)getRegisteredBean(beanName);
}
- public BundleInfo getBundleInfo(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 BundleInfo(url, symbolicName, version);
- }
-
- public BundleInfo getBundleInfo(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Cannot obtain bundle info for: null");
-
- String sname = bundle.getSymbolicName();
- String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
-
- URL location = null;
- for (String auxLoc : deployments.keySet())
- {
- BundleDeployment auxDep = deployments.get(auxLoc);
- BundleInfo auxInfo = auxDep.getBundleInfo();
- if (sname.equals(auxInfo.getSymbolicName()) && version.equals(auxInfo.getVersion()))
- {
- location = toURL(auxLoc);
- break;
- }
- }
-
- BundleInfo info = null;
- if (location != null)
- {
- info = new BundleInfo(location, sname, version);
- }
- return info;
- }
-
- public Bundle getBundle(BundleInfo info)
- {
- BundleContext context = getRegisteredBean(BundleContext.class, BEAN_SYSTEM_BUNDLE_CONTEXT);
- String symbolicName = info.getSymbolicName();
- String version = info.getVersion();
-
- Bundle bundle = null;
- for (Bundle aux : context.getBundles())
- {
- if (aux.getSymbolicName().equals(symbolicName))
- {
- String auxVersion = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
- if (version == null || version.equals(auxVersion))
- {
- bundle = aux;
- break;
- }
- }
- }
- return bundle;
- }
-
public void deploy(URL url) throws BundleException
{
- deployInternal(new URL[] { url });
+ DeploymentRegistryService registry = getDeploymentRegistry();
+ BundleDeployment dep = registry.createBundleDeployment(url);
+ deploy(new BundleDeployment[] { dep });
}
public boolean undeploy(URL url) throws BundleException
{
- BundleDeployment dep = deployments.remove(url.toExternalForm());
+ DeploymentRegistryService registry = getDeploymentRegistry();
+ BundleDeployment dep = registry.getBundleDeployment(url);
if (dep == null)
{
logWarning("Package not deployed: " + url);
@@ -204,7 +128,7 @@
try
{
MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
- mainDeployer.removeDeployment(dep.getName());
+ mainDeployer.removeDeployment((String)dep.getMetadata());
mainDeployer.process();
return true;
}
@@ -215,17 +139,8 @@
}
}
- public void deploy(BundleInfo[] bundles) throws BundleException
+ public void deploy(BundleDeployment[] depArr) throws BundleException
{
- URL[] urls = new URL[bundles.length];
- for (int i = 0; i < bundles.length; i++)
- urls[i] = bundles[i].getLocation();
-
- deployInternal(urls);
- }
-
- private void deployInternal(URL[] urls) throws BundleException
- {
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
@@ -233,26 +148,29 @@
List<Deployment> depList = new ArrayList<Deployment>();
MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
- for (URL location : urls)
+ DeploymentRegistryService registry = getDeploymentRegistry();
+
+ for (BundleDeployment dep : depArr)
{
- BundleInfo info = getBundleInfo(location);
-
- VirtualFile file = VFS.createNewRoot(location);
+ VirtualFile file = VFS.createNewRoot(dep.getLocation());
VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
- mainDeployer.addDeployment(deployment);
-
- String depName = deployment.getName();
- BundleDeployment dep = new BundleDeployment(depName, info);
- deployments.put(location.toExternalForm(), dep);
+ dep.setMetadata(deployment.getName());
+ registry.registerBundleDeployment(dep);
depList.add(deployment);
+
+ MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+ att.addAttachment(Constants.PROPERTY_START_LEVEL, new Integer(dep.getStartLevel()));
+ att.addAttachment(Constants.PROPERTY_AUTO_START, new Boolean(dep.isAutoStart()));
+
+ mainDeployer.addDeployment(deployment);
}
// Process the deployments
mainDeployer.process();
// Check for completeness
- Deployment[] depArr = depList.toArray(new Deployment[depList.size()]);
- mainDeployer.checkComplete(depArr);
+ Deployment[] deploymentArr = depList.toArray(new Deployment[depList.size()]);
+ mainDeployer.checkComplete(deploymentArr);
}
catch (RuntimeException rte)
{
@@ -268,23 +186,17 @@
}
}
- public void undeploy(BundleInfo[] infos) throws BundleException
+ public void undeploy(BundleDeployment[] depArr) throws BundleException
{
try
{
MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
- for (BundleInfo info : infos)
+ DeploymentRegistryService registry = getDeploymentRegistry();
+
+ for (BundleDeployment dep : depArr)
{
- URL location = info.getLocation();
- BundleDeployment dep = deployments.remove(location.toExternalForm());
- if (dep != null)
- {
- mainDeployer.removeDeployment(dep.getName());
- }
- else
- {
- logWarning("Package not deployed: " + location);
- }
+ registry.unregisterBundleDeployment(dep);
+ mainDeployer.removeDeployment((String)dep.getMetadata());
}
mainDeployer.process();
}
@@ -344,40 +256,17 @@
}
}
- private URL toURL(String location)
+ private DeploymentRegistryService getDeploymentRegistry()
{
- try
+ if (registryTracker == null)
{
- return new URL(location);
+ BundleContext context = getRegisteredBean(BundleContext.class, BEAN_SYSTEM_BUNDLE_CONTEXT);
+ registryTracker = new ServiceTracker(context, DeploymentRegistryService.class.getName(), null);
+ registryTracker.open();
}
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Invalid URL location: " + location);
- }
+ return (DeploymentRegistryService)registryTracker.getService();
}
-
- static class BundleDeployment
- {
- private String name;
- private BundleInfo info;
-
- public BundleDeployment(String depName, BundleInfo bundleInfo)
- {
- this.name = depName;
- this.info = bundleInfo;
- }
-
- public String getName()
- {
- return name;
- }
-
- public BundleInfo getBundleInfo()
- {
- return info;
- }
- }
-
+
static class PreInstalledControllerContext extends AbstractControllerContext
{
public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/Constants.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/Constants.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/Constants.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -43,6 +43,20 @@
String PROPERTY_DEFERRED_START = "org.jboss.osgi.deferred.start";
/**
+ * If set to 'true' bundles are started automatically.
+ *
+ * The default is 'false'
+ */
+ String PROPERTY_AUTO_START = "org.jboss.osgi.auto.start";
+
+ /**
+ * Specifies the start level for a bundle.
+ *
+ * The default is '0'
+ */
+ String PROPERTY_START_LEVEL = "org.jboss.osgi.start.level";
+
+ /**
* The JBossOSGi runtime system property that denotes the path to the runtime
*/
String OSGI_HOME = "osgi.home";
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -21,17 +21,16 @@
*/
package org.jboss.osgi.spi.service;
+//$Id$
+
import java.net.URL;
import javax.management.ObjectName;
import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.osgi.framework.Bundle;
+import org.jboss.osgi.spi.util.BundleDeployment;
import org.osgi.framework.BundleException;
-//$Id$
-
/**
* A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
*
@@ -46,31 +45,14 @@
ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
/**
- * Get the bundle info for the given bundle URL
- */
- BundleInfo getBundleInfo(URL url) throws BundleException;
-
- /**
- * Get the bundle info for the given bundle
- * @return null, if this service does not maintain the bundle info
- */
- BundleInfo getBundleInfo(Bundle bundle);
-
- /**
- * Get the installed bundle for the given bundle info
- * @return null, if there is no bundle that matches the given bundle info
- */
- Bundle getBundle(BundleInfo info);
-
- /**
* Deploy an array of bundles
*/
- void deploy(BundleInfo[] bundles) throws BundleException;
+ void deploy(BundleDeployment[] bundleDeps) throws BundleException;
/**
* Undeploy an array of bundles
*/
- void undeploy(BundleInfo[] bundles) throws BundleException;
+ void undeploy(BundleDeployment[] bundleDeps) throws BundleException;
/**
* Deploy bundle from URL
Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentRegistryService.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -0,0 +1,65 @@
+/*
+ * 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.spi.service;
+
+//$Id: DeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler(a)jboss.com $
+
+import java.net.URL;
+
+import org.jboss.osgi.spi.util.BundleDeployment;
+import org.osgi.framework.BundleException;
+
+/**
+ * A Service to register/unregister bundle deployments.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public interface DeploymentRegistryService
+{
+ /**
+ * Create a bundle deployment from the given bundle URL
+ */
+ BundleDeployment createBundleDeployment(URL url) throws BundleException;
+
+ /**
+ * Create a bundle deployment from the given bundle URL
+ * @return null, if this service does not maintain the bundle deployment
+ */
+ BundleDeployment getBundleDeployment(URL url);
+
+ /**
+ * Get the bundle deployment for the given bundle symbolicName and version
+ * @return null, if this service does not maintain the bundle deployment
+ */
+ BundleDeployment getBundleDeployment(String symbolicName, String version);
+
+ /**
+ * Register a bundle deployment
+ */
+ void registerBundleDeployment(BundleDeployment dep);
+
+ /**
+ * Unregister a bundle deployment
+ */
+ void unregisterBundleDeployment(BundleDeployment dep);
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -25,7 +25,7 @@
import java.net.URL;
-import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.spi.util.BundleDeployment;
/**
* A service that scans a directory location for new/removed bundles.
@@ -76,7 +76,7 @@
/**
* Returns the array of bundles currently known to the deployemtn scanner.
*/
- BundleInfo[] getBundleInfos();
+ BundleDeployment[] getBundleDeployments();
/**
* Add a scan listener to this service
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java (from rev 90894, 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/BundleDeployment.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleDeployment.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -0,0 +1,152 @@
+/*
+ * 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.spi.util;
+
+import java.io.Serializable;
+import java.net.URL;
+
+//$Id$
+
+/**
+ * An abstraction of a bundle deployment
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class BundleDeployment implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private URL location;
+ private String symbolicName;
+ private String version;
+ private int startLevel;
+ private boolean autoStart;
+ private Object metadata;
+
+ public BundleDeployment(URL location, String symbolicName, String version)
+ {
+ if (location == null)
+ throw new IllegalArgumentException("Location cannot be null");
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Symbolic name cannot be null");
+
+ this.symbolicName = symbolicName;
+ this.location = location;
+
+ this.version = (version != null ? version : "0.0.0");
+ }
+
+ /**
+ * Get the bundle location
+ */
+ public URL getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * Get the bundle symbolic name
+ */
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ /**
+ * Get the bundle version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * Get the start level associated with this deployment
+ */
+ public int getStartLevel()
+ {
+ return startLevel;
+ }
+
+ /**
+ * Set the start level associated with this deployment
+ */
+ public void setStartLevel(int startLevel)
+ {
+ this.startLevel = startLevel;
+ }
+
+ /**
+ * Get the autostart flag associated with this deployment
+ */
+ public boolean isAutoStart()
+ {
+ return autoStart;
+ }
+
+ /**
+ * Set the autostart flag associated with this deployment
+ */
+ public void setAutoStart(boolean autoStart)
+ {
+ 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)
+ {
+ if (!(obj instanceof BundleDeployment))
+ return false;
+
+ BundleDeployment other = (BundleDeployment)obj;
+ return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + symbolicName + ":" + version + "]";
+ }
+}
\ No newline at end of file
Deleted: 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-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -1,98 +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.spi.util;
-
-import java.net.URL;
-
-//$Id$
-
-/**
- * An abstraction of a bundle
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-May-2009
- */
-public class BundleInfo
-{
- private URL location;
- private String symbolicName;
- private String version;
-
- public BundleInfo(URL location, String symbolicName, String version)
- {
- if (location == null)
- throw new IllegalArgumentException("Location cannot be null");
- if (symbolicName == null)
- throw new IllegalArgumentException("Symbolic name cannot be null");
-
- this.symbolicName = symbolicName;
- this.location = location;
-
- this.version = (version != null ? version : "0.0.0");
- }
-
- /**
- * Get the bundle location
- */
- public URL getLocation()
- {
- return location;
- }
-
- /**
- * Get the bundle symbolic name
- */
- public String getSymbolicName()
- {
- return symbolicName;
- }
-
- /**
- * Get the bundle version
- */
- public String getVersion()
- {
- return version;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (!(obj instanceof BundleInfo))
- return false;
-
- BundleInfo other = (BundleInfo)obj;
- return symbolicName.equals(other.symbolicName) && version.equals(other.version);
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public String toString()
- {
- return "[" + symbolicName + ":" + version + "]";
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2009-07-08 09:26:46 UTC (rev 90924)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2009-07-08 10:12:31 UTC (rev 90925)
@@ -78,6 +78,9 @@
<!-- jbosgi41 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi41-bundleA.jar" files="${tests.resources.dir}/jbosgi41/jbosgi41-bundleA.bnd" />
+ <!-- jbosgi99 -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi99-bundleA.jar" files="${tests.resources.dir}/jbosgi99/jbosgi99-bundleA.bnd" />
+
<!-- jbosgi108 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi108-bundleA.jar" files="${tests.resources.dir}/jbosgi108/jbosgi108-bundleA.bnd" />
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi108-bundleB.jar" files="${tests.resources.dir}/jbosgi108/jbosgi108-bundleB.bnd" />
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99 (from rev 90880, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108)
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI108TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java 2009-07-07 07:31:04 UTC (rev 90880)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI108TestCase.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -1,176 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.jbosgi108;
-
-//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jboss.osgi.spi.capability.JMXCapability;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.test.osgi.jbosgi108.bundleA.SomeBeanMBean;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.osgi.framework.BundleException;
-
-/**
- * [JBOSGI-108] Investigate statics on PackageAdmin.refresh
- *
- * https://jira.jboss.org/jira/browse/JBOSGI-108
- *
- * @author thomas.diesler(a)jboss.com
- * @since 19-Jun-2009
- */
-public class OSGI108TestCase
-{
- private static OSGiRuntime runtime;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
- {
- runtime = new OSGiTestHelper().getDefaultRuntime();
- runtime.addCapability(new JMXCapability());
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (runtime != null)
- runtime.shutdown();
- }
-
- @Before
- public void setUp()
- {
- OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
- packageAdmin.refreshPackages(null);
- }
-
- @Test
- public void testRedeploySingle() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
-
- bundleA.start();
-
- SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
- List<String> messages = report(someBean.getMessages());
- assertEquals("Start messages", 1, messages.size());
-
- bundleA.uninstall();
-
- // Reinstall bundleA
- bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- bundleA.start();
-
- // The static in bundleA.SomeBean is expected to be recreated
-
- messages = report(someBean.getMessages());
- assertEquals("Start messages", 1, messages.size());
-
- bundleA.uninstall();
- }
-
- @Test
- public void testRedeployWithReference() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
-
- bundleA.start();
- bundleB.start();
-
- SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
- List<String> messages = report(someBean.getMessages());
- assertEquals("Start messages", 2, messages.size());
-
- bundleA.uninstall();
-
- // After uninstall bundleA, bundleB still holds a reference on
- // bundleA.SomeBean
-
- // Reinstall bundleA
- bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- bundleA.start();
-
- // The static in bundleA.SomeBean is expected to be reused
-
- messages = report(someBean.getMessages());
- assertEquals("Start messages", 4, messages.size());
-
- bundleB.uninstall();
- bundleA.uninstall();
- }
-
- @Test
- public void testRedeployWithReferenceAndRefresh() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
-
- bundleA.start();
- bundleB.start();
-
- SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
- List<String> messages = report(someBean.getMessages());
- assertEquals("Start messages", 2, messages.size());
-
- bundleA.uninstall();
-
- // After uninstall bundleA, bundleB still holds a reference on
- // bundleA.SomeBean
-
- // Refresh all packages
- OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
- packageAdmin.refreshPackages(null);
-
- // Reinstall bundleA
- bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
- bundleA.start();
-
- // The static in bundleA.SomeBean is expected to be recreated
-
- messages = report(someBean.getMessages());
- assertEquals("Start messages", 1, messages.size());
-
- bundleB.uninstall();
- bundleA.uninstall();
- }
-
- private List<String> report(List<String> messages)
- {
- // System.out.println(">>>>>>>>>>>>");
- // for (String aux : messages)
- // System.out.println(aux);
- // System.out.println("<<<<<<<<<<<");
-
- return messages;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java (from rev 90880, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -0,0 +1,73 @@
+/*
+ * 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.jbosgi99;
+
+//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-99] No explicit control over bundle.start()
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-99
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2009
+ */
+public class OSGI99TestCase
+{
+ private static OSGiRuntime runtime;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testInstallOnly() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi99-bundleA.jar");
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
+
+ bundleA.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+
+ bundleA.uninstall();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-07 07:31:04 UTC (rev 90880)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -19,57 +19,20 @@
* 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.jbosgi108.bundleA;
+package org.jboss.test.osgi.jbosgi99.bundleA;
//$Id: ServiceActivator.java 87064 2009-04-09 11:08:56Z thomas.diesler(a)jboss.com $
-import javax.management.MBeanServer;
-
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
public class ActivatorBundleA implements BundleActivator
{
- private SomeBean bean;
-
public void start(BundleContext context)
{
- bean = new SomeBean();
-
- // Register the MBean
- try
- {
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- MBeanServer service = (MBeanServer)context.getService(sref);
- service.registerMBean(bean, SomeBean.MBEAN_NAME);
- }
- catch (Exception ex)
- {
- throw new IllegalStateException(ex);
- }
-
- ClassLoader cl = getClass().getClassLoader();
- String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
}
public void stop(BundleContext context)
{
- ClassLoader cl = getClass().getClassLoader();
- String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
-
- // Register the MBean
- try
- {
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- MBeanServer service = (MBeanServer)context.getService(sref);
- service.unregisterMBean(SomeBean.MBEAN_NAME);
- }
- catch (Exception ex)
- {
- throw new IllegalStateException(ex);
- }
}
}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/SomeBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java 2009-07-07 07:31:04 UTC (rev 90880)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/SomeBean.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.jbosgi108.bundleA;
-
-//$Id$
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class SomeBean implements SomeBeanMBean
-{
- private static List<String> messages = new ArrayList<String>();
-
- public void addMessage(String msg)
- {
- messages.add(msg);
- }
-
- public List<String> getMessages()
- {
- return Collections.unmodifiableList(messages);
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/SomeBeanMBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java 2009-07-07 07:31:04 UTC (rev 90880)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/SomeBeanMBean.java 2009-07-08 10:12:31 UTC (rev 90925)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.jbosgi108.bundleA;
-
-import java.util.List;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-
-//$Id$
-
-public interface SomeBeanMBean
-{
- ObjectName MBEAN_NAME = ObjectNameFactory.create("jboss.osgi:bean=SomeBean");
-
- List<String> getMessages();
-}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99 (from rev 90880, projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi108)
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi108-bundleA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi108/jbosgi108-bundleA.bnd 2009-07-07 07:31:04 UTC (rev 90880)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi108-bundleA.bnd 2009-07-08 10:12:31 UTC (rev 90925)
@@ -1,6 +0,0 @@
-# bnd build -classpath target/test-classes -output target/test-libs/jbosgi108-bundleA.jar src/test/resources/jbosgi108/jbosgi108-bundleA.bnd
-
-Bundle-SymbolicName: jbosgi108-bundleA
-Bundle-Activator: org.jboss.test.osgi.jbosgi108.bundleA.ActivatorBundleA
-Export-Package: org.jboss.test.osgi.jbosgi108.bundleA
-
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi108-bundleB.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi108/jbosgi108-bundleB.bnd 2009-07-07 07:31:04 UTC (rev 90880)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi108-bundleB.bnd 2009-07-08 10:12:31 UTC (rev 90925)
@@ -1,7 +0,0 @@
-# bnd build -classpath target/test-classes -output target/test-libs/jbosgi108-bundleB.jar src/test/resources/jbosgi108/jbosgi108-bundleB.bnd
-
-Bundle-SymbolicName: jbosgi108-bundleB
-Bundle-Activator: org.jboss.test.osgi.jbosgi108.bundleB.ActivatorBundleB
-Export-Package: org.jboss.test.osgi.jbosgi108.bundleB
-Import-Package: org.osgi.framework, org.jboss.test.osgi.jbosgi108.bundleA
-
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi99-bundleA.bnd (from rev 90880, projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi108/jbosgi108-bundleA.bnd)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi99-bundleA.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/jbosgi99/jbosgi99-bundleA.bnd 2009-07-08 10:12:31 UTC (rev 90925)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi99-bundleA.jar src/test/resources/jbosgi99/jbosgi99-bundleA.bnd
+
+Bundle-SymbolicName: jbosgi99-bundleA
+Bundle-Activator: org.jboss.test.osgi.jbosgi99.bundleA.ActivatorBundleA
+Export-Package: org.jboss.test.osgi.jbosgi99.bundleA
+
16 years, 11 months
JBoss-OSGI SVN: r90923 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-07-08 02:59:34 -0400 (Wed, 08 Jul 2009)
New Revision: 90923
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
Log:
[JBOSGI-98] Support configuration per profile
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-07-08 06:58:59 UTC (rev 90922)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-07-08 06:59:34 UTC (rev 90923)
@@ -27,10 +27,13 @@
import static org.jboss.osgi.spi.Constants.OSGI_SERVER_HOME;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Enumeration;
import java.util.Properties;
@@ -96,7 +99,7 @@
public void run()
{
- initSystemProperties();
+ initBootstrap();
OSGiBootstrapProvider bootProvider = getBootstrapProvider();
OSGiFramework framework = bootProvider.getFramework();
@@ -108,7 +111,7 @@
thread.start();
}
- private void initSystemProperties()
+ private void initBootstrap()
{
osgiHome = System.getProperty(OSGI_HOME);
if (osgiHome == null)
@@ -116,14 +119,27 @@
osgiServerHome = osgiHome + "/server/" + serverName;
+ // Replace the context class loader with one that contains the server conf dir
+ File serverConfDir = new File(osgiServerHome + "/conf");
+ if (serverConfDir.exists())
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ URLClassLoader confLoader = new URLClassLoader(new URL[] { toURL(serverConfDir) }, ctxLoader);
+ Thread.currentThread().setContextClassLoader(confLoader);
+ }
+
+ // This property must be set before the logger is obtained
+ System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
+ log = Logger.getLogger(OSGiBootstrap.class);
+
Properties defaults = new Properties();
defaults.setProperty(OSGI_SERVER_NAME, serverName);
defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
defaults.setProperty(JBOSS_BIND_ADDRESS, bindAdress);
defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
- getLogger().debug("JBoss OSGi System Properties");
- getLogger().debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
+ log.debug("JBoss OSGi System Properties");
+ log.debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
Enumeration<?> defaultNames = defaults.propertyNames();
while (defaultNames.hasMoreElements())
@@ -134,21 +150,11 @@
{
String propValue = defaults.getProperty(propName);
System.setProperty(propName, propValue);
- getLogger().debug(" " + propName + "=" + propValue);
+ log.debug(" " + propName + "=" + propValue);
}
}
}
- private Logger getLogger()
- {
- if (log == null)
- {
- System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
- log = Logger.getLogger(OSGiBootstrap.class);
- }
- return log;
- }
-
/*
* * Get an instance of an OSGiBootstrapProvider.
*/
@@ -196,6 +202,18 @@
return provider;
}
+ private URL toURL(File file)
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Invalid file: " + file);
+ }
+ }
+
class StartupThread extends Thread
{
private OSGiFramework framework;
@@ -231,7 +249,7 @@
if (lastChange > afterStart)
{
float diff = (lastChange - beforeStart) / 1000f;
- getLogger().info("JBossOSGi Runtime started in " + diff + "sec");
+ log.info("JBossOSGi Runtime started in " + diff + "sec");
}
service.removeScanListener(this);
}
@@ -240,7 +258,7 @@
}
float diff = (afterStart - beforeStart) / 1000f;
- getLogger().info("JBossOSGi Runtime booted in " + diff + "sec");
+ log.info("JBossOSGi Runtime booted in " + diff + "sec");
Reader br = new InputStreamReader(System.in);
try
@@ -269,9 +287,9 @@
public void run()
{
- getLogger().info("Initiating shutdown ...");
+ log.info("Initiating shutdown ...");
framework.stop();
- getLogger().info("Shutdown complete");
+ log.info("Shutdown complete");
}
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-07-08 06:58:59 UTC (rev 90922)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-07-08 06:59:34 UTC (rev 90923)
@@ -23,6 +23,7 @@
//$Id$
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -75,59 +76,62 @@
* file://${test.archive.directory}/bundles/jboss-osgi-jmx.jar \
* file://${test.archive.directory}/bundles/jboss-osgi-microcontainer.jar
* </pre>
- *
+ *
* @author thomas.diesler(a)jboss.com
* @since 24-Apr-2009
*/
-public class PropertiesBootstrapProvider implements OSGiBootstrapProvider
+public class PropertiesBootstrapProvider implements OSGiBootstrapProvider
{
/** The default framework property: jboss.osgi.framework.properties */
public static final String OSGI_FRAMEWORK_CONFIG = "jboss.osgi.framework.properties";
/** The default framework config: jboss-osgi-framework.properties */
public static final String DEFAULT_OSGI_FRAMEWORK_PROPERTIES = "jboss-osgi-framework.properties";
-
+
/** The OSGi framework integration class: org.jboss.osgi.spi.framework.impl */
public static final String PROP_OSGI_FRAMEWORK_IMPL = "org.jboss.osgi.spi.framework.impl";
- /** The OSGi framework integration class: org.jboss.osgi.spi.framework.autoInstall */
+ /** Optional list of bundles that get installed automatically: org.jboss.osgi.spi.framework.autoInstall */
public static final String PROP_OSGI_FRAMEWORK_AUTO_INSTALL = "org.jboss.osgi.spi.framework.autoInstall";
- /** The OSGi framework integration class: org.jboss.osgi.spi.framework.autoStart */
+ /** Optional list of bundles that get started automatically: org.jboss.osgi.spi.framework.autoStart */
public static final String PROP_OSGI_FRAMEWORK_AUTO_START = "org.jboss.osgi.spi.framework.autoStart";
-
+ /** Optional path to extra properties: org.jboss.osgi.spi.framework.extra */
+ public static final String PROP_OSGI_FRAMEWORK_EXTRA = "org.jboss.osgi.spi.framework.extra";
+
private static Set<String> internalProps = new HashSet<String>();
static
{
internalProps.add(PROP_OSGI_FRAMEWORK_IMPL);
internalProps.add(PROP_OSGI_FRAMEWORK_AUTO_INSTALL);
internalProps.add(PROP_OSGI_FRAMEWORK_AUTO_START);
+ internalProps.add(PROP_OSGI_FRAMEWORK_EXTRA);
}
-
+
private OSGiFramework framework;
private boolean configured;
-
+
public void configure()
{
- throw new NotImplementedException();
+ configure(DEFAULT_OSGI_FRAMEWORK_PROPERTIES);
}
public void configure(URL urlConfig)
{
// Read the configuration properties
Properties props = getBootstrapProperties(urlConfig);
-
+
// Load the framework instance
framework = loadFrameworkImpl(urlConfig, props);
-
+
// Process Framework props
initFrameworkProperties(props);
// Init the the autoInstall URLs
List<URL> installURLs = getBundleURLs(props, PROP_OSGI_FRAMEWORK_AUTO_INSTALL);
framework.setAutoInstall(installURLs);
-
+
// Init the the autoStart URLs
List<URL> startURLs = getBundleURLs(props, PROP_OSGI_FRAMEWORK_AUTO_START);
framework.setAutoStart(startURLs);
-
+
configured = true;
}
@@ -136,7 +140,7 @@
String bundleList = props.getProperty(key);
if (bundleList == null)
bundleList = "";
-
+
List<URL> bundleURLs = new ArrayList<URL>();
for (String bundle : bundleList.split("[, ]"))
{
@@ -159,7 +163,7 @@
}
catch (MalformedURLException ex)
{
- throw new IllegalStateException("Invalid path: " + path, ex);
+ throw new IllegalStateException("Invalid path: " + path, ex);
}
}
@@ -204,9 +208,9 @@
private void initFrameworkProperties(Properties props)
{
- Map<String,Object> frameworkProps = new HashMap<String,Object>();
+ Map<String, Object> frameworkProps = new HashMap<String, Object>();
Enumeration<?> keys = props.propertyNames();
- while(keys.hasMoreElements())
+ while (keys.hasMoreElements())
{
String key = (String)keys.nextElement();
if (internalProps.contains(key) == false)
@@ -223,7 +227,7 @@
String frameworkImpl = props.getProperty(PROP_OSGI_FRAMEWORK_IMPL);
if (frameworkImpl == null)
throw new IllegalStateException("Cannot get : " + urlConfig);
-
+
OSGiFramework framework;
try
{
@@ -250,7 +254,7 @@
}
catch (IOException ex)
{
- throw new IllegalStateException("Cannot load properties from: " + urlConfig, ex);
+ throw new IllegalStateException("Cannot load properties from: " + urlConfig, ex);
}
// Replace system properties
@@ -261,6 +265,42 @@
String value = props.getProperty(key);
props.setProperty(key, StringPropertyReplacer.replaceProperties(value));
}
+
+ // Merge optional extra properties
+ String extraPropsValue = props.getProperty(PROP_OSGI_FRAMEWORK_EXTRA);
+ if (extraPropsValue != null)
+ {
+ URL extraPropsURL = null;
+ try
+ {
+ extraPropsURL = new URL(extraPropsValue);
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore;
+ }
+ if (extraPropsURL == null)
+ {
+ File propsFile = new File(extraPropsValue);
+ try
+ {
+ extraPropsURL = propsFile.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore;
+ }
+ }
+
+ if (extraPropsURL == null)
+ throw new IllegalStateException("Invalid properties URL: " + extraPropsValue);
+
+ props.remove(PROP_OSGI_FRAMEWORK_EXTRA);
+ Properties extraProps = getBootstrapProperties(extraPropsURL);
+ props.putAll(extraProps);
+ }
+
return props;
}
+
}
16 years, 11 months