JBoss-OSGI SVN: r96268 - in projects/jboss-osgi/trunk/reactor/framework/src: test/java/org/jboss/test/osgi and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-11 12:37:13 -0500 (Wed, 11 Nov 2009)
New Revision: 96268
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
Log:
Add some more smoke tests for deploying bundles and non-bundles through the MainDeployer along with tests for passing OSGiMetaData explicitly, as would be done by the management console
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 17:19:53 UTC (rev 96267)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11 17:37:13 UTC (rev 96268)
@@ -108,7 +108,7 @@
public static final String BEAN_BUNDLE_MANAGER = "OSGiBundleManager";
/** The string representation of this bundle's location identifier. */
- private static final String PROPERTY_BUNDLE_LOCATION = "org.jboss.osgi.bundle.location";
+ public static final String PROPERTY_BUNDLE_LOCATION = "org.jboss.osgi.bundle.location";
/** The framework version */
private static String OSGi_FRAMEWORK_VERSION = "r4v42"; // [TODO] externalise
@@ -233,6 +233,16 @@
}
/**
+ * Get the deployerClient.
+ *
+ * @return the deployerClient.
+ */
+ public DeployerClient getDeployerClient()
+ {
+ return deployerClient;
+ }
+
+ /**
* Set the framework properties
*
* @param properties the properties
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java 2009-11-11 17:19:53 UTC (rev 96267)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java 2009-11-11 17:37:13 UTC (rev 96268)
@@ -34,6 +34,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.test.kernel.junit.MicrocontainerTest;
import org.jboss.virtual.AssembledDirectory;
@@ -142,6 +143,31 @@
}
/**
+ * Create a bundle
+ *
+ * @param root the location of the location to deploy
+ * @param child the child to deploy
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle deployBundle(String root, String child) throws Exception
+ {
+ return getDelegate().deployBundle(root, child);
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle deployBundle(VirtualFile file) throws Exception
+ {
+ return getDelegate().deployBundle(file);
+ }
+
+ /**
* Remove a bundle
*
* @param bundle the bundle to remove
@@ -167,6 +193,36 @@
return getDelegate().assembleBundle(name, resourcePaths, packages);
}
+ protected Bundle deployBundle(String name, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, null, (String[]) null, packages);
+ }
+
+ protected Bundle deployBundle(String name, String resourcePath, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, null, resourcePath, packages);
+ }
+
+ protected Bundle deployBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, null, resourcePaths, packages);
+ }
+
+ protected Bundle deployBundle(String name, OSGiMetaData metaData, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, metaData, (String[]) null, packages);
+ }
+
+ protected Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, metaData, resourcePath, packages);
+ }
+
+ protected Bundle deployBundle(String name, OSGiMetaData metaData, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, metaData, resourcePaths, packages);
+ }
+
protected AssembledDirectory createAssembledDirectory(String name) throws Exception
{
return getDelegate().createAssembledDirectory(name, "");
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11 17:19:53 UTC (rev 96267)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11 17:37:13 UTC (rev 96268)
@@ -23,6 +23,7 @@
// $Id: $
+import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Collection;
@@ -32,9 +33,17 @@
import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VFS;
@@ -143,6 +152,11 @@
}
return bundleManager;
}
+
+ public DeployerClient getDeployerClient()
+ {
+ return getBundleManager().getDeployerClient();
+ }
/**
* Create a bundle
@@ -202,14 +216,104 @@
public Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
{
- AssembledDirectory assembledDirectory = createAssembledDirectory(name, "");
- for (String path : resourcePaths)
- addPath(assembledDirectory, path, "");
- for (Class<?> reference : packages)
- addPackage(assembledDirectory, reference);
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", resourcePaths, packages);
return addBundle(assembledDirectory);
}
+ public Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath, Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", new String[] { resourcePath }, packages);
+ return deployBundle(assembledDirectory, metaData);
+ }
+
+ public Bundle deployBundle(String name, OSGiMetaData metaData, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", resourcePaths, packages);
+ return deployBundle(assembledDirectory, metaData);
+ }
+
+ public Bundle deployBundle(VirtualFile virtualFile, OSGiMetaData metaData) throws Exception
+ {
+ Deployment deployment = createDeployment(virtualFile, metaData);
+ return deployBundle(deployment);
+ }
+
+ public Bundle deployBundle(String root, String child) throws Exception
+ {
+ URL resourceRoot = getClass().getResource(root);
+ if (resourceRoot == null)
+ throw new AssertionFailedError("Resource not found: " + root);
+ URL childResource = new URL(resourceRoot, child);
+ return deployBundle(childResource);
+ }
+
+ public Bundle deployBundle(URL url) throws Exception
+ {
+ // Get the root file
+ VirtualFile root;
+ try
+ {
+ root = VFS.getRoot(url);
+ }
+ catch (IOException e)
+ {
+ throw new BundleException("Invalid url=" + url, e);
+ }
+
+ return deployBundle(root);
+ }
+
+ public Bundle deployBundle(VirtualFile file) throws Exception
+ {
+ return deployBundle(file, null);
+ }
+
+ public Bundle deployBundle(Deployment deployment) throws Exception
+ {
+ DeployerClient deployerClient = getDeployerClient();
+ MainDeployerStructure deployerStructure = (MainDeployerStructure) deployerClient;
+ deployerClient.deploy(deployment);
+ try
+ {
+ DeploymentUnit unit = deployerStructure.getDeploymentUnit(deployment.getName());
+ OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ if (bundleState == null)
+ throw new IllegalStateException("Unable to determine bundle state for " + deployment.getName());
+
+ return bundleState.getBundleInternal();
+ }
+ catch (Exception e)
+ {
+ deployerClient.undeploy(deployment);
+ throw e;
+ }
+ }
+
+ public Deployment createDeployment(VirtualFile virtualFile, OSGiMetaData metaData) throws Exception
+ {
+ VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
+ MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+ if (metaData != null)
+ att.addAttachment(OSGiMetaData.class, metaData);
+ return deployment;
+ }
+
+ public AssembledDirectory createAssembledDirectory(String name, String rootName, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name, rootName);
+ if (resourcePaths != null)
+ {
+ for (String path : resourcePaths)
+ addPath(assembledDirectory, path, "");
+ }
+ if (packages != null)
+ {
+ for (Class<?> reference : packages)
+ addPackage(assembledDirectory, reference);
+ }
+ return assembledDirectory;
+ }
+
public AssembledDirectory createAssembledDirectory(String name) throws Exception
{
return createAssembledDirectory(name, "");
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 17:19:53 UTC (rev 96267)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-11 17:37:13 UTC (rev 96268)
@@ -23,9 +23,13 @@
import java.io.InputStream;
import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import junit.framework.Test;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.smoke.support.a.A;
import org.jboss.test.osgi.smoke.support.a.b.B;
@@ -82,6 +86,59 @@
}
}
+ public void testDeployedNoManifest() throws Exception
+ {
+ testDeployedBundle("smoke-no-manifest", Bundle.ACTIVE);
+ }
+
+ public void testDeployedNonOSGiManifest() throws Exception
+ {
+ testDeployedBundle("smoke-non-osgi-manifest", Bundle.ACTIVE);
+ }
+
+ public void testDeployedOSGiManifest() throws Exception
+ {
+ testDeployedBundle("smoke-osgi-manifest", Bundle.INSTALLED);
+ }
+
+ public void testAssembledDeployment() throws Exception
+ {
+ Manifest manifest = new Manifest();
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.putValue("Bundle-Name", "SmokeDeployment");
+ attributes.putValue("Bundle-SymbolicName", "org.jboss.test.osgi.smoke.deployment");
+ OSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
+ Bundle bundle = deployBundle("smoke-deployment", metaData, A.class);
+ try
+ {
+ assertEquals(Bundle.INSTALLED, bundle.getState());
+ bundle.start();
+ assertLoadClass(bundle, A.class);
+ assertLoadClassFail(bundle, B.class);
+ assertLoadClassFail(bundle, C.class);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+
+ public void testAssembledNonOSGiDeployment() throws Exception
+ {
+ Bundle bundle = deployBundle("smoke-non-osgi-deployment", A.class);
+ try
+ {
+ assertEquals(Bundle.ACTIVE, bundle.getState());
+ assertLoadClass(bundle, A.class);
+ assertLoadClassFail(bundle, B.class);
+ assertLoadClassFail(bundle, C.class);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+
protected void testBundle(String name, int expectedState) throws Exception
{
Bundle bundle = addBundle("/bundles/smoke/", name);
@@ -95,6 +152,19 @@
}
}
+ protected void testDeployedBundle(String name, int expectedState) throws Exception
+ {
+ Bundle bundle = deployBundle("/bundles/smoke/", name);
+ try
+ {
+ testBundle(bundle, name, expectedState);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+
protected void testBundle(Bundle bundle, String name, int expectedState) throws Exception
{
assertEquals(expectedState, bundle.getState());
14 years, 8 months
JBoss-OSGI SVN: r96267 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-11-11 12:19:53 -0500 (Wed, 11 Nov 2009)
New Revision: 96267
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/Handler.java
Log:
Use host-less handler.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/Handler.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/Handler.java 2009-11-11 16:53:48 UTC (rev 96266)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/Handler.java 2009-11-11 17:19:53 UTC (rev 96267)
@@ -24,18 +24,18 @@
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
-import java.net.URLStreamHandler;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.HostlessHandler;
/**
* Bundle url stream handler.
*
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
-public class Handler extends URLStreamHandler
+public class Handler extends HostlessHandler
{
protected URLConnection openConnection(URL u) throws IOException
{
14 years, 8 months
JBoss-OSGI SVN: r96266 - in projects/jboss-osgi/trunk/reactor/framework/src: main/java/org/jboss/osgi/framework/deployers and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)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
14 years, 8 months
JBoss-OSGI SVN: r96263 - in projects/jboss-osgi/trunk/reactor/framework/src: test/java/org/jboss/test/osgi and 10 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-11 10:59:11 -0500 (Wed, 11 Nov 2009)
New Revision: 96263
Added:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bootstrap/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFrameworkFactory.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/launch/FrameworkLaunchTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
Log:
[JBOSGI-202] - Add properties to control where the bootstrap file comes from and fix the broken testsuite caused by refactoring
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFrameworkFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFrameworkFactory.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFrameworkFactory.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -23,9 +23,14 @@
// $Id$
+import java.net.MalformedURLException;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.jboss.dependency.plugins.AbstractControllerContext;
@@ -40,7 +45,6 @@
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -53,9 +57,12 @@
*/
public class OSGiFrameworkFactory implements FrameworkFactory
{
- // Provide logging
- final Logger log = Logger.getLogger(OSGiFrameworkFactory.class);
+ /** The system property used to get a bootstrap url */
+ public static final String BOOTSTRAP_URL = "org.jboss.osgi.framework.launch.bootstrapURL";
+ /** The system property used to get a bootstrap path loaded from a classloader */
+ public static final String BOOTSTRAP_PATH = "org.jboss.osgi.framework.launch.bootstrapPath";
+
@SuppressWarnings("unchecked")
public Framework newFramework(Map configuration)
{
@@ -69,7 +76,29 @@
BasicXMLDeployer deployer = new BasicXMLDeployer(kernel, ControllerMode.AUTOMATIC);
URL url = null;
- String[] bootstraps = new String[] { "jboss-osgi-bootstrap.xml", "META-INF/jboss-osgi-bootstrap.xml", "META-INF/jboss-osgi-default-bootstrap.xml" };
+
+ // Specified urls
+ String bootstrapURL = getProperty(BOOTSTRAP_URL);
+ if (bootstrapURL != null)
+ {
+ try
+ {
+ url = new URL(bootstrapURL);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Invalid system property " + BOOTSTRAP_URL, e);
+ }
+ }
+
+ // Default bootstrap paths
+ List<String> bootstraps = Arrays.asList("jboss-osgi-bootstrap.xml", "META-INF/jboss-osgi-bootstrap.xml", "META-INF/jboss-osgi-default-bootstrap.xml");
+
+ // Specified bootstrap path
+ String bootstrapPath = getProperty(BOOTSTRAP_PATH);
+ if (bootstrapPath != null)
+ bootstraps = Collections.singletonList(bootstrapPath);
+
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
for (String xml : bootstraps)
{
@@ -118,4 +147,24 @@
return controller;
}
+ /**
+ * Get a property
+ *
+ * @param propertyName the property name
+ * @return the property
+ */
+ private String getProperty(final String propertyName)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ return System.getProperty(propertyName);
+
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(propertyName);
+ }
+ });
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -67,7 +67,7 @@
*/
protected void deploy() throws Exception
{
- String common = "/META-INF/jboss-osgi-bootstrap.xml";
+ String common = "/bootstrap/jboss-osgi-bootstrap.xml";
URL url = getClass().getResource(common);
if (url == null)
throw new IllegalStateException(common + " not found");
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -29,6 +29,8 @@
import java.util.Locale;
import java.util.Set;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -48,6 +50,11 @@
*/
public class BundleContextUnitTestCase extends FrameworkTestCase
{
+ public static Test suite()
+ {
+ return suite(BundleContextUnitTestCase.class);
+ }
+
public BundleContextUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -28,6 +28,8 @@
import java.util.HashSet;
import java.util.Set;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
@@ -41,6 +43,11 @@
*/
public class BundleEntriesUnitTestCase extends FrameworkTestCase
{
+ public static Test suite()
+ {
+ return suite(BundleEntriesUnitTestCase.class);
+ }
+
public BundleEntriesUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -25,6 +25,8 @@
import java.util.Hashtable;
import java.util.jar.Attributes;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -40,6 +42,11 @@
*/
public class BundleUnitTestCase extends FrameworkTestCase
{
+ public static Test suite()
+ {
+ return suite(BundleUnitTestCase.class);
+ }
+
public BundleUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -24,6 +24,8 @@
import java.util.Dictionary;
import java.util.Hashtable;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -43,6 +45,11 @@
super(name);
}
+ public static Test suite()
+ {
+ return suite(SystemBundleUnitTestCase.class);
+ }
+
public void testBundleId() throws Exception
{
assertEquals(0, getSystemBundle().getBundleId());
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -41,6 +41,11 @@
*/
public class BundleClassPathTest extends OSGiTest
{
+ public void setUp()
+ {
+ System.setProperty("org.jboss.osgi.framework.launch.bootstrapPath", "bootstrap/jboss-osgi-bootstrap.xml");
+ }
+
@Test
public void testBundleClassPath() throws Exception
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.osgi.classloader;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
@@ -41,6 +43,11 @@
*/
public class ExportImportPackageUnitTestCase extends FrameworkTestCase
{
+ public static Test suite()
+ {
+ return suite(ExportImportPackageUnitTestCase.class);
+ }
+
public ExportImportPackageUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.osgi.classloader;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
@@ -41,6 +43,11 @@
super(name);
}
+ public static Test suite()
+ {
+ return suite(RequireBundleUnitTestCase.class);
+ }
+
public void testSimpleRequireBundle() throws Exception
{
Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -46,6 +46,11 @@
*/
public class SimpleBundleTestCase
{
+ public void setUp()
+ {
+ System.setProperty("org.jboss.osgi.framework.launch.bootstrapPath", "bootstrap/jboss-osgi-bootstrap.xml");
+ }
+
@Test
public void testBundleInstallLauchAPI() throws Exception
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTest.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTest.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -51,6 +51,7 @@
public void setUp()
{
System.clearProperty("simple-logservice-bundle");
+ System.setProperty("org.jboss.osgi.framework.launch.bootstrapPath", "bootstrap/jboss-osgi-bootstrap.xml");
}
@Test
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/launch/FrameworkLaunchTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/launch/FrameworkLaunchTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/launch/FrameworkLaunchTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -40,6 +40,11 @@
*/
public class FrameworkLaunchTestCase
{
+ public void setUp()
+ {
+ System.setProperty("org.jboss.osgi.framework.launch.bootstrapPath", "bootstrap/jboss-osgi-bootstrap.xml");
+ }
+
@Test
public void testFrameworkLaunch() throws BundleException
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -48,6 +48,8 @@
@BeforeClass
public static void beforeClass() throws BundleException
{
+ System.setProperty("org.jboss.osgi.framework.launch.bootstrapPath", "bootstrap/jboss-osgi-bootstrap.xml");
+
OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
framework = (OSGiFramework)bootProvider.getFramework();
framework.start();
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -50,6 +50,11 @@
*/
public class ResolverSmokeTest extends OSGiTest
{
+ public void setUp()
+ {
+ System.setProperty("org.jboss.osgi.framework.launch.bootstrapPath", "bootstrap/jboss-osgi-bootstrap.xml");
+ }
+
@Test
public void testBundleResolver() throws BundleException
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -24,6 +24,8 @@
import java.util.Dictionary;
import java.util.Hashtable;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.b.B;
@@ -43,6 +45,11 @@
*/
public class GetServiceReferencesUnitTestCase extends FrameworkTestCase
{
+ public static Test suite()
+ {
+ return suite(GetServiceReferencesUnitTestCase.class);
+ }
+
public GetServiceReferencesUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.osgi.service;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.BrokenServiceFactory;
import org.osgi.framework.Bundle;
@@ -39,6 +41,11 @@
{
static String OBJCLASS = BundleContext.class.getName();
+ public static Test suite()
+ {
+ return suite(GetUnGetServiceUnitTestCase.class);
+ }
+
public GetUnGetServiceUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -24,6 +24,8 @@
import java.util.Dictionary;
import java.util.Hashtable;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -43,6 +45,11 @@
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
+ public static Test suite()
+ {
+ return suite(RegisterServiceUnitTestCase.class);
+ }
+
public RegisterServiceUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.osgi.service;
+import junit.framework.Test;
+
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
@@ -42,6 +44,11 @@
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
+ public static Test suite()
+ {
+ return suite(ServiceFactoryUnitTestCase.class);
+ }
+
public ServiceFactoryUnitTestCase(String name)
{
super(name);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -28,6 +28,8 @@
import java.util.Set;
import java.util.TreeSet;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.osgi.framework.Bundle;
@@ -50,6 +52,11 @@
super(name);
}
+ public static Test suite()
+ {
+ return suite(ServiceReferenceUnitTestCase.class);
+ }
+
public void testGetProperty() throws Exception
{
ServiceReference reference = null;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -23,6 +23,8 @@
import java.util.Hashtable;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.osgi.framework.Bundle;
@@ -45,6 +47,11 @@
super(name);
}
+ public static Test suite()
+ {
+ return suite(ServiceRegistrationUnitTestCase.class);
+ }
+
public void testGetReference() throws Exception
{
Bundle bundle = addBundle("/bundles/simple/", "simple-bundle1");
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 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-11 15:59:11 UTC (rev 96263)
@@ -24,6 +24,8 @@
import java.io.InputStream;
import java.net.URL;
+import junit.framework.Test;
+
import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.smoke.support.a.A;
import org.jboss.test.osgi.smoke.support.a.b.B;
@@ -38,6 +40,11 @@
*/
public class OSGiSmokeTestCase extends FrameworkTestCase
{
+ public static Test suite()
+ {
+ return suite(OSGiSmokeTestCase.class);
+ }
+
public OSGiSmokeTestCase(String name)
{
super(name);
@@ -45,14 +52,14 @@
public void testNoManifest() throws Exception
{
- // [TODO] discuss no manifest
- //testBundle("smoke-no-manifest", Bundle.ACTIVE);
+ // TODO no manifest
+ // testBundle("smoke-no-manifest", Bundle.ACTIVE);
}
public void testNonOSGiManifest() throws Exception
{
- // [TODO] discuss no osgi manifest
- //testBundle("smoke-non-osgi-manifest", Bundle.ACTIVE);
+ // TODO no manifest
+ // testBundle("smoke-non-osgi-manifest", Bundle.ACTIVE);
}
public void testOSGiManifest() throws Exception
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-11-11 15:28:38 UTC (rev 96262)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-11-11 15:59:11 UTC (rev 96263)
@@ -1,182 +0,0 @@
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!--
- ********************************
- * *
- * OSGi Framework *
- * *
- ********************************
- -->
-
- <bean name="OSGiBundleManager" class="org.jboss.osgi.framework.bundle.OSGiBundleManager">
- <constructor>
- <parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
- <parameter><inject bean="MainDeployer" /></parameter>
- </constructor>
- <property name="properties">
- <map keyClass="java.lang.String" valueClass="java.lang.String">
- <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
- <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
- <entry><key>org.osgi.framework.system.packages.extra</key><value>
-
- org.jboss.logging;version=2.0,
-
- org.jboss.osgi.spi;version=1.0,
- org.jboss.osgi.spi.capability;version=1.0,
- org.jboss.osgi.spi.management;version=1.0,
- org.jboss.osgi.spi.service;version=1.0,
- org.jboss.osgi.spi.util;version=1.0,
-
- org.osgi.framework,
- org.osgi.framework.launch,
- org.osgi.service.startlevel,
- org.osgi.service.packageadmin
- </value></entry>
- </map>
- </property>
- <incallback method="addPlugin" />
- <uncallback method="removePlugin" />
- </bean>
-
- <!--
- ********************************
- * *
- * OSGi Framework Plugins *
- * *
- ********************************
- -->
-
- <bean name="OSGiBundleResolver" class="org.jboss.osgi.framework.resolver.internal.basic.BasicResolverImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="OSGiSystemPackages" class="org.jboss.osgi.framework.plugins.internal.SystemPackagesPluginImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
-
- <!--
- ********************************
- * *
- * OSGi Service Plugins *
- * *
- ********************************
- -->
-
- <bean name="MicrocontainerService" class="org.jboss.osgi.framework.service.internal.MicrocontainerServiceImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="StartLevelService" class="org.jboss.osgi.framework.service.internal.StartLevelImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
-
- <!--
- ********************************
- * *
- * OSGi Deployment *
- * *
- ********************************
- -->
-
- <!-- The MainDeployer -->
- <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
- <property name="structuralDeployers"><inject bean="StructuralDeployers" /></property>
- <property name="deployers"><inject bean="Deployers" /></property>
- </bean>
-
- <!-- The holder for deployers that determine structure -->
- <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
- <property name="structureBuilder">
- <!-- The consolidator of the structure information -->
- <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder" />
- </property>
- <!-- Accept any implementor of structure deployer -->
- <incallback method="addDeployer" />
- <uncallback method="removeDeployer" />
- </bean>
-
- <!-- The holder for deployers that do real deployment -->
- <bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
- <constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
- <!-- Accept any implementor of deployer -->
- <incallback method="addDeployer" />
- <uncallback method="removeDeployer" />
- </bean>
-
- <!-- Bundle Structure -->
- <bean name="BundleStructure" class="org.jboss.osgi.deployer.BundleStructureDeployer" />
-
- <!-- JAR & File Structure (needed for negative testing) -->
- <bean name="JARStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure" />
- <bean name="FileStructure" class="org.jboss.deployers.vfs.plugins.structure.file.FileStructure" />
-
- <!-- POJO Deployment -->
- <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer" />
- <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer" />
- <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
- <constructor>
- <parameter class="org.jboss.dependency.spi.Controller"><inject bean="jboss.kernel:service=KernelController" /></parameter>
- </constructor>
- </bean>
-
- <!-- OSGI Deployment -->
- <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
- <bean name="OSGiBundleStateDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateDeployer">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
- <bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
-
- <!--
- ********************************
- * *
- * OSGi Classloading *
- * *
- ********************************
- -->
-
- <bean name="OSGiClassLoaderSystem" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderSystem" />
- <bean name="OSGiClassLoaderDomain" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderDomain" >
- <constructor><parameter>OSGiClassLoaderDomain</parameter></constructor>
- <property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
- <property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
- </bean>
- <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
- <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
- </bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
- <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
- <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
- </bean>
-
- <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
- <incallback method="addModule" state="Configured" />
- <uncallback method="removeModule" state="Configured" />
- </bean>
- <bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
- <property name="defaultMetaData">
- <classloading xmlns="urn:jboss:classloading:1.0" export-all="NON_EMPTY" import-all="true" />
- </property>
- </bean>
- <bean name="ClassLoaderClassPathDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer" />
- <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
- <property name="classLoading"><inject bean="ClassLoading" /></property>
- </bean>
- <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
- <property name="classLoading"><inject bean="ClassLoading" /></property>
- <property name="system"><inject bean="OSGiClassLoaderSystem" /></property>
- </bean>
-
-</deployment>
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml (from rev 96255, projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2009-11-11 15:59:11 UTC (rev 96263)
@@ -0,0 +1,182 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!--
+ ********************************
+ * *
+ * OSGi Framework *
+ * *
+ ********************************
+ -->
+
+ <bean name="OSGiBundleManager" class="org.jboss.osgi.framework.bundle.OSGiBundleManager">
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
+ <parameter><inject bean="MainDeployer" /></parameter>
+ </constructor>
+ <property name="properties">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
+ <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+ <entry><key>org.osgi.framework.system.packages.extra</key><value>
+
+ org.jboss.logging;version=2.0,
+
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.capability;version=1.0,
+ org.jboss.osgi.spi.management;version=1.0,
+ org.jboss.osgi.spi.service;version=1.0,
+ org.jboss.osgi.spi.util;version=1.0,
+
+ org.osgi.framework,
+ org.osgi.framework.launch,
+ org.osgi.service.startlevel,
+ org.osgi.service.packageadmin
+ </value></entry>
+ </map>
+ </property>
+ <incallback method="addPlugin" />
+ <uncallback method="removePlugin" />
+ </bean>
+
+ <!--
+ ********************************
+ * *
+ * OSGi Framework Plugins *
+ * *
+ ********************************
+ -->
+
+ <bean name="OSGiBundleResolver" class="org.jboss.osgi.framework.resolver.internal.basic.BasicResolverImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="OSGiSystemPackages" class="org.jboss.osgi.framework.plugins.internal.SystemPackagesPluginImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+
+ <!--
+ ********************************
+ * *
+ * OSGi Service Plugins *
+ * *
+ ********************************
+ -->
+
+ <bean name="MicrocontainerService" class="org.jboss.osgi.framework.service.internal.MicrocontainerServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="StartLevelService" class="org.jboss.osgi.framework.service.internal.StartLevelImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+
+ <!--
+ ********************************
+ * *
+ * OSGi Deployment *
+ * *
+ ********************************
+ -->
+
+ <!-- The MainDeployer -->
+ <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
+ <property name="structuralDeployers"><inject bean="StructuralDeployers" /></property>
+ <property name="deployers"><inject bean="Deployers" /></property>
+ </bean>
+
+ <!-- The holder for deployers that determine structure -->
+ <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
+ <property name="structureBuilder">
+ <!-- The consolidator of the structure information -->
+ <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder" />
+ </property>
+ <!-- Accept any implementor of structure deployer -->
+ <incallback method="addDeployer" />
+ <uncallback method="removeDeployer" />
+ </bean>
+
+ <!-- The holder for deployers that do real deployment -->
+ <bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
+ <constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
+ <!-- Accept any implementor of deployer -->
+ <incallback method="addDeployer" />
+ <uncallback method="removeDeployer" />
+ </bean>
+
+ <!-- Bundle Structure -->
+ <bean name="BundleStructure" class="org.jboss.osgi.deployer.BundleStructureDeployer" />
+
+ <!-- JAR & File Structure (needed for negative testing) -->
+ <bean name="JARStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure" />
+ <bean name="FileStructure" class="org.jboss.deployers.vfs.plugins.structure.file.FileStructure" />
+
+ <!-- POJO Deployment -->
+ <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer" />
+ <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer" />
+ <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
+ <constructor>
+ <parameter class="org.jboss.dependency.spi.Controller"><inject bean="jboss.kernel:service=KernelController" /></parameter>
+ </constructor>
+ </bean>
+
+ <!-- OSGI Deployment -->
+ <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
+ <bean name="OSGiBundleStateDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateDeployer">
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
+ <bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
+
+ <!--
+ ********************************
+ * *
+ * OSGi Classloading *
+ * *
+ ********************************
+ -->
+
+ <bean name="OSGiClassLoaderSystem" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderSystem" />
+ <bean name="OSGiClassLoaderDomain" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderDomain" >
+ <constructor><parameter>OSGiClassLoaderDomain</parameter></constructor>
+ <property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
+ <property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
+ </bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
+ </bean>
+
+ <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+ <incallback method="addModule" state="Configured" />
+ <uncallback method="removeModule" state="Configured" />
+ </bean>
+ <bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
+ <property name="defaultMetaData">
+ <classloading xmlns="urn:jboss:classloading:1.0" export-all="NON_EMPTY" import-all="true" />
+ </property>
+ </bean>
+ <bean name="ClassLoaderClassPathDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer" />
+ <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
+ <property name="classLoading"><inject bean="ClassLoading" /></property>
+ </bean>
+ <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
+ <property name="classLoading"><inject bean="ClassLoading" /></property>
+ <property name="system"><inject bean="OSGiClassLoaderSystem" /></property>
+ </bean>
+
+</deployment>
14 years, 8 months
JBoss-OSGI SVN: r96262 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-11-11 10:28:38 -0500 (Wed, 11 Nov 2009)
New Revision: 96262
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
Log:
The bundle usage is enough.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-11 15:19:33 UTC (rev 96261)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-11 15:28:38 UTC (rev 96262)
@@ -30,12 +30,12 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
import org.jboss.virtual.spi.VFSContext;
import org.jboss.virtual.spi.VirtualFileHandler;
+import org.osgi.framework.Bundle;
/**
* Bundle handler.
@@ -48,19 +48,19 @@
private static final long serialVersionUID = 6650185906199900589L;
private VirtualFile file;
- private OSGiBundleState bundleState;
+ private Bundle bundle;
private VirtualFileHandler handler;
- public BundleHandler(VFSContext context, VirtualFile file, OSGiBundleState bundleState) throws IOException
+ public BundleHandler(VFSContext context, VirtualFile file, Bundle bundle) throws IOException
{
- this(context, LazyVirtualFileHandler.create(file.getParent()), file, bundleState);
+ this(context, LazyVirtualFileHandler.create(file.getParent()), file, bundle);
}
- public BundleHandler(VFSContext context, VirtualFileHandler parent, VirtualFile file, OSGiBundleState bundleState) throws IOException
+ public BundleHandler(VFSContext context, VirtualFileHandler parent, VirtualFile file, Bundle bundle) throws IOException
{
super(context, parent, file.getName());
this.file = file;
- this.bundleState = bundleState;
+ this.bundle = bundle;
}
protected VirtualFileHandler getHandler() throws IOException
@@ -82,31 +82,31 @@
protected VirtualFileHandler createChildHandler(VirtualFile child) throws IOException
{
if (handler == null)
- return new BundleHandler(getVFSContext(), child, bundleState);
+ return new BundleHandler(getVFSContext(), child, bundle);
else
- return new BundleHandler(getVFSContext(), handler, child, bundleState);
+ return new BundleHandler(getVFSContext(), handler, child, bundle);
}
public URI toURI() throws URISyntaxException
{
- return new URI("bundle", Long.toString(bundleState.getBundleId()), getRelativePath(false), null);
+ return new URI("bundle", Long.toString(bundle.getBundleId()), getRelativePath(false), null);
}
public long getLastModified() throws IOException
{
- return bundleState.getLastModified();
+ return bundle.getLastModified();
}
public InputStream openStream() throws IOException
{
- bundleState.getResource(getRelativePath(false)); // permission check
+ bundle.getResource(getRelativePath(false)); // permission check
return file.openStream();
}
public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
{
- bundleState.findEntries(getRelativePath(false), null, false); // permission check
+ bundle.findEntries(getRelativePath(false), null, false); // permission check
List<VirtualFile> children = file.getChildren();
if (children != null && children.isEmpty() == false)
@@ -124,7 +124,7 @@
public VirtualFileHandler getChild(String path) throws IOException
{
String fullPath = getRelativePath(true) + path;
- URL entry = bundleState.getEntry(fullPath); // permission check
+ URL entry = bundle.getEntry(fullPath); // permission check
if (entry == null)
return null;
14 years, 8 months
JBoss-OSGI SVN: r96257 - in projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework: resolver and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-11 09:11:52 -0500 (Wed, 11 Nov 2009)
New Revision: 96257
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
Log:
Source code tidyup
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -123,6 +123,10 @@
/**
* Install a bundle from a virtual file
+ *
+ * @param root the root file
+ * @return the bundle
+ * @throws BundleException for any error
*/
public Bundle installBundle(VirtualFile root) throws BundleException
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -74,11 +74,15 @@
/**
* Add an importer of this export package.
+ *
+ * @param importer the importer
*/
void addImporter(ImportPackage importer);
/**
* Remove an importer of this export package.
+ *
+ * @param importer the importer
*/
void removeImporter(ImportPackage importer);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -70,6 +70,8 @@
/**
* Set the exporter that this import package is wired to.
+ *
+ * @param exporter the exporter
*/
void setExporter(ExportPackage exporter);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -54,6 +54,8 @@
/**
* Get the attribute value for the given key.
+ *
+ * @param key the key
* @return The attribute value or null.
*/
Object getAttribute(String key);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -85,11 +85,15 @@
/**
* Return true if this resolvable is a singleton.
+ *
+ * @return true when this is a singleton
*/
boolean isSingleton();
/**
* Return true if this resolvable has been resolved.
+ *
+ * @return true when it is resolved
*/
boolean isResolved();
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -41,13 +41,18 @@
List<Resolvable> getBundles();
/**
- * Get the registered resolvable bundle.
+ * Get the registered resolvable bundle.
+ *
+ * @param symbolicName the symbolic name of the bundle
+ * @param version the version of the bundle
* @return The registered resolvable bundle.
*/
Resolvable getBundle(String symbolicName, Version version);
/**
- * Get the registered resolvable bundle.
+ * Get the registered resolvable bundle.
+ *
+ * @param bundle the bundle
* @return The registered resolvable bundle.
*/
Resolvable getBundle(Bundle bundle);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -35,7 +35,6 @@
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.FactHandle;
-import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.resolver.AbstractResolver;
import org.jboss.osgi.framework.resolver.ExportPackage;
@@ -51,9 +50,6 @@
*/
public class RuleBasedResolverImpl extends AbstractResolver
{
- // Provide Logging
- private static final Logger log = Logger.getLogger(RuleBasedResolverImpl.class);
-
private StatefulKnowledgeSession ksession;
private Map<Object, FactHandle> facts = new ConcurrentHashMap<Object, FactHandle>();
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-11 13:45:27 UTC (rev 96256)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-11 14:11:52 UTC (rev 96257)
@@ -44,6 +44,9 @@
*/
class BundleHandler extends AbstractVirtualFileHandler
{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6650185906199900589L;
+
private VirtualFile file;
private OSGiBundleState bundleState;
private VirtualFileHandler handler;
14 years, 8 months
JBoss-OSGI SVN: r96254 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-11-11 04:05:28 -0500 (Wed, 11 Nov 2009)
New Revision: 96254
Added:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/LazyVirtualFileHandler.java
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java
Log:
Delay reflect hack as long as possible.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-11 08:33:58 UTC (rev 96253)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-11 09:05:28 UTC (rev 96254)
@@ -31,6 +31,8 @@
import java.util.List;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
import org.jboss.virtual.spi.VFSContext;
import org.jboss.virtual.spi.VirtualFileHandler;
@@ -42,16 +44,30 @@
*/
class BundleHandler extends AbstractVirtualFileHandler
{
+ private VirtualFile file;
+ private OSGiBundleState bundleState;
private VirtualFileHandler handler;
- private OSGiBundleState bundleState;
- public BundleHandler(VFSContext context, VirtualFileHandler parent, VirtualFileHandler handler, OSGiBundleState bundleState)
+ public BundleHandler(VFSContext context, VirtualFile file, OSGiBundleState bundleState) throws IOException
{
- super(context, parent, handler.getName());
- this.handler = handler;
+ this(context, LazyVirtualFileHandler.create(file.getParent()), file, bundleState);
+ }
+
+ public BundleHandler(VFSContext context, VirtualFileHandler parent, VirtualFile file, OSGiBundleState bundleState) throws IOException
+ {
+ super(context, parent, file.getName());
+ this.file = file;
this.bundleState = bundleState;
}
+ protected VirtualFileHandler getHandler() throws IOException
+ {
+ if (handler == null)
+ handler = LazyVirtualFileHandler.create(file);
+
+ return handler;
+ }
+
protected String getRelativePath(boolean checkEnd)
{
String path = handler.getLocalPathName();
@@ -60,6 +76,14 @@
return path;
}
+ protected VirtualFileHandler createChildHandler(VirtualFile child) throws IOException
+ {
+ if (handler == null)
+ return new BundleHandler(getVFSContext(), child, bundleState);
+ else
+ return new BundleHandler(getVFSContext(), handler, child, bundleState);
+ }
+
public URI toURI() throws URISyntaxException
{
return new URI("bundle", Long.toString(bundleState.getBundleId()), getRelativePath(false), null);
@@ -74,20 +98,20 @@
{
bundleState.getResource(getRelativePath(false)); // permission check
- return handler.openStream();
+ return file.openStream();
}
public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
{
bundleState.findEntries(getRelativePath(false), null, false); // permission check
- List<VirtualFileHandler> children = handler.getChildren(ignoreErrors);
+ List<VirtualFile> children = file.getChildren();
if (children != null && children.isEmpty() == false)
{
List<VirtualFileHandler> handlers = new ArrayList<VirtualFileHandler>(children.size());
- for (VirtualFileHandler child : children)
+ for (VirtualFile child : children)
{
- handlers.add(new BundleHandler(getVFSContext(), handler, child, bundleState));
+ handlers.add(createChildHandler(child));
}
return handlers;
}
@@ -101,39 +125,39 @@
if (entry == null)
return null;
- VirtualFileHandler child = handler.getChild(path); // the child should exist, since entry does
- return new BundleHandler(getVFSContext(), handler, child, bundleState);
+ VirtualFile child = file.getChild(path); // the child should exist, since entry does
+ return createChildHandler(child);
}
//---------------------------------------------------------
public long getSize() throws IOException
{
- return handler.getSize();
+ return file.getSize();
}
public boolean exists() throws IOException
{
- return handler.exists();
+ return file.exists();
}
public boolean isLeaf() throws IOException
{
- return handler.isLeaf();
+ return file.isLeaf();
}
public boolean isHidden() throws IOException
{
- return handler.isHidden();
+ return file.isHidden();
}
public boolean removeChild(String name) throws IOException
{
- return handler.removeChild(name);
+ return getHandler().removeChild(name);
}
public boolean isNested() throws IOException
{
- return handler.isNested();
+ return VFSUtils.isNestedFile(file);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java 2009-11-11 08:33:58 UTC (rev 96253)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java 2009-11-11 09:05:28 UTC (rev 96254)
@@ -22,10 +22,8 @@
package org.jboss.osgi.framework.vfs;
import java.io.IOException;
-import java.lang.reflect.Method;
import java.net.URI;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
+import java.net.URL;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
@@ -43,30 +41,6 @@
*/
public class BundleVFSContext extends AbstractVFSContext
{
- private static final Method getHandler;
-
- static
- {
- try
- {
- PrivilegedExceptionAction<Method> action = new PrivilegedExceptionAction<Method>()
- {
- public Method run() throws Exception
- {
- Method method = VirtualFile.class.getDeclaredMethod("getHandler");
- method.setAccessible(true);
- return method;
- }
- };
- getHandler = AccessController.doPrivileged(action);
-
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
private String host;
private VirtualFileHandler root;
@@ -83,28 +57,22 @@
if (abs == null)
throw new IllegalArgumentException("No such bundle: " + id);
+ String path = rootURI.getPath();
+ if (path == null)
+ path = "";
+
OSGiBundleState bundleState = OSGiBundleState.class.cast(abs); // should be able to cast, as it's not system
+ URL resource = bundleState.getEntry(path); // permission check
+ if (resource == null)
+ throw new IllegalArgumentException("No such resource: " + path + " in bundle: " + bundleState);
+
DeploymentUnit unit = bundleState.getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit == false)
throw new IllegalArgumentException("Cannot handle non VFS deployments: " + unit);
- String path = rootURI.getPath();
- if (path == null)
- path = "";
-
VFSDeploymentUnit vdu = VFSDeploymentUnit.class.cast(unit);
- VirtualFile file = vdu.getFile(path);
- try
- {
- VirtualFileHandler handler = (VirtualFileHandler)getHandler.invoke(file);
- root = new BundleHandler(this, handler.getParent(), handler, bundleState);
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
+ VirtualFile file = vdu.getFile(path); // should exist, resource != null
+ root = new BundleHandler(this, file, bundleState);
}
public String getName()
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/LazyVirtualFileHandler.java (from rev 96232, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/LazyVirtualFileHandler.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/LazyVirtualFileHandler.java 2009-11-11 09:05:28 UTC (rev 96254)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.framework.vfs;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VirtualFileHandler;
+
+/**
+ * Create a lazy VirtualFileHandler based off VirtualFile
+ *
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+class LazyVirtualFileHandler
+{
+ private static final Method getHandler;
+
+ static
+ {
+ try
+ {
+ PrivilegedExceptionAction<Method> action = new PrivilegedExceptionAction<Method>()
+ {
+ public Method run() throws Exception
+ {
+ Method method = VirtualFile.class.getDeclaredMethod("getHandler");
+ method.setAccessible(true);
+ return method;
+ }
+ };
+ getHandler = AccessController.doPrivileged(action);
+
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Create a VFH proxy, delaying the actual reflect hack.
+ *
+ * @param file the VFH owner
+ * @return VFH proxy
+ * @throws IOException for any error
+ */
+ static VirtualFileHandler create(VirtualFile file) throws IOException
+ {
+ if (file == null)
+ return null;
+
+ ClassLoader cl = LazyVirtualFileHandler.class.getClassLoader();
+ Object proxy = Proxy.newProxyInstance(cl, new Class<?>[]{VirtualFileHandler.class}, new ProxyHandler(file));
+ return VirtualFileHandler.class.cast(proxy);
+ }
+
+ private static class ProxyHandler implements InvocationHandler
+ {
+ private VirtualFile file;
+ private volatile VirtualFileHandler handler;
+
+ private ProxyHandler(VirtualFile file)
+ {
+ this.file = file;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ return method.invoke(getHandler(), args);
+ }
+
+ private VirtualFileHandler getHandler() throws Exception
+ {
+ if (handler == null)
+ handler = (VirtualFileHandler)getHandler.invoke(file);
+
+ return handler;
+ }
+ }
+}
\ No newline at end of file
14 years, 8 months
JBoss-OSGI SVN: r96251 - in projects/jboss-osgi/trunk/reactor/framework: src/main/java/org/jboss/osgi/framework/bundle and 6 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-11 02:10:01 -0500 (Wed, 11 Nov 2009)
New Revision: 96251
Modified:
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
Log:
More work on rule based resolver
Revert back to jboss-vfs-2.1.3.SP1
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-11 07:10:01 UTC (rev 96251)
@@ -38,7 +38,6 @@
<properties>
<version.drools>5.0.1</version.drools>
<version.jboss.aop>2.1.0.CR3</version.jboss.aop>
- <version.jboss.vfs>2.2.0-SNAPSHOT</version.jboss.vfs>
<version.jboss.classloading>2.0.8-SNAPSHOT</version.jboss.classloading>
<version.jboss.deployers>2.0.9-SNAPSHOT</version.jboss.deployers>
<version.jboss.microcontainer>2.0.9.GA</version.jboss.microcontainer>
@@ -113,11 +112,6 @@
<version>${version.jboss.classloading}</version>
</dependency>
<dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <version>${version.jboss.vfs}</version>
- </dependency>
- <dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading</artifactId>
<version>${version.jboss.classloading}</version>
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -43,6 +43,7 @@
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.util.collection.ConcurrentSet;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -586,7 +587,7 @@
checkValidBundleContext();
checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
- AbstractBundleState bundleState = getBundleManager().install(location, input);
+ AbstractBundleState bundleState = getBundleManager().installBundle(location, input);
return bundleState.getBundleInternal();
}
@@ -595,6 +596,15 @@
return installBundle(location, null);
}
+ public Bundle installBundle(VirtualFile root) throws BundleException
+ {
+ checkValidBundleContext();
+ checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
+
+ AbstractBundleState bundleState = getBundleManager().installBundle(root);
+ return bundleState.getBundleInternal();
+ }
+
@Override
public String toString()
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -25,6 +25,7 @@
import java.io.InputStream;
import java.util.Dictionary;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -140,6 +141,11 @@
return bundleState.installBundle(location);
}
+ public Bundle install(VirtualFile root) throws BundleException
+ {
+ return bundleState.installBundle(root);
+ }
+
@SuppressWarnings("unchecked")
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
{
@@ -167,14 +173,14 @@
bundleState.removeServiceListener(listener);
}
+ public boolean ungetService(ServiceReference reference)
+ {
+ return bundleState.ungetService(reference);
+ }
+
@Override
public String toString()
{
return bundleState.toString();
}
-
- public boolean ungetService(ServiceReference reference)
- {
- return bundleState.ungetService(reference);
- }
}
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 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -386,12 +386,12 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public AbstractBundleState install(URL url) throws BundleException
+ public AbstractBundleState installBundle(URL url) throws BundleException
{
if (url == null)
throw new BundleException("Null url");
- return install(url.toExternalForm(), null);
+ return installBundle(url.toExternalForm(), null);
}
/**
@@ -402,7 +402,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public AbstractBundleState install(String location, InputStream input) throws BundleException
+ public AbstractBundleState installBundle(String location, InputStream input) throws BundleException
{
if (location == null)
throw new BundleException("Null location");
@@ -456,7 +456,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public AbstractBundleState install(VirtualFile root) throws BundleException
+ public AbstractBundleState installBundle(VirtualFile root) throws BundleException
{
return install(root, null);
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -29,6 +29,8 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.launch.Framework;
@@ -120,6 +122,14 @@
}
/**
+ * Install a bundle from a virtual file
+ */
+ public Bundle installBundle(VirtualFile root) throws BundleException
+ {
+ return bundleManager.installBundle(root).getBundleInternal();
+ }
+
+ /**
* The Framework cannot be uninstalled.
* <p>
* This method always throws a BundleException.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -78,7 +78,7 @@
for (URL bundleURL : autoInstall)
{
- Bundle bundle = bundleManager.install(bundleURL);
+ Bundle bundle = bundleManager.installBundle(bundleURL);
autoBundles.put(bundleURL, bundle);
}
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -44,7 +44,7 @@
import org.osgi.framework.Bundle;
/**
- * The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
+ * A Resolver that is based on the Drools rule engine.
*
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl 2009-11-11 07:10:01 UTC (rev 96251)
@@ -1,7 +1,6 @@
package org.jboss.osgi.framework.resolver
declare WireCandidate
- name : String
importPackage : ImportPackage
exportPackage : ExportPackage
end
@@ -28,7 +27,6 @@
$import : ImportPackage( name == $export.name, exporter == null )
then
WireCandidate wc = new WireCandidate();
- wc.setName( $import.getName() + "-" + $export.getVersion());
wc.setImportPackage( $import );
wc.setExportPackage( $export );
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -158,7 +158,7 @@
if (resourceRoot == null)
throw new AssertionFailedError("Resource not found: " + root);
URL childResource = new URL(resourceRoot, child);
- AbstractBundleState bundleState = getBundleManager().install(childResource);
+ AbstractBundleState bundleState = getBundleManager().installBundle(childResource);
return bundleState.getBundleInternal();
}
@@ -171,7 +171,7 @@
*/
public Bundle addBundle(VirtualFile file) throws Exception
{
- AbstractBundleState bundleState = getBundleManager().install(file);
+ AbstractBundleState bundleState = getBundleManager().installBundle(file);
return bundleState.getBundleInternal();
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -23,9 +23,17 @@
// $Id$
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.launch.OSGiFramework;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.Resolver;
-import org.jboss.test.osgi.FrameworkTestCase;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.virtual.VirtualFile;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.osgi.framework.BundleException;
/**
* An abstract {@link Resolver} test.
@@ -33,16 +41,41 @@
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
*/
-abstract class AbstractResolverTest extends FrameworkTestCase
+public abstract class AbstractResolverTest
{
- public AbstractResolverTest(String name)
+ protected static OSGiFramework framework;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
{
- super(name);
+ OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+ framework = (OSGiFramework)bootProvider.getFramework();
+ framework.start();
}
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (framework != null)
+ {
+ framework.stop();
+ framework = null;
+ }
+ }
+
protected Resolver getResolver()
{
- Resolver resolver = getBundleManager().getPlugin(ResolverPlugin.class);
- return resolver;
+ OSGiBundleManager bundleManager = framework.getBundleManager();
+ return bundleManager.getPlugin(ResolverPlugin.class);
}
+
+ public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
+ {
+ return new OSGiTestHelper().assembleBundle(name, resource, packages);
+ }
+
+ public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
+ {
+ return new OSGiTestHelper().assembleBundle(name, resources, packages);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -23,6 +23,12 @@
// $Id$
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
import org.jboss.osgi.framework.resolver.ExportPackage;
@@ -30,6 +36,7 @@
import org.jboss.osgi.framework.resolver.Resolvable;
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.test.osgi.classloader.support.a.A;
+import org.jboss.virtual.VirtualFile;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
@@ -42,54 +49,56 @@
*/
public class ResolverMetadataTest extends AbstractResolverTest
{
- public ResolverMetadataTest(String name)
- {
- super(name);
- }
-
@Test
public void testSimpleExport() throws Exception
{
// Bundle-SymbolicName: resolver-simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA", "/bundles/resolver/simpleexport", A.class);
-
- Resolver resolver = getResolver();
- assertEquals(1, resolver.getBundles().size());
-
- Resolvable resolvableA = resolver.getBundle(bundleA.getSymbolicName(), null);
- assertNotNull("Resolvable not null", resolvableA);
-
- resolvableA = resolver.getBundle(bundleA.getSymbolicName(), bundleA.getVersion());
- assertNotNull("Resolvable not null", resolvableA);
-
- resolvableA = resolver.getBundle(bundleA);
- assertNotNull("Resolvable not null", resolvableA);
-
- assertNotNull(resolvableA.getBundle());
- assertEquals("resolver-simpleexport", resolvableA.getSymbolicName());
- assertEquals(Version.emptyVersion, resolvableA.getVersion());
-
- List<ExportPackage> exportPackages = resolvableA.getExportPackages();
- assertNotNull("ExportPackages not null", exportPackages);
- assertEquals(1, exportPackages.size());
-
- ExportPackage exportPackage = resolvableA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- assertNotNull("ExportPackage not null", exportPackage);
- assertEquals("org.jboss.test.osgi.classloader.support.a", exportPackage.getName());
+ VirtualFile fileA = assembleBundle("bundleA", "/bundles/resolver/simpleexport", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Resolver resolver = getResolver();
+ assertEquals(1, resolver.getBundles().size());
+
+ Resolvable resolvableA = resolver.getBundle(bundleA.getSymbolicName(), null);
+ assertNotNull("Resolvable not null", resolvableA);
+
+ resolvableA = resolver.getBundle(bundleA.getSymbolicName(), bundleA.getVersion());
+ assertNotNull("Resolvable not null", resolvableA);
+
+ resolvableA = resolver.getBundle(bundleA);
+ assertNotNull("Resolvable not null", resolvableA);
+
+ assertNotNull(resolvableA.getBundle());
+ assertEquals("resolver-simpleexport", resolvableA.getSymbolicName());
+ assertEquals(Version.emptyVersion, resolvableA.getVersion());
+
+ List<ExportPackage> exportPackages = resolvableA.getExportPackages();
+ assertNotNull("ExportPackages not null", exportPackages);
+ assertEquals(1, exportPackages.size());
+
+ ExportPackage exportPackage = resolvableA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertNotNull("ExportPackage not null", exportPackage);
+ assertEquals("org.jboss.test.osgi.classloader.support.a", exportPackage.getName());
- assertEquals(Version.emptyVersion, exportPackage.getVersion());
- assertEquals(0, exportPackage.getUses().size());
- assertEquals(0, exportPackage.getMandatoryAttributes().size());
- assertNull("Null includes", exportPackage.getIncludes());
- assertNull("Null excludes", exportPackage.getExcludes());
-
- List<ImportPackage> importPackages = resolvableA.getImportPackages();
- assertNotNull("ImportPackages not null", importPackages);
- assertEquals(0, importPackages.size());
-
- assertFalse("No sigleton", resolvableA.isSingleton());
- assertFalse("Not resolved", resolvableA.isResolved());
+ assertEquals(Version.emptyVersion, exportPackage.getVersion());
+ assertEquals(0, exportPackage.getUses().size());
+ assertEquals(0, exportPackage.getMandatoryAttributes().size());
+ assertNull("Null includes", exportPackage.getIncludes());
+ assertNull("Null excludes", exportPackage.getExcludes());
+
+ List<ImportPackage> importPackages = resolvableA.getImportPackages();
+ assertNotNull("ImportPackages not null", importPackages);
+ assertEquals(0, importPackages.size());
+
+ assertFalse("No sigleton", resolvableA.isSingleton());
+ assertFalse("Not resolved", resolvableA.isResolved());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
}
@Test
@@ -97,21 +106,28 @@
{
// Bundle-SymbolicName: resolver-simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA", "/bundles/resolver/simpleimport");
-
- Resolvable resolvableA = getResolver().getBundle(bundleA);
-
- List<ImportPackage> importPackages = resolvableA.getImportPackages();
- assertNotNull("ImportPackages not null", importPackages);
- assertEquals(1, importPackages.size());
+ VirtualFile fileA = assembleBundle("bundleA", "/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Resolvable resolvableA = getResolver().getBundle(bundleA);
+
+ List<ImportPackage> importPackages = resolvableA.getImportPackages();
+ assertNotNull("ImportPackages not null", importPackages);
+ assertEquals(1, importPackages.size());
- ImportPackage importPackage = resolvableA.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- assertNotNull("ImportPackage not null", importPackage);
- assertEquals("org.jboss.test.osgi.classloader.support.a", importPackage.getName());
+ ImportPackage importPackage = resolvableA.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertNotNull("ImportPackage not null", importPackage);
+ assertEquals("org.jboss.test.osgi.classloader.support.a", importPackage.getName());
- assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
- assertNull("Null bundle-symbolic-name", importPackage.getBundleSymbolicName());
- assertEquals("[0.0.0,?)", importPackage.getBundleVersion().toString());
+ assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
+ assertNull("Null bundle-symbolic-name", importPackage.getBundleSymbolicName());
+ assertEquals("[0.0.0,?)", importPackage.getBundleVersion().toString());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
}
@Test
@@ -119,9 +135,16 @@
{
// Bundle-SymbolicName: resolver-singleton;singleton:=true
// Export-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA", "/bundles/resolver/singleton", A.class);
-
- Resolvable resolvableA = getResolver().getBundle(bundleA);
- assertTrue("Sigleton", resolvableA.isSingleton());
+ VirtualFile fileA = assembleBundle("bundleA", "/bundles/resolver/singleton", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Resolvable resolvableA = getResolver().getBundle(bundleA);
+ assertTrue("Sigleton", resolvableA.isSingleton());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java 2009-11-11 07:05:34 UTC (rev 96250)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java 2009-11-11 07:10:01 UTC (rev 96251)
@@ -23,6 +23,8 @@
// $Id$
+import static org.junit.Assert.*;
+
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.ExportPackage;
@@ -31,6 +33,9 @@
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.framework.resolver.internal.drools.RuleBasedResolverImpl;
import org.jboss.test.osgi.classloader.support.a.A;
+import org.jboss.virtual.VirtualFile;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
/**
@@ -41,17 +46,10 @@
*/
public class RuleBasedResolverTest extends AbstractResolverTest
{
- public RuleBasedResolverTest(String name)
+ @Before
+ public void setUp() throws Exception
{
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- OSGiBundleManager bundleManager = getBundleManager();
+ OSGiBundleManager bundleManager = framework.getBundleManager();
ResolverPlugin resolver = bundleManager.getPlugin(ResolverPlugin.class);
if ((resolver instanceof RuleBasedResolverImpl) == false)
{
@@ -60,25 +58,31 @@
}
}
+ @Test
public void testSimpleImport() throws Exception
{
// Bundle-SymbolicName: resolver-simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA", "/bundles/resolver/simpleimport");
-
+ VirtualFile fileA = assembleBundle("bundleA", "/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+
// Bundle-SymbolicName: resolver-simpleexport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleB = assembleBundle("bundleB", "/bundles/resolver/simpleexport", A.class);
-
+ VirtualFile fileB = assembleBundle("bundleB", "/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+
Resolver resolver = getResolver();
Resolvable resolvableA = resolver.getBundle(bundleA);
assertTrue("BundleA resolved", resolvableA.isResolved());
ImportPackage importPackage = resolvableA.getImportPackage(A.class.getPackage().getName());
assertNotNull("Exporter not null", importPackage.getExporter());
-
+
Resolvable resolvableB = resolver.getBundle(bundleB);
assertTrue("BundleB resolved", resolvableB.isResolved());
ExportPackage exportPackage = resolvableB.getExportPackage(A.class.getPackage().getName());
assertEquals("Importers not null", 1, exportPackage.getImporters().size());
+
+ bundleB.uninstall();
+ bundleA.uninstall();
}
}
\ No newline at end of file
14 years, 8 months
JBoss-OSGI SVN: r96250 - projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-11 02:05:34 -0500 (Wed, 11 Nov 2009)
New Revision: 96250
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
Log:
Add VFS bundle creation
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2009-11-11 07:03:43 UTC (rev 96249)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2009-11-11 07:05:34 UTC (rev 96250)
@@ -28,6 +28,7 @@
import javax.naming.NamingException;
import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
@@ -178,14 +179,6 @@
}
/**
- * Delegates to {@link OSGiTestHelper#getJndiPort()}
- */
- public Integer getJndiPort()
- {
- return getTestHelper().getJndiPort();
- }
-
- /**
* Delegates to {@link OSGiTestHelper#getServerHost()}
*/
public String getServerHost()
@@ -208,28 +201,14 @@
{
return getTestHelper().getFramework();
}
-
- /**
- * Delegates to {@link OSGiTestHelper#isFrameworkEquinox()}
- */
- public boolean isFrameworkEquinox()
+
+ public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
{
- return getTestHelper().isFrameworkEquinox();
+ return getTestHelper().assembleBundle(name, resource, packages);
}
-
- /**
- * Delegates to {@link OSGiTestHelper#isFrameworkFelix()}
- */
- public boolean isFrameworkFelix()
+
+ public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
{
- return getTestHelper().isFrameworkFelix();
+ return getTestHelper().assembleBundle(name, resources, packages);
}
-
- /**
- * Delegates to {@link OSGiTestHelper#isFrameworkJBossMC()}
- */
- public boolean isFrameworkJBossMC()
- {
- return getTestHelper().isFrameworkJBossMC();
- }
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-11-11 07:03:43 UTC (rev 96249)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-11-11 07:05:34 UTC (rev 96250)
@@ -29,10 +29,15 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import junit.framework.AssertionFailedError;
+
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.testing.internal.EmbeddedRuntime;
import org.jboss.osgi.testing.internal.RemoteRuntime;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
/**
* An OSGi Test Helper
@@ -172,49 +177,73 @@
@SuppressWarnings("unchecked")
public InitialContext getInitialContext() throws NamingException
{
+ String port = System.getProperty("jndi.server.port", "1099");
+ Integer jndiPort = new Integer(port);
+
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
- env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + getJndiPort());
+ env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + jndiPort);
return new InitialContext(env);
}
- public Integer getJndiPort()
- {
- String port = System.getProperty("jndi.server.port", "1099");
- return new Integer(port);
- }
-
public String getServerHost()
{
String bindAddress = System.getProperty("jboss.bind.address", "localhost");
return bindAddress;
}
-
+
public String getTargetContainer()
{
String targetContainer = System.getProperty("target.container");
return targetContainer;
}
-
+
public String getFramework()
{
String framework = System.getProperty("framework", "jbossmc");
return framework;
}
-
- public boolean isFrameworkEquinox()
+
+ public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
{
- return "equinox".equals(getFramework());
+ return assembleBundle(name, new String[] { resource }, packages);
}
-
- public boolean isFrameworkFelix()
+
+ public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
{
- return "felix".equals(getFramework());
+ AssembledDirectory assembledDirectory = AssembledDirectory.createAssembledDirectory(name, "");
+ for (String path : resources)
+ addPath(assembledDirectory, path, "");
+ for (Class<?> reference : packages)
+ addPackage(assembledDirectory, reference);
+ return assembledDirectory;
}
-
- public boolean isFrameworkJBossMC()
+
+ private void addPath(AssembledDirectory dir, String path, String name) throws Exception
{
- return "jbossmc".equals(getFramework());
+ URL url = getClass().getResource(path);
+ if (url == null)
+ throw new AssertionFailedError(path + " not found");
+
+ VirtualFile file = VFS.getVirtualFile(url, name);
+ dir.addPath(file);
}
+
+ private void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ {
+ String packagePath = packageNameToPath(reference.getName());
+ dir.addResources(reference, new String[] { packagePath + "/*.class" }, new String[0]);
+ }
+
+ // Convert a class's package name into a path
+ private String packageNameToPath(final String className)
+ {
+ int end = className.lastIndexOf('.');
+ if (end == -1)
+ return "";
+
+ String packageName = className.substring(0, end);
+ return packageName.replace('.', '/');
+ }
}
14 years, 8 months
JBoss-OSGI SVN: r96238 - in projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2: blueprint/impl and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-10 17:42:17 -0500 (Tue, 10 Nov 2009)
New Revision: 96238
Modified:
projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/blueprint/impl/pom.xml
projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/pom.xml
Log:
Post release 1.0.0.Beta2 build fix
Modified: projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/blueprint/impl/pom.xml 2009-11-10 22:39:42 UTC (rev 96237)
+++ projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/blueprint/impl/pom.xml 2009-11-10 22:42:17 UTC (rev 96238)
@@ -64,6 +64,7 @@
org.osgi.service.blueprint.*
</Export-Package>
<Import-Package>
+ javax.xml.namespace,
org.apache.xerces.dom,
org.jboss.osgi.common.log;version=1.0,
org.jboss.osgi.spi;version=1.0,
Modified: projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/pom.xml
===================================================================
--- projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/pom.xml 2009-11-10 22:39:42 UTC (rev 96237)
+++ projects/jboss-osgi/tags/jboss-osgi-1.0.0.Beta2/pom.xml 2009-11-10 22:42:17 UTC (rev 96238)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.0</version>
+ <version>1.0.0.SP1</version>
</parent>
<!-- Modules -->
14 years, 8 months