[jboss-cvs] JBossAS SVN: r96266 - in projects/jboss-osgi/trunk/reactor/framework/src: main/java/org/jboss/osgi/framework/deployers and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 11 11:53:48 EST 2009
Author: adrian at jboss.org
Date: 2009-11-11 11:53:48 -0500 (Wed, 11 Nov 2009)
New Revision: 96266
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
Log:
Reinstate the ability to manage non-osgi bundles using the OSGi api. Also fixed the incorrect usage of initialization in the parser deployer
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11 16:40:12 UTC (rev 96265)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11 16:53:48 UTC (rev 96266)
@@ -46,8 +46,8 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
-import java.util.jar.Manifest;
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
@@ -67,14 +67,13 @@
import org.jboss.osgi.framework.metadata.PackageAttribute;
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
import org.jboss.osgi.framework.plugins.AutoInstallPlugin;
-import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.plugins.PackageAdminServicePlugin;
import org.jboss.osgi.framework.plugins.Plugin;
+import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.ServicePlugin;
import org.jboss.osgi.framework.util.NoFilter;
-import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
import org.jboss.util.collection.ConcurrentSet;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
@@ -475,7 +474,6 @@
{
VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
- att.addAttachment(PROPERTY_AUTO_START, Boolean.FALSE);
att.addAttachment(PROPERTY_BUNDLE_LOCATION, location);
deployerClient.deploy(deployment);
@@ -583,7 +581,17 @@
OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
if (osgiMetaData == null)
- throw new IllegalStateException("Cannot obtain OSGi metadata");
+ {
+ Manifest manifest = unit.getAttachment(Manifest.class);
+ // [TODO] we need a mechanism to construct an OSGiMetaData from an easier factory
+ if (manifest == null)
+ manifest = new Manifest();
+ // [TODO] populate some bundle information
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.put(new Name(Constants.BUNDLE_NAME), unit.getName());
+ attributes.put(new Name(Constants.BUNDLE_SYMBOLICNAME), unit.getName());
+ osgiMetaData = new AbstractOSGiMetaData(manifest);
+ }
String location = (String)unit.getAttachment(PROPERTY_BUNDLE_LOCATION);
if (location == null)
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java 2009-11-11 16:40:12 UTC (rev 96265)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java 2009-11-11 16:53:48 UTC (rev 96266)
@@ -59,7 +59,6 @@
this.bundleManager = bundleManager;
this.requiredStage = DeploymentStages.DESCRIBE;
- setInput(OSGiMetaData.class);
setOutput(OSGiBundleState.class);
setStage(DeploymentStages.POST_PARSE);
setTopLevelOnly(true);
@@ -74,7 +73,8 @@
protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
{
// [TODO] look at manifest headers and persistent state for this
- unit.setRequiredStage(requiredStage);
+ if (unit.getAttachment(OSGiMetaData.class) != null)
+ unit.setRequiredStage(requiredStage);
OSGiBundleState bundleState = bundleManager.addDeployment(unit);
unit.addAttachment(OSGiBundleState.class, bundleState);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2009-11-11 16:40:12 UTC (rev 96265)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2009-11-11 16:53:48 UTC (rev 96266)
@@ -21,6 +21,8 @@
*/
package org.jboss.osgi.framework.deployers;
+import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
+
import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
@@ -50,21 +52,6 @@
super(OSGiMetaData.class);
setTopLevelOnly(true);
}
-
- @Override
- protected OSGiMetaData parse(VFSDeploymentUnit unit, VirtualFile file, OSGiMetaData root) throws Exception
- {
- OSGiMetaData metaData = super.parse(unit, file, root);
- if (metaData != null)
- {
- String symbolicName = metaData.getBundleSymbolicName();
- log.debug("Bundle-SymbolicName: " + symbolicName + " in " + file);
-
- // Add a marker that this is an OSGi deployment
- unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
- }
- return metaData;
- }
@Override
protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
@@ -75,4 +62,20 @@
return new AbstractOSGiMetaData(manifest);
}
+
+ @Override
+ protected void init(VFSDeploymentUnit unit, OSGiMetaData metaData, VirtualFile file) throws Exception
+ {
+ super.init(unit, metaData, file);
+
+ String symbolicName = metaData.getBundleSymbolicName();
+ log.debug("Bundle-SymbolicName: " + symbolicName + " in " + file);
+
+ // Add a marker that this is an OSGi deployment
+ unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
+
+ // Don't automatically start OSGi deployments.
+ // [todo] this use the required stage processing
+ unit.addAttachment(PROPERTY_AUTO_START, Boolean.FALSE);
+ }
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-11 16:40:12 UTC (rev 96265)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-11 16:53:48 UTC (rev 96266)
@@ -52,14 +52,12 @@
public void testNoManifest() throws Exception
{
- // TODO no manifest
- // testBundle("smoke-no-manifest", Bundle.ACTIVE);
+ testBundle("smoke-no-manifest", Bundle.ACTIVE);
}
public void testNonOSGiManifest() throws Exception
{
- // TODO no manifest
- // testBundle("smoke-non-osgi-manifest", Bundle.ACTIVE);
+ testBundle("smoke-non-osgi-manifest", Bundle.ACTIVE);
}
public void testOSGiManifest() throws Exception
More information about the jboss-cvs-commits
mailing list