JBoss-OSGI SVN: r96237 - in projects/jboss-osgi/projects/parent: tags and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-10 17:39:42 -0500 (Tue, 10 Nov 2009)
New Revision: 96237
Added:
projects/jboss-osgi/projects/parent/tags/jboss-osgi-parent-1.0.0.SP1/
Removed:
projects/jboss-osgi/projects/parent/branches/1.0.0.SP1/
Log:
Post release 1.0.0.Beta2 build fix
Copied: projects/jboss-osgi/projects/parent/tags/jboss-osgi-parent-1.0.0.SP1 (from rev 96236, projects/jboss-osgi/projects/parent/branches/1.0.0.SP1)
14 years, 6 months
JBoss-OSGI SVN: r96236 - in projects/jboss-osgi/projects/parent: branches and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-10 17:37:35 -0500 (Tue, 10 Nov 2009)
New Revision: 96236
Added:
projects/jboss-osgi/projects/parent/branches/
projects/jboss-osgi/projects/parent/branches/1.0.0.SP1/
Modified:
projects/jboss-osgi/projects/parent/branches/1.0.0.SP1/pom.xml
Log:
Post release 1.0.0.Beta2 build fix
Copied: projects/jboss-osgi/projects/parent/branches/1.0.0.SP1 (from rev 93966, projects/jboss-osgi/projects/parent/tags/jboss-osgi-parent-1.0.0)
Modified: projects/jboss-osgi/projects/parent/branches/1.0.0.SP1/pom.xml
===================================================================
--- projects/jboss-osgi/projects/parent/tags/jboss-osgi-parent-1.0.0/pom.xml 2009-09-23 20:43:57 UTC (rev 93966)
+++ projects/jboss-osgi/projects/parent/branches/1.0.0.SP1/pom.xml 2009-11-10 22:37:35 UTC (rev 96236)
@@ -7,7 +7,7 @@
<artifactId>jboss-osgi-parent</artifactId>
<packaging>pom</packaging>
- <version>1.0.0</version>
+ <version>1.0.0.SP1</version>
<url>http://www.jboss.org/community/wiki/JBossOSGi</url>
<description>JBossOSGi</description>
@@ -20,7 +20,7 @@
<!-- Properties -->
<properties>
- <version.aqute.bnd>0.0.323</version.aqute.bnd>
+ <version.aqute.bnd>0.0.356</version.aqute.bnd>
</properties>
<build>
14 years, 6 months
JBoss-OSGI SVN: r96232 - 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-10 15:52:56 -0500 (Tue, 10 Nov 2009)
New Revision: 96232
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
Log:
Fix relative path #2.
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-10 20:15:52 UTC (rev 96231)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-10 20:52:56 UTC (rev 96232)
@@ -62,7 +62,7 @@
public URI toURI() throws URISyntaxException
{
- return new URI("bundle", Long.toString(bundleState.getBundleId()), handler.getLocalPathName(), null);
+ return new URI("bundle", Long.toString(bundleState.getBundleId()), getRelativePath(false), null);
}
public long getLastModified() throws IOException
14 years, 6 months
JBoss-OSGI SVN: r96231 - 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-10 15:15:52 -0500 (Tue, 10 Nov 2009)
New Revision: 96231
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java
Log:
Fix relative path.
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-10 19:32:57 UTC (rev 96230)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-10 20:15:52 UTC (rev 96231)
@@ -52,6 +52,14 @@
this.bundleState = bundleState;
}
+ protected String getRelativePath(boolean checkEnd)
+ {
+ String path = handler.getLocalPathName();
+ if (checkEnd && path.endsWith("/") == false)
+ path += "/";
+ return path;
+ }
+
public URI toURI() throws URISyntaxException
{
return new URI("bundle", Long.toString(bundleState.getBundleId()), handler.getLocalPathName(), null);
@@ -64,14 +72,14 @@
public InputStream openStream() throws IOException
{
- bundleState.getResource(""); // permission check
+ bundleState.getResource(getRelativePath(false)); // permission check
return handler.openStream();
}
public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
{
- bundleState.findEntries("", null, false); // permission check
+ bundleState.findEntries(getRelativePath(false), null, false); // permission check
List<VirtualFileHandler> children = handler.getChildren(ignoreErrors);
if (children != null && children.isEmpty() == false)
@@ -88,7 +96,8 @@
public VirtualFileHandler getChild(String path) throws IOException
{
- URL entry = bundleState.getEntry(path); // permission check
+ String fullPath = getRelativePath(true) + path;
+ URL entry = bundleState.getEntry(fullPath); // permission check
if (entry == null)
return null;
14 years, 6 months
JBoss-OSGI SVN: r96230 - in projects/jboss-osgi/trunk/reactor/framework: src/main/java/org/jboss/osgi/framework/bundle and 18 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-10 14:32:57 -0500 (Tue, 10 Nov 2009)
New Revision: 96230
Added:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/
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/classloader/support/c/
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.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/RuleBasedResolverTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexport/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexport/META-INF/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexport/META-INF/MANIFEST.MF
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleimport/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleimport/META-INF/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleimport/META-INF/MANIFEST.MF
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/singleton/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/singleton/META-INF/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/singleton/META-INF/MANIFEST.MF
Modified:
projects/jboss-osgi/trunk/reactor/framework/pom.xml
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/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/Resolvable.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.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/resolver/ResolverMetadataTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
Add initial rule based resolver
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-10 19:32:57 UTC (rev 96230)
@@ -36,12 +36,14 @@
<!-- Properties -->
<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>
<version.jboss.test>1.1.4.GA</version.jboss.test>
+ <surefire.system.args>${surefire.memory.args} ${surefire.jpda.args} ${surefire.profiler.args}</surefire.system.args>
</properties>
<dependencies>
@@ -50,6 +52,11 @@
<artifactId>bnd</artifactId>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ <version>${version.drools}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.aop</groupId>
<artifactId>jboss-aop</artifactId>
<version>${version.jboss.aop}</version>
@@ -410,6 +417,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <argLine>${surefire.system.args}</argLine>
<systemProperties>
<property>
<name>log4j.output.dir</name>
@@ -429,23 +437,4 @@
</plugins>
</build>
- <!-- Repositories -->
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/trunk/...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/trunk/rea...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi/projects/jboss-osgi/trunk/reac...</url>
- </scm>
-
</project>
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-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -325,15 +325,28 @@
*/
public void addPlugin(Plugin plugin)
{
- Class<? extends Plugin> clazz = plugin.getClass();
+ Class<?> clazz = plugin.getClass();
+ if (addPlugin(plugin, clazz) == false)
+ {
+ Class<?> superclass = clazz.getSuperclass();
+ if (Plugin.class.isAssignableFrom(superclass))
+ addPlugin(plugin, superclass);
+ }
+ }
+
+ private boolean addPlugin(Plugin plugin, Class<?> clazz)
+ {
+ boolean pluginAdded = false;
for (Class<?> interf : clazz.getInterfaces())
{
if (Plugin.class.isAssignableFrom(interf))
{
- log.debug("Add plugin: " + clazz.getName());
+ log.debug("Add plugin: " + plugin.getClass().getName());
plugins.put(interf, plugin);
+ pluginAdded = true;
}
}
+ return pluginAdded;
}
/**
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.framework.resolver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.plugins.ResolverPlugin;
+import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
+import org.jboss.osgi.framework.resolver.internal.ResolvableImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * An abstract resolver that maintains the {@link Resolvable} bundles.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Nov-2009
+ */
+public abstract class AbstractResolver extends AbstractPlugin implements ResolverPlugin
+{
+ private Map<OSGiBundleState, Resolvable> resolverBundleMap = new ConcurrentHashMap<OSGiBundleState, Resolvable>();
+
+ public AbstractResolver(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+ }
+
+ public List<Resolvable> getBundles()
+ {
+ List<Resolvable> values = new ArrayList<Resolvable>(resolverBundleMap.values());
+ return Collections.unmodifiableList(values);
+ }
+
+ public Resolvable getBundle(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Null bundle");
+
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ return resolverBundleMap.get(bundleState);
+ }
+
+ public Resolvable getBundle(String symbolicName, Version version)
+ {
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Null symbolicName");
+
+ if (version == null)
+ version = Version.emptyVersion;
+
+ Resolvable retBundle = null;
+ for (Resolvable aux : resolverBundleMap.values())
+ {
+ if (aux.getSymbolicName().equals(symbolicName) && aux.getVersion().equals(version))
+ {
+ retBundle = aux;
+ break;
+ }
+ }
+ return retBundle;
+ }
+
+ public Resolvable addBundle(Bundle bundle)
+ {
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ ResolvableImpl resolvable = new ResolvableImpl(bundle);
+ resolverBundleMap.put(bundleState, resolvable);
+ return resolvable;
+ }
+
+ public Resolvable removeBundle(Bundle bundle)
+ {
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ return resolverBundleMap.remove(bundleState);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/AbstractResolver.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -71,4 +71,14 @@
* @return An empty set if there is no importer
*/
Set<ImportPackage> getImporters();
+
+ /**
+ * Add an importer of this export package.
+ */
+ void addImporter(ImportPackage importer);
+
+ /**
+ * Remove an importer of this export package.
+ */
+ 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-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -22,7 +22,6 @@
package org.jboss.osgi.framework.resolver;
import org.jboss.osgi.framework.metadata.VersionRange;
-import org.osgi.framework.Version;
/**
* An abstraction of a package import.
@@ -61,11 +60,16 @@
* The bundle version of the exporting bundle.
* @return null if this attribute is not set
*/
- Version getBundleVersion();
+ VersionRange getBundleVersion();
/**
* Get the exporter that this import package is wired to.
* @return Null if the import is not yet resolved.
*/
ExportPackage getExporter();
+
+ /**
+ * Set the exporter that this import package is wired to.
+ */
+ 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/Resolvable.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -84,12 +84,17 @@
ImportPackage getImportPackage(String packageName);
/**
- * @return True if this resovable is a singleton bundle.
+ * Return true if this resolvable is a singleton.
*/
boolean isSingleton();
/**
- * @return True if this resovable has been resolved.
+ * Return true if this resolvable has been resolved.
*/
boolean isResolved();
+
+ /**
+ * Mark this resolvable as resolved.
+ */
+ void markResolved();
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -32,7 +33,6 @@
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.ImportPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
-import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -45,6 +45,7 @@
public class ExportPackageImpl extends NamedPackageImpl implements ExportPackage
{
private PackageAttribute packageMetaData;
+ private Set<ImportPackage> importers = new HashSet<ImportPackage>();
public ExportPackageImpl(Resolvable owner, String packageName)
{
@@ -112,6 +113,23 @@
public Set<ImportPackage> getImporters()
{
- throw new NotImplementedException();
+ return Collections.unmodifiableSet(importers);
}
+
+ public void addImporter(ImportPackage importer)
+ {
+ importers.add(importer);
+ }
+
+ public void removeImporter(ImportPackage importer)
+ {
+ importers.remove(importer);
+ }
+
+ @Override
+ public String toString()
+ {
+ String ownerStr = getOwner().getSymbolicName() + "-" + getOwner().getVersion();
+ return "ExportPackage[" + ownerStr + "[" + getName() + "-" + getVersion() + "]]";
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -24,12 +24,11 @@
import org.jboss.osgi.framework.metadata.PackageAttribute;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.VersionRange;
+import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.ImportPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
-import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
/**
* An abstraction of a package import.
@@ -40,6 +39,7 @@
public class ImportPackageImpl extends NamedPackageImpl implements ImportPackage
{
private PackageAttribute packageMetaData;
+ private ExportPackage exporter;
public ImportPackageImpl(Resolvable owner, String packageName)
{
@@ -67,7 +67,8 @@
public VersionRange getVersion()
{
- throw new NotImplementedException();
+ Parameter version = getPackageMetaData().getAttribute(Constants.VERSION_ATTRIBUTE);
+ return (VersionRange)(version != null ? version.getValue() : AbstractVersionRange.valueOf("0.0.0"));
}
public String getBundleSymbolicName()
@@ -75,9 +76,10 @@
return (String)getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
}
- public Version getBundleVersion()
+ public VersionRange getBundleVersion()
{
- return Version.parseVersion((String)getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE));
+ Parameter version = getPackageMetaData().getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
+ return (VersionRange)(version != null ? version.getValue() : AbstractVersionRange.valueOf("0.0.0"));
}
public Resolution getResolution()
@@ -88,6 +90,21 @@
public ExportPackage getExporter()
{
- throw new NotImplementedException();
+ return exporter;
}
+
+ public void setExporter(ExportPackage exporter)
+ {
+ this.exporter = exporter;
+ ExportPackageImpl exporterImpl = (ExportPackageImpl)exporter;
+ exporterImpl.addImporter(this);
+
+ }
+
+ @Override
+ public String toString()
+ {
+ String ownerStr = getOwner().getSymbolicName() + "-" + getOwner().getVersion();
+ return "ImportPackage[" + ownerStr + "[" + getName() + " " + getVersion() + "]]";
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -121,13 +121,19 @@
return resolved;
}
- public void setResolved(boolean resolved)
+ public void markResolved()
{
- this.resolved = resolved;
+ this.resolved = true;
}
public boolean isSingleton()
{
return metaData.isSingleton();
}
+
+ @Override
+ public String toString()
+ {
+ return "Resolvable[" + getSymbolicName() + "-" + getVersion() + "]";
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -41,14 +41,11 @@
import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.jboss.osgi.framework.plugins.ResolverPlugin;
-import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
+import org.jboss.osgi.framework.resolver.AbstractResolver;
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
-import org.jboss.osgi.framework.resolver.internal.ResolvableImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
/**
* The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
@@ -56,12 +53,11 @@
* @author thomas.diesler(a)jboss.com
* @since 10-Sep-2009
*/
-public class BasicResolverImpl extends AbstractPlugin implements ResolverPlugin
+public class BasicResolverImpl extends AbstractResolver
{
/** The log */
private static final Logger log = Logger.getLogger(BasicResolverImpl.class);
- private Map<OSGiBundleState, Resolvable> resolverBundleMap = new ConcurrentHashMap<OSGiBundleState, Resolvable>();
private Map<OSGiBundleState, List<BundleCapability>> bundleCapabilitiesMap = new ConcurrentHashMap<OSGiBundleState, List<BundleCapability>>();
private Map<OSGiBundleState, List<BundleRequirement>> bundleRequirementsMap = new ConcurrentHashMap<OSGiBundleState, List<BundleRequirement>>();
@@ -70,53 +66,30 @@
super(bundleManager);
}
- public List<Resolvable> getBundles()
+ public Resolvable removeBundle(Bundle bundle)
{
- List<Resolvable> values = new ArrayList<Resolvable>(resolverBundleMap.values());
- return Collections.unmodifiableList(values);
- }
-
- public Resolvable getBundle(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
+ Resolvable removedBundle = super.removeBundle(bundle);
OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
- return resolverBundleMap.get(bundleState);
- }
+ bundleCapabilitiesMap.remove(bundleState);
- public Resolvable getBundle(String symbolicName, Version version)
- {
- if (symbolicName == null)
- throw new IllegalArgumentException("Null symbolicName");
-
- if (version == null)
- version = Version.emptyVersion;
-
- Resolvable retBundle = null;
- for (Resolvable aux : resolverBundleMap.values())
+ List<BundleRequirement> bundleRequirements = bundleRequirementsMap.remove(bundleState);
+ if (bundleRequirements != null)
{
- if (aux.getSymbolicName().equals(symbolicName) && aux.getVersion().equals(version))
+ for (BundleRequirement requirement : bundleRequirements)
{
- retBundle = aux;
- break;
+ requirement.unwireCapability();
}
}
- return retBundle;
+ return removedBundle;
}
- public Resolvable addBundle(Bundle bundle)
- {
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
- return resolverBundleMap.put(bundleState, new ResolvableImpl(bundle));
- }
-
public List<Resolvable> resolve(List<Bundle> bundles)
{
List<Resolvable> resolvedBundles = new ArrayList<Resolvable>();
for (OSGiBundleState aux : resolveBundles(bundles))
{
- Resolvable resBundle = resolverBundleMap.get(aux);
+ Resolvable resBundle = getBundle(aux);
if (resBundle == null)
throw new IllegalStateException("Cannot obtain bundle for: " + aux);
resolvedBundles.add(resBundle);
@@ -201,24 +174,6 @@
return resolvedBundles;
}
- public Resolvable removeBundle(Bundle bundle)
- {
- OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
-
- bundleCapabilitiesMap.remove(bundleState);
-
- List<BundleRequirement> bundleRequirements = bundleRequirementsMap.remove(bundleState);
- if (bundleRequirements != null)
- {
- for (BundleRequirement requirement : bundleRequirements)
- {
- requirement.unwireCapability();
- }
- }
-
- return null;
- }
-
public ExportPackage getExporter(Bundle bundle, String importPackage)
{
OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
@@ -227,7 +182,7 @@
return null;
OSGiBundleState exportingBundle = match.getExportingBundle();
- Resolvable resolverBundle = resolverBundleMap.get(exportingBundle);
+ Resolvable resolverBundle = getBundle(exportingBundle);
return resolverBundle.getExportPackage(importPackage);
}
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.framework.resolver.internal.drools;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+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;
+import org.jboss.osgi.framework.resolver.ImportPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.osgi.framework.Bundle;
+
+/**
+ * The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Nov-2009
+ */
+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>();
+
+ public RuleBasedResolverImpl(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ kbuilder.add(ResourceFactory.newClassPathResource("META-INF/resolver-rules.drl", getClass()), ResourceType.DRL);
+ if (kbuilder.hasErrors())
+ throw new IllegalStateException("Cannot create knowledge base" + kbuilder.getErrors());
+
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
+ ksession = kbase.newStatefulKnowledgeSession();
+ }
+
+ @Override
+ public Resolvable addBundle(Bundle bundle)
+ {
+ Resolvable resolvable = super.addBundle(bundle);
+ facts.put(resolvable, ksession.insert(resolvable));
+
+ for (ImportPackage aux : resolvable.getImportPackages())
+ facts.put(aux, ksession.insert(aux));
+
+ for (ExportPackage aux : resolvable.getExportPackages())
+ facts.put(aux, ksession.insert(aux));
+
+ ksession.fireAllRules();
+
+ return resolvable;
+ }
+
+ @Override
+ public Resolvable removeBundle(Bundle bundle)
+ {
+ Resolvable resolvable = super.removeBundle(bundle);
+ ksession.retract(facts.get(resolvable));
+
+ for (ImportPackage aux : resolvable.getImportPackages())
+ ksession.retract(facts.get(aux));
+
+ for (ExportPackage aux : resolvable.getExportPackages())
+ ksession.retract(facts.get(aux));
+
+ ksession.fireAllRules();
+ return resolvable;
+ }
+
+ public List<Resolvable> resolve(List<Bundle> bundles)
+ {
+ List<Resolvable> resolvedBundles = new ArrayList<Resolvable>();
+ return Collections.unmodifiableList(resolvedBundles);
+ }
+
+ public ExportPackage getExporter(Bundle bundle, String importPackage)
+ {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,65 @@
+package org.jboss.osgi.framework.resolver
+
+declare WireCandidate
+ name : String
+ importPackage : ImportPackage
+ exportPackage : ExportPackage
+end
+
+rule "Add ImportPackages"
+when
+ $owner : Resolvable( importPackages.size > 0, resolved == false )
+ not ImportPackage( owner == $owner )
+then
+ System.out.println("Add ImportPackages " + $owner);
+end
+
+rule "Add ExportPackages"
+when
+ $owner : Resolvable( exportPackages.size > 0, resolved == false )
+ not ExportPackage( owner == $owner )
+then
+ System.out.println("Add ExportPackages " + $owner);
+end
+
+rule "Add WireCandidate"
+when
+ $export : ExportPackage( )
+ $import : ImportPackage( name == $export.name, exporter == null )
+then
+ WireCandidate wc = new WireCandidate();
+ wc.setName( $import.getName() + "-" + $export.getVersion());
+ wc.setImportPackage( $import );
+ wc.setExportPackage( $export );
+
+ System.out.println("Add WireCandidate " + wc.getImportPackage() + " --> " + wc.getExportPackage());
+ insert ( wc );
+end
+
+rule "Use WireCandidate"
+when
+ $import : ImportPackage( exporter == null )
+ $wc : WireCandidate( importPackage == $import )
+ not( WireCandidate( this != $wc, importPackage == $import ) )
+then
+ System.out.println("Use WireCandidate " + $wc.getImportPackage() + " --> " + $wc.getExportPackage());
+ modify ( $wc.getImportPackage() ) { setExporter( $wc.getExportPackage() ) };
+ retract ( $wc );
+end
+
+rule "Mark resolved"
+when
+ $owner : Resolvable( resolved == false )
+ not ImportPackage( owner == $owner, exporter == null )
+then
+ System.out.println("Resolved " + $owner);
+ modify ( $owner ) { markResolved ( ) };
+end
+
+rule "Report unresolved import"
+when
+ $import : ImportPackage( exporter == null )
+then
+ System.out.println("Unresolved " + $import );
+end
+
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-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -35,7 +35,6 @@
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.test.AbstractTestDelegate;
import org.jboss.test.kernel.junit.MicrocontainerTest;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VirtualFile;
@@ -73,17 +72,9 @@
super(name);
}
- /**
- * Get the AbstractTestDelegate
- *
- * @param clazz the test class
- * @return The AbstractTestDelegate
- * @throws Exception for any error
- */
- public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ public static FrameworkTestDelegate getDelegate(Class<?> clazz) throws Exception
{
FrameworkTestDelegate delegate = new FrameworkTestDelegate(clazz);
- //delegate.enableSecurity = true;
return delegate;
}
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-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -23,17 +23,18 @@
// $Id: $
+import java.lang.reflect.Method;
import java.net.URL;
+import java.util.Collection;
import java.util.Enumeration;
import junit.framework.AssertionFailedError;
import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.dependency.spi.ControllerState;
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.launch.OSGiFramework;
-import org.jboss.osgi.spi.util.ServiceLoader;
import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VFS;
@@ -42,7 +43,6 @@
import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.FrameworkFactory;
/**
* A OSGiTestDelegate
@@ -50,7 +50,7 @@
* @author <a href="baileyje(a)gmail.com">John Bailey</a>
* @author Thomas.Diesler(a)jboss.com
*/
-class FrameworkTestDelegate extends MicrocontainerTestDelegate
+public class FrameworkTestDelegate extends MicrocontainerTestDelegate
{
private OSGiBundleManager bundleManager;
@@ -62,21 +62,84 @@
super(clazz);
}
- OSGiBundleManager getBundleManager()
+ /**
+ * Deploys the jboss-osgi-bootstrap.xml bean descriptor to setup OSGi deployers
+ */
+ protected void deploy() throws Exception
{
+ String common = "/META-INF/jboss-osgi-bootstrap.xml";
+ URL url = getClass().getResource(common);
+ if (url == null)
+ throw new IllegalStateException(common + " not found");
+ deploy(url);
+ try
+ {
+ super.deploy();
+ deployBundles();
+ }
+ catch (Throwable t)
+ {
+ undeploy();
+ if (t instanceof Exception)
+ throw (Exception) t;
+ if (t instanceof Error)
+ throw (Error) t;
+ throw new RuntimeException("Error during deploy", t);
+ }
+ }
+
+ protected void undeploy()
+ {
+ undeployBundles();
+ super.undeploy();
+ }
+
+ protected void deployBundles() throws Exception
+ {
+ try
+ {
+ Method method = clazz.getMethod("deployBundles", new Class[] { FrameworkTestDelegate.class });
+ log.debug("Deploying Bundles...");
+ method.invoke(null, this);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.debug("No deployBundles() in " + clazz.getName());
+ }
+ }
+
+ protected void undeployBundles()
+ {
+ OSGiBundleManager bundleManager = getBundleManager();
+ Collection<AbstractBundleState> bundles = bundleManager.getBundles();
+ for (AbstractBundleState bundleState : bundles)
+ {
+ try
+ {
+ if (bundleState.getBundleId() != 0)
+ bundleManager.uninstall(bundleState);
+ }
+ catch (Throwable t)
+ {
+ getLog().warn("Error undeploying bundle: " + bundleState, t);
+ }
+ }
+ }
+
+ public OSGiBundleManager getBundleManager()
+ {
if (bundleManager == null)
{
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- OSGiFramework framework = (OSGiFramework)factory.newFramework(null);
+ bundleManager = getBean("OSGiBundleManager", ControllerState.INSTALLED, OSGiBundleManager.class);
try
{
- framework.start();
+ if (bundleManager.isActive() == false)
+ bundleManager.startFramework();
}
catch (BundleException ex)
{
- throw new IllegalStateException("Cannot start framework", ex);
+ throw new IllegalStateException("Cannot start bundle manager", ex);
}
- bundleManager = framework.getBundleManager();
}
return bundleManager;
}
@@ -89,7 +152,7 @@
* @return Bundle for the deployment
* @throws Exception for any error
*/
- Bundle addBundle(String root, String child) throws Exception
+ public Bundle addBundle(String root, String child) throws Exception
{
URL resourceRoot = getClass().getResource(root);
if (resourceRoot == null)
@@ -106,7 +169,7 @@
* @return Bundle for the deployment
* @throws Exception for any error
*/
- Bundle addBundle(VirtualFile file) throws Exception
+ public Bundle addBundle(VirtualFile file) throws Exception
{
AbstractBundleState bundleState = getBundleManager().install(file);
return bundleState.getBundleInternal();
@@ -118,13 +181,13 @@
* @param bundle the bundle to remove
* @throws Exception for any error
*/
- void uninstall(Bundle bundle) throws Exception
+ public void uninstall(Bundle bundle) throws Exception
{
if (bundle.getState() != Bundle.UNINSTALLED)
getBundleManager().uninstall(bundle);
}
- DeploymentUnit getDeploymentUnit(Bundle bundle)
+ public DeploymentUnit getDeploymentUnit(Bundle bundle)
{
DeploymentUnit deploymentUnit = getBundleManager().getDeployment(bundle.getBundleId());
if (deploymentUnit == null)
@@ -132,12 +195,12 @@
return deploymentUnit;
}
- Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+ public Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
{
return assembleBundle(name, new String[] { resources }, packages);
}
- Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+ public Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
{
AssembledDirectory assembledDirectory = createAssembledDirectory(name, "");
for (String path : resourcePaths)
@@ -147,23 +210,23 @@
return addBundle(assembledDirectory);
}
- AssembledDirectory createAssembledDirectory(String name) throws Exception
+ public AssembledDirectory createAssembledDirectory(String name) throws Exception
{
return createAssembledDirectory(name, "");
}
- AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
+ public AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
{
return AssembledDirectory.createAssembledDirectory(name, rootName);
}
- void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ public void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
{
String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
dir.addResources(reference, new String[] { packagePath + "/*.class" } , new String[0]);
}
- void addPath(final AssembledDirectory dir, String path, String name) throws Exception
+ public void addPath(final AssembledDirectory dir, String path, String name) throws Exception
{
URL url = getClass().getResource(path);
if (url == null)
@@ -175,12 +238,12 @@
dir.addPath(file, noJars);
}
- URL getBundleResource(Bundle bundle, String path)
+ public URL getBundleResource(Bundle bundle, String path)
{
return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
}
- Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
+ public Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
{
return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
}
Added: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.test.osgi.classloader.support.c;
+
+import org.jboss.test.osgi.classloader.support.a.A;
+
+/**
+ * CA.
+ *
+ * @authorThomas.Diesler(a)jboss.com
+ * @version $Revision$
+ */
+public class CA
+{
+ public CA(A a)
+ {
+ }
+}
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.resolver;
+
+// $Id$
+
+import org.jboss.osgi.framework.plugins.ResolverPlugin;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.test.osgi.FrameworkTestCase;
+
+/**
+ * An abstract {@link Resolver} test.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Nov-2009
+ */
+abstract class AbstractResolverTest extends FrameworkTestCase
+{
+ public AbstractResolverTest(String name)
+ {
+ super(name);
+ }
+
+ protected Resolver getResolver()
+ {
+ Resolver resolver = getBundleManager().getPlugin(ResolverPlugin.class);
+ return resolver;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -25,12 +25,10 @@
import java.util.List;
-import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.ImportPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
import org.jboss.osgi.framework.resolver.Resolver;
-import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -40,9 +38,9 @@
* Test {@link Resolver} metadata.
*
* @author thomas.diesler(a)jboss.com
- * @since 27-Jul-2009
+ * @since 09-Nov-2009
*/
-public class ResolverMetadataTest extends FrameworkTestCase
+public class ResolverMetadataTest extends AbstractResolverTest
{
public ResolverMetadataTest(String name)
{
@@ -50,19 +48,17 @@
}
@Test
- public void testBasicExport() throws Exception
+ public void testSimpleExport() throws Exception
{
- //Bundle-Name: BundleA
- //Bundle-Version: 1.0.0
- //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
- Bundle bundleA = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+ // Bundle-SymbolicName: resolver-simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ Bundle bundleA = assembleBundle("bundleA", "/bundles/resolver/simpleexport", A.class);
- Resolver resolver = getBundleManager().getPlugin(ResolverPlugin.class);
+ Resolver resolver = getResolver();
assertEquals(1, resolver.getBundles().size());
Resolvable resolvableA = resolver.getBundle(bundleA.getSymbolicName(), null);
- assertNull("Resolvable null", resolvableA);
+ assertNotNull("Resolvable not null", resolvableA);
resolvableA = resolver.getBundle(bundleA.getSymbolicName(), bundleA.getVersion());
assertNotNull("Resolvable not null", resolvableA);
@@ -71,8 +67,8 @@
assertNotNull("Resolvable not null", resolvableA);
assertNotNull(resolvableA.getBundle());
- assertEquals(bundleA.getSymbolicName(), resolvableA.getSymbolicName());
- assertEquals(bundleA.getVersion(), resolvableA.getVersion());
+ assertEquals("resolver-simpleexport", resolvableA.getSymbolicName());
+ assertEquals(Version.emptyVersion, resolvableA.getVersion());
List<ExportPackage> exportPackages = resolvableA.getExportPackages();
assertNotNull("ExportPackages not null", exportPackages);
@@ -82,10 +78,9 @@
assertNotNull("ExportPackage not null", exportPackage);
assertEquals("org.jboss.test.osgi.classloader.support.a", exportPackage.getName());
- assertEquals(Version.parseVersion("1.0.0"), exportPackage.getVersion());
+ assertEquals(Version.emptyVersion, exportPackage.getVersion());
assertEquals(0, exportPackage.getUses().size());
assertEquals(0, exportPackage.getMandatoryAttributes().size());
- assertEquals("x", exportPackage.getAttribute("test"));
assertNull("Null includes", exportPackage.getIncludes());
assertNull("Null excludes", exportPackage.getExcludes());
@@ -96,4 +91,37 @@
assertFalse("No sigleton", resolvableA.isSingleton());
assertFalse("Not resolved", resolvableA.isResolved());
}
+
+ @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");
+
+ 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());
+
+ assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
+ assertNull("Null bundle-symbolic-name", importPackage.getBundleSymbolicName());
+ assertEquals("[0.0.0,?)", importPackage.getBundleVersion().toString());
+ }
+
+ @Test
+ public void testSingleton() throws Exception
+ {
+ // 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());
+ }
}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.resolver;
+
+// $Id$
+
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.plugins.ResolverPlugin;
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.ImportPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+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.osgi.framework.Bundle;
+
+/**
+ * Test the rule based {@link Resolver}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-Jul-2009
+ */
+public class RuleBasedResolverTest extends AbstractResolverTest
+{
+ public RuleBasedResolverTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ OSGiBundleManager bundleManager = getBundleManager();
+ ResolverPlugin resolver = bundleManager.getPlugin(ResolverPlugin.class);
+ if ((resolver instanceof RuleBasedResolverImpl) == false)
+ {
+ bundleManager.removePlugin(resolver);
+ bundleManager.addPlugin(new RuleBasedResolverImpl(bundleManager));
+ }
+ }
+
+ 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");
+
+ // Bundle-SymbolicName: resolver-simpleexport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ Bundle bundleB = assembleBundle("bundleB", "/bundles/resolver/simpleexport", A.class);
+
+ 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());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-11-10 19:00:18 UTC (rev 96229)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-11-10 19:32:57 UTC (rev 96230)
@@ -46,6 +46,9 @@
********************************
-->
+ <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>
@@ -55,9 +58,6 @@
<bean name="OSGiSystemPackages" class="org.jboss.osgi.framework.plugins.internal.SystemPackagesPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="OSGiBundleResolver" class="org.jboss.osgi.framework.resolver.internal.basic.BasicResolverImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- </bean>
<!--
********************************
Added: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexport/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexport/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexport/META-INF/MANIFEST.MF 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolver-simpleexport
+Export-Package: org.jboss.test.osgi.classloader.support.a
Added: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleimport/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleimport/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleimport/META-INF/MANIFEST.MF 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolver-simpleimport
+Import-Package: org.jboss.test.osgi.classloader.support.a
Added: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/singleton/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/singleton/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/singleton/META-INF/MANIFEST.MF 2009-11-10 19:32:57 UTC (rev 96230)
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolver-sigleton;singleton:=true
+Export-Package: org.jboss.test.osgi.classloader.support.a
14 years, 6 months
JBoss-OSGI SVN: r96225 - 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-10 11:55:53 -0500 (Tue, 10 Nov 2009)
New Revision: 96225
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java
Log:
Be consistent to const.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java 2009-11-10 16:54:15 UTC (rev 96224)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java 2009-11-10 16:55:53 UTC (rev 96225)
@@ -43,7 +43,7 @@
init();
}
- private static final String HANDLER_PCKGS = "java.protocol.handler.pkgs";
+ private static final String HANDLER_PKGS = "java.protocol.handler.pkgs";
private OSGiBundleManager manager;
public BundleVFSContextFactory(OSGiBundleManager manager)
@@ -56,18 +56,18 @@
public static void init()
{
- String pckg = BundleVFSContextFactory.class.getPackage().getName();
- String pckgs = System.getProperty(HANDLER_PCKGS);
+ String pkg = BundleVFSContextFactory.class.getPackage().getName();
+ String pkgs = System.getProperty(HANDLER_PKGS);
- if (pckgs == null || pckgs.trim().length() == 0)
+ if (pkgs == null || pkgs.trim().length() == 0)
{
- pckgs = pckg;
- System.setProperty(HANDLER_PCKGS, pckgs);
+ pkgs = pkg;
+ System.setProperty(HANDLER_PKGS, pkgs);
}
- else if (pckgs.contains(pckg) == false)
+ else if (pkgs.contains(pkg) == false)
{
- pckgs += ("|" + pckg);
- System.setProperty(HANDLER_PCKGS, pckgs);
+ pkgs += ("|" + pkg);
+ System.setProperty(HANDLER_PKGS, pkgs);
}
}
14 years, 6 months
JBoss-OSGI SVN: r96224 - 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-10 11:54:15 -0500 (Tue, 10 Nov 2009)
New Revision: 96224
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java
Log:
Fix pckg + url handler.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java 2009-11-10 16:49:19 UTC (rev 96223)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java 2009-11-10 16:54:15 UTC (rev 96224)
@@ -43,6 +43,7 @@
init();
}
+ private static final String HANDLER_PCKGS = "java.protocol.handler.pkgs";
private OSGiBundleManager manager;
public BundleVFSContextFactory(OSGiBundleManager manager)
@@ -55,16 +56,18 @@
public static void init()
{
- String pkgs = System.getProperty("java.protocol.handler.pkgs");
- if (pkgs == null || pkgs.trim().length() == 0)
+ String pckg = BundleVFSContextFactory.class.getPackage().getName();
+ String pckgs = System.getProperty(HANDLER_PCKGS);
+
+ if (pckgs == null || pckgs.trim().length() == 0)
{
- pkgs = "org.jboss.osgi.framework.vfs";
- System.setProperty("java.protocol.handler.pkgs", pkgs);
+ pckgs = pckg;
+ System.setProperty(HANDLER_PCKGS, pckgs);
}
- else if (!pkgs.contains("org.jboss.virtual.protocol"))
+ else if (pckgs.contains(pckg) == false)
{
- pkgs += "|org.jboss.osgi.framework.vfs";
- System.setProperty("java.protocol.handler.pkgs", pkgs);
+ pckgs += ("|" + pckg);
+ System.setProperty(HANDLER_PCKGS, pckgs);
}
}
14 years, 6 months
JBoss-OSGI SVN: r96223 - in projects/jboss-osgi/trunk/reactor/framework: src/main/java/org/jboss/osgi/framework and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-11-10 11:49:19 -0500 (Tue, 10 Nov 2009)
New Revision: 96223
Added:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContextActions.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/
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
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/Handler.java
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/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
Log:
[JBOSGI-201]; handle bundle:// protocol; TODO - tests.
[JBOSGI-141]; initial work on service mix.
Update MC libs - CL, Deployers, VFS.
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-10 15:14:51 UTC (rev 96222)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-10 16:49:19 UTC (rev 96223)
@@ -37,8 +37,9 @@
<!-- Properties -->
<properties>
<version.jboss.aop>2.1.0.CR3</version.jboss.aop>
- <version.jboss.classloading>2.0.7.CR2</version.jboss.classloading>
- <version.jboss.deployers>2.0.8.GA</version.jboss.deployers>
+ <version.jboss.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>
<version.jboss.test>1.1.4.GA</version.jboss.test>
</properties>
@@ -93,6 +94,10 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -101,6 +106,11 @@
<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>
@@ -109,6 +119,12 @@
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading-vfs</artifactId>
<version>${version.jboss.classloading}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
@@ -119,16 +135,34 @@
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs-spi</artifactId>
<version>${version.jboss.deployers}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs</artifactId>
<version>${version.jboss.deployers}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-kernel</artifactId>
<version>${version.jboss.microcontainer}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.osgi</groupId>
@@ -137,10 +171,22 @@
<dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployers</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployment</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- Provided Dependencies -->
@@ -397,9 +443,9 @@
<!-- Subversion -->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projec...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/...</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi/projects/runtime/microcontaine...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/trunk/...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/trunk/rea...</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi/projects/jboss-osgi/trunk/reac...</url>
</scm>
</project>
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-10 15:14:51 UTC (rev 96222)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -94,7 +94,7 @@
protected Set<OSGiServiceState> registeredServices = new ConcurrentSet<OSGiServiceState>();
/** The services in use */
- protected Map<OSGiServiceState, Integer> servicesInUse = new ConcurrentHashMap<OSGiServiceState, Integer>();
+ protected final Map<OSGiServiceState, Integer> servicesInUse = new ConcurrentHashMap<OSGiServiceState, Integer>();
/** The cached symbolic name */
private String symbolicName;
@@ -346,6 +346,7 @@
* True if the use count of a service for this bundle is grater that 0.
*
* @param serviceState the service
+ * @return true if counter is bigger than zero, false otherwise
*/
boolean isServiceInUse(OSGiServiceState serviceState)
{
@@ -652,7 +653,7 @@
int previous = getState();
// Get the corresponding bundle event type
- int bundleEventType = 0;
+ int bundleEventType;
switch (state)
{
case Bundle.STARTING:
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-10 15:14:51 UTC (rev 96222)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -21,8 +21,6 @@
*/
package org.jboss.osgi.framework.bundle;
-import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -48,9 +46,10 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
+import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.DeployerClient;
@@ -75,6 +74,7 @@
import org.jboss.osgi.framework.plugins.Plugin;
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;
@@ -97,6 +97,7 @@
*
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @author Thomas.Diesler(a)jboss.com
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public class OSGiBundleManager
@@ -639,7 +640,6 @@
*/
private void validateBundle(AbstractBundleState bundleState)
{
-
OSGiMetaData metaData = bundleState.getOSGiMetaData();
String symbolicName = metaData.getBundleSymbolicName();
@@ -952,7 +952,7 @@
/**
* Get services
*
- * @param bundleState the referencing bundle
+ * @param bundle the referencing bundle
* @param clazz any class
* @param filter any filter
* @param checkAssignable whether to check isAssignable
@@ -1055,7 +1055,6 @@
* @param bundle the referencing bundle
* @param clazz any class
* @param filterStr any filter
- * @param checkAssignable
* @param checkAssignable whether to check isAssignable
* @return the services
* @throws InvalidSyntaxException when the filter is invalid
@@ -1084,8 +1083,25 @@
OSGiServiceState result = new OSGiServiceState(bundleState, clazzes, service, properties);
result.internalRegister();
registeredServices.add(result);
+
+ try
+ {
+ Controller controller = kernel.getController();
+ controller.install(result);
+ }
+ catch (Throwable t)
+ {
+ fireError(bundleState, "installing service to MC in", t);
+
+ registeredServices.remove(result);
+ result.internalUnregister();
+
+ throw new RuntimeException(t);
+ }
+
FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
plugin.fireServiceEvent(bundleState, ServiceEvent.REGISTERED, result);
+
return result;
}
@@ -1096,9 +1112,12 @@
*/
void unregisterService(OSGiServiceState serviceState)
{
- log.debug("Unregistering service: " + serviceState.toLongString());
+ Controller controller = kernel.getController();
+ controller.uninstall(serviceState.getName());
+
FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
plugin.fireServiceEvent(serviceState.getBundleState(), ServiceEvent.UNREGISTERING, serviceState);
+
registeredServices.remove(serviceState);
serviceState.internalUnregister();
}
@@ -1306,7 +1325,7 @@
/**
* Fire a framework error
*
- * @param bundleState the bundle state
+ * @param bundle the bundle
* @param context the msg context
* @param t the throwable
*/
@@ -1324,7 +1343,7 @@
/**
* Fire a framework error
*
- * @param bundleState the bundle state
+ * @param bundle the bundle
* @param context the msg context
* @param t the throwable
*/
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContextActions.java (from rev 96195, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContextActions.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContextActions.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.bundle;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * OSGi actions.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ */
+class OSGiControllerContextActions implements ControllerContextActions
+{
+ static final ControllerContextActions ACTIONS = new OSGiControllerContextActions();
+
+ public void install(ControllerContext context, ControllerState fromState, ControllerState toState) throws Throwable
+ {
+ }
+
+ public void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
+ {
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-11-10 15:14:51 UTC (rev 96222)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -32,10 +32,12 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
+import org.jboss.dependency.plugins.AbstractControllerContext;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.util.CaseInsensitiveDictionary;
import org.jboss.util.collection.ConcurrentSet;
+import org.jboss.util.id.GUID;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -50,9 +52,10 @@
* OSGiServiceState.
*
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class OSGiServiceState implements ServiceReference, ServiceRegistration
+public class OSGiServiceState extends AbstractControllerContext implements ServiceReference, ServiceRegistration
{
/** The log */
private static final Logger log = Logger.getLogger(OSGiServiceState.class);
@@ -99,6 +102,9 @@
@SuppressWarnings("unchecked")
public OSGiServiceState(AbstractBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
{
+ // name is random / unique, we use aliases
+ super(GUID.asString(), OSGiControllerContextActions.ACTIONS, null, service);
+
if (bundleState == null)
throw new IllegalArgumentException("Null bundle state");
if (clazzes == null || clazzes.length == 0)
@@ -158,13 +164,20 @@
return clazzes;
}
+ @Override
+ public Object getTarget()
+ {
+ // do we cache this? or how to unget?
+ return getService(getBundleState());
+ }
+
/**
* Get the service.
*
* @param bundleState the bundle that requested the service
* @return the service.
*/
- public Object getService(AbstractBundleState bundleState)
+ Object getService(AbstractBundleState bundleState)
{
// [TODO] fix race condition with unregistration
if (isUnregistered())
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleHandler.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -0,0 +1,130 @@
+/*
+ * 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.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VirtualFileHandler;
+
+/**
+ * Bundle handler.
+ *
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+class BundleHandler extends AbstractVirtualFileHandler
+{
+ private VirtualFileHandler handler;
+ private OSGiBundleState bundleState;
+
+ public BundleHandler(VFSContext context, VirtualFileHandler parent, VirtualFileHandler handler, OSGiBundleState bundleState)
+ {
+ super(context, parent, handler.getName());
+ this.handler = handler;
+ this.bundleState = bundleState;
+ }
+
+ public URI toURI() throws URISyntaxException
+ {
+ return new URI("bundle", Long.toString(bundleState.getBundleId()), handler.getLocalPathName(), null);
+ }
+
+ public long getLastModified() throws IOException
+ {
+ return bundleState.getLastModified();
+ }
+
+ public InputStream openStream() throws IOException
+ {
+ bundleState.getResource(""); // permission check
+
+ return handler.openStream();
+ }
+
+ public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
+ {
+ bundleState.findEntries("", null, false); // permission check
+
+ List<VirtualFileHandler> children = handler.getChildren(ignoreErrors);
+ if (children != null && children.isEmpty() == false)
+ {
+ List<VirtualFileHandler> handlers = new ArrayList<VirtualFileHandler>(children.size());
+ for (VirtualFileHandler child : children)
+ {
+ handlers.add(new BundleHandler(getVFSContext(), handler, child, bundleState));
+ }
+ return handlers;
+ }
+ return Collections.emptyList();
+ }
+
+ public VirtualFileHandler getChild(String path) throws IOException
+ {
+ URL entry = bundleState.getEntry(path); // permission check
+ if (entry == null)
+ return null;
+
+ VirtualFileHandler child = handler.getChild(path); // the child should exist, since entry does
+ return new BundleHandler(getVFSContext(), handler, child, bundleState);
+ }
+
+ //---------------------------------------------------------
+
+ public long getSize() throws IOException
+ {
+ return handler.getSize();
+ }
+
+ public boolean exists() throws IOException
+ {
+ return handler.exists();
+ }
+
+ public boolean isLeaf() throws IOException
+ {
+ return handler.isLeaf();
+ }
+
+ public boolean isHidden() throws IOException
+ {
+ return handler.isHidden();
+ }
+
+ public boolean removeChild(String name) throws IOException
+ {
+ return handler.removeChild(name);
+ }
+
+ public boolean isNested() throws IOException
+ {
+ return handler.isNested();
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -0,0 +1,119 @@
+/*
+ * 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.Method;
+import java.net.URI;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.AbstractVFSContext;
+import org.jboss.virtual.spi.VirtualFileHandler;
+
+/**
+ * Bundle vfs context.
+ *
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+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;
+
+ public BundleVFSContext(URI rootURI, OSGiBundleManager manager) throws IOException
+ {
+ super(rootURI);
+
+ host = rootURI.getHost();
+ long id = Long.parseLong(host);
+ if (id == 0)
+ throw new IllegalArgumentException("Cannot handle system bundle, it's too abstract.");
+
+ AbstractBundleState abs = manager.getBundleById(id);
+ if (abs == null)
+ throw new IllegalArgumentException("No such bundle: " + id);
+
+ OSGiBundleState bundleState = OSGiBundleState.class.cast(abs); // should be able to cast, as it's not system
+ 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;
+ }
+ }
+
+ public String getName()
+ {
+ return host;
+ }
+
+ public VirtualFileHandler getRoot() throws IOException
+ {
+ return root;
+ }
+}
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContextFactory.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -0,0 +1,99 @@
+/*
+ * 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.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.io.IOException;
+
+import org.jboss.virtual.plugins.context.AbstractContextFactory;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VFSContextFactoryLocator;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+
+/**
+ * Bundle vfs context factory.
+ *
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+public class BundleVFSContextFactory extends AbstractContextFactory
+{
+ static
+ {
+ init();
+ }
+
+ private OSGiBundleManager manager;
+
+ public BundleVFSContextFactory(OSGiBundleManager manager)
+ {
+ super("bundle");
+ if (manager == null)
+ throw new IllegalArgumentException("Null manager");
+ this.manager = manager;
+ }
+
+ public static void init()
+ {
+ String pkgs = System.getProperty("java.protocol.handler.pkgs");
+ if (pkgs == null || pkgs.trim().length() == 0)
+ {
+ pkgs = "org.jboss.osgi.framework.vfs";
+ System.setProperty("java.protocol.handler.pkgs", pkgs);
+ }
+ else if (!pkgs.contains("org.jboss.virtual.protocol"))
+ {
+ pkgs += "|org.jboss.osgi.framework.vfs";
+ System.setProperty("java.protocol.handler.pkgs", pkgs);
+ }
+ }
+
+ public void start()
+ {
+ VFSContextFactoryLocator.registerFactory(this);
+ }
+
+ public void stop()
+ {
+ VFSContextFactoryLocator.unregisterFactory(this);
+ }
+
+ public VFSContext getVFS(URL rootURL) throws IOException
+ {
+ try
+ {
+ return getVFS(rootURL.toURI());
+ }
+ catch (URISyntaxException e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ public VFSContext getVFS(URI rootURI) throws IOException
+ {
+ return new BundleVFSContext(rootURI, manager);
+ }
+}
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/bundle/Handler.java 2009-11-10 16:49:19 UTC (rev 96223)
@@ -0,0 +1,45 @@
+/*
+ * 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.bundle;
+
+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;
+
+/**
+ * Bundle url stream handler.
+ *
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+public class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection(URL u) throws IOException
+ {
+ VirtualFile file = VFS.getRoot(u);
+ return new VirtualFileURLConnection(u, file);
+ }
+}
\ No newline at end of file
14 years, 6 months
JBoss-OSGI SVN: r96196 - in projects/jboss-osgi/trunk/reactor/framework/src: main/java/org/jboss/osgi/framework/resolver/internal and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-09 17:11:53 -0500 (Mon, 09 Nov 2009)
New Revision: 96196
Added:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.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/ResolverSmokeTest.java
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java
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/Resolver.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedPackageImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
Log:
Add resolver metadata processing and test
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-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.framework.resolver;
-import java.util.Map;
+import java.util.Set;
/**
@@ -47,8 +47,14 @@
String getName();
/**
- * Get the associated map of arbitrary attributes.
- * @return Associated map of arbitrary attributes or an empty map.
+ * Get the associated set of arbitrary attributes.
+ * @return An empty list if their are no attributes.
*/
- Map<String, String> getAttributes();
+ Set<String> getAttributes();
+
+ /**
+ * Get the attribute value for the given key.
+ * @return The attribute value or null.
+ */
+ Object getAttribute(String key);
}
\ No newline at end of file
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-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -24,9 +24,10 @@
import java.util.List;
import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
/**
- * The Resolver handles the resolve phase of bundles.
+ * Handles the resolve phase of the installed bundles.
*
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
@@ -40,6 +41,18 @@
List<Resolvable> getBundles();
/**
+ * Get the registered resolvable bundle.
+ * @return The registered resolvable bundle.
+ */
+ Resolvable getBundle(String symbolicName, Version version);
+
+ /**
+ * Get the registered resolvable bundle.
+ * @return The registered resolvable bundle.
+ */
+ Resolvable getBundle(Bundle bundle);
+
+ /**
* Add a bundle to the resolver.
*
* @param bundle the bundle
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -21,53 +21,96 @@
*/
package org.jboss.osgi.framework.resolver.internal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
+import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.ImportPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Constants;
import org.osgi.framework.Version;
/**
+ * An abstraction of a package export.
*
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
*/
public class ExportPackageImpl extends NamedPackageImpl implements ExportPackage
{
+ private PackageAttribute packageMetaData;
+
public ExportPackageImpl(Resolvable owner, String packageName)
{
super(owner, packageName);
}
- public List<String> getExcludes()
+ @Override
+ protected PackageAttribute getPackageMetaData()
{
- throw new NotImplementedException();
+ if (packageMetaData == null)
+ {
+ for (PackageAttribute aux : getMetaData().getExportPackages())
+ {
+ if (aux.getPackageInfo().getName().equals(getName()))
+ {
+ packageMetaData = aux;
+ break;
+ }
+ }
+ if (packageMetaData == null)
+ throw new IllegalStateException("Cannot obtain packageMetaData for: " + getName());
+ }
+ return packageMetaData;
}
- public Set<ImportPackage> getImporters()
+ public Version getVersion()
{
- throw new NotImplementedException();
+ Parameter version = getPackageMetaData().getAttribute(Constants.VERSION_ATTRIBUTE);
+ return Version.parseVersion(version != null ? version.getValue().toString() : null);
}
+ public List<String> getUses()
+ {
+ return getDirectiveValueList(Constants.USES_DIRECTIVE);
+ }
+
+ public List<String> getExcludes()
+ {
+ List<String> valueList = getDirectiveValueList(Constants.EXCLUDE_DIRECTIVE);
+ return valueList.isEmpty() ? null : valueList;
+ }
+
public List<String> getIncludes()
{
- throw new NotImplementedException();
+ List<String> valueList = getDirectiveValueList(Constants.INCLUDE_DIRECTIVE);
+ return valueList.isEmpty() ? null : valueList;
}
public List<String> getMandatoryAttributes()
{
- throw new NotImplementedException();
+ return getDirectiveValueList(Constants.MANDATORY_DIRECTIVE);
}
- public List<String> getUses()
+ @SuppressWarnings("unchecked")
+ private List<String> getDirectiveValueList(String key)
{
- throw new NotImplementedException();
+ List<String> valueList = new ArrayList<String>();
+ Parameter directive = getPackageMetaData().getDirective(key);
+ if (directive != null)
+ {
+ valueList.addAll((Collection<String>)directive.getValue());
+ }
+ return Collections.unmodifiableList(valueList);
}
- public Version getVersion()
+ public Set<ImportPackage> getImporters()
{
throw new NotImplementedException();
}
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.framework.resolver.internal;
+
+import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.jboss.osgi.framework.metadata.Parameter;
+import org.jboss.osgi.framework.metadata.VersionRange;
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.ImportPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+/**
+ * An abstraction of a package import.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Nov-2009
+ */
+public class ImportPackageImpl extends NamedPackageImpl implements ImportPackage
+{
+ private PackageAttribute packageMetaData;
+
+ public ImportPackageImpl(Resolvable owner, String packageName)
+ {
+ super(owner, packageName);
+ }
+
+ @Override
+ protected PackageAttribute getPackageMetaData()
+ {
+ if (packageMetaData == null)
+ {
+ for (PackageAttribute aux : getMetaData().getImportPackages())
+ {
+ if (aux.getPackageInfo().getName().equals(getName()))
+ {
+ packageMetaData = aux;
+ break;
+ }
+ }
+ if (packageMetaData == null)
+ throw new IllegalStateException("Cannot obtain packageMetaData for: " + getName());
+ }
+ return packageMetaData;
+ }
+
+ public VersionRange getVersion()
+ {
+ throw new NotImplementedException();
+ }
+
+ public String getBundleSymbolicName()
+ {
+ return (String)getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
+ }
+
+ public Version getBundleVersion()
+ {
+ return Version.parseVersion((String)getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE));
+ }
+
+ public Resolution getResolution()
+ {
+ Parameter param = getPackageMetaData().getDirective(Constants.RESOLUTION_DIRECTIVE);
+ return (param != null ? Resolution.valueOf(param.getValue().toString()) : Resolution.MANDATORY);
+ }
+
+ public ExportPackage getExporter()
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedPackageImpl.java 2009-11-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedPackageImpl.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -21,26 +21,39 @@
*/
package org.jboss.osgi.framework.resolver.internal;
-import java.util.Map;
+import java.util.Set;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.resolver.NamedPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
-import org.jboss.osgi.spi.NotImplementedException;
/**
+ * An abstraction of an osgi package declaration.
*
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
*/
-public class NamedPackageImpl implements NamedPackage
+abstract class NamedPackageImpl implements NamedPackage
{
private Resolvable owner;
private String packageName;
-
+ private OSGiMetaData metaData;
+
public NamedPackageImpl(Resolvable owner, String packageName)
{
+ if (owner == null)
+ throw new IllegalArgumentException("Null package owner");
+ if (packageName == null)
+ throw new IllegalArgumentException("Null packageName");
+
this.owner = owner;
this.packageName = packageName;
+
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(owner.getBundle());
+ this.metaData = bundleState.getOSGiMetaData();
}
public Resolvable getOwner()
@@ -52,9 +65,22 @@
{
return packageName;
}
-
- public Map<String, String> getAttributes()
+
+ protected OSGiMetaData getMetaData()
{
- throw new NotImplementedException();
+ return metaData;
}
+
+ protected abstract PackageAttribute getPackageMetaData();
+
+ public Set<String> getAttributes()
+ {
+ return getPackageMetaData().getAttributes().keySet();
+ }
+
+ public Object getAttribute(String key)
+ {
+ Parameter attr = getPackageMetaData().getAttribute(key);
+ return (attr != null ? attr.getValue() : null);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -33,27 +33,28 @@
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.ImportPackage;
import org.jboss.osgi.framework.resolver.Resolvable;
-import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
/**
+ * An abstraction of a resolvable bundle.
*
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
*/
public class ResolvableImpl implements Resolvable
{
- private OSGiBundleState bundle;
+ private OSGiBundleState bundleState;
private OSGiMetaData metaData;
private boolean resolved;
private Map<String, ExportPackage> exportedPackages = new LinkedHashMap<String, ExportPackage>();
+ private Map<String, ImportPackage> importedPackages = new LinkedHashMap<String, ImportPackage>();
public ResolvableImpl(Bundle bundle)
{
- this.bundle = OSGiBundleState.assertBundleState(bundle);
- this.metaData = ((OSGiBundleState)bundle).getOSGiMetaData();
+ this.bundleState = OSGiBundleState.assertBundleState(bundle);
+ this.metaData = bundleState.getOSGiMetaData();
// Initialize exported packages
List<PackageAttribute> exportPackages = metaData.getExportPackages();
@@ -65,21 +66,32 @@
exportedPackages.put(packageName, new ExportPackageImpl(this, packageName));
}
}
+
+ // Initialize imported packages
+ List<PackageAttribute> importPackages = metaData.getImportPackages();
+ if (importPackages != null)
+ {
+ for (PackageAttribute attr: importPackages)
+ {
+ String packageName = attr.getPackageInfo().getName();
+ importedPackages.put(packageName, new ImportPackageImpl(this, packageName));
+ }
+ }
}
public Bundle getBundle()
{
- return bundle;
+ return bundleState.getBundleInternal();
}
public String getSymbolicName()
{
- return bundle.getSymbolicName();
+ return bundleState.getSymbolicName();
}
public Version getVersion()
{
- return bundle.getVersion();
+ return bundleState.getVersion();
}
public ExportPackage getExportPackage(String packageName)
@@ -93,14 +105,15 @@
return Collections.unmodifiableList(values);
}
- public ImportPackage getImportPackage(String name)
+ public ImportPackage getImportPackage(String packageName)
{
- throw new NotImplementedException();
+ return importedPackages.get(packageName);
}
public List<ImportPackage> getImportPackages()
{
- throw new NotImplementedException();
+ List<ImportPackage> values = new ArrayList<ImportPackage>(importedPackages.values());
+ return Collections.unmodifiableList(values);
}
public boolean isResolved()
@@ -115,6 +128,6 @@
public boolean isSingleton()
{
- return bundle.getOSGiMetaData().isSingleton();
+ return metaData.isSingleton();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-11-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -48,6 +48,7 @@
import org.jboss.osgi.framework.resolver.internal.ResolvableImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
/**
* The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
@@ -75,6 +76,35 @@
return Collections.unmodifiableList(values);
}
+ public Resolvable getBundle(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Null bundle");
+
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ return resolverBundleMap.get(bundleState);
+ }
+
+ public Resolvable getBundle(String symbolicName, Version version)
+ {
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Null symbolicName");
+
+ if (version == null)
+ version = Version.emptyVersion;
+
+ Resolvable retBundle = null;
+ for (Resolvable aux : resolverBundleMap.values())
+ {
+ if (aux.getSymbolicName().equals(symbolicName) && aux.getVersion().equals(version))
+ {
+ retBundle = aux;
+ break;
+ }
+ }
+ return retBundle;
+ }
+
public Resolvable addBundle(Bundle bundle)
{
OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTest.java 2009-11-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTest.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.resolver;
-
-// $Id: FrameworkLaunchTestCase.java 92733 2009-08-24 09:40:32Z thomas.diesler(a)jboss.com $
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-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.Resolvable;
-import org.jboss.osgi.framework.resolver.Resolver;
-import org.jboss.osgi.spi.util.ServiceLoader;
-import org.jboss.osgi.testing.OSGiTest;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-
-/**
- * Test OSGi System bundle access
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-Jul-2009
- */
-public class BundleResolverTest extends OSGiTest
-{
- @Test
- public void testBundleResolver() throws BundleException
- {
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- Framework framework = factory.newFramework(null);
- framework.start();
-
- List<String> bundlePaths = new ArrayList<String>();
- bundlePaths.add("bundles/jboss-osgi-apache-xerces.jar");
- bundlePaths.add("bundles/jboss-osgi-common.jar");
- bundlePaths.add("bundles/jboss-osgi-common-core.jar");
- bundlePaths.add("bundles/jboss-osgi-husky.jar");
- bundlePaths.add("bundles/jboss-osgi-jaxb.jar");
- bundlePaths.add("bundles/jboss-osgi-jmx.jar");
- bundlePaths.add("bundles/jboss-osgi-jndi.jar");
- bundlePaths.add("bundles/jboss-osgi-xml-binding.jar");
- bundlePaths.add("bundles/org.apache.felix.configadmin.jar");
- bundlePaths.add("bundles/org.apache.felix.log.jar");
- bundlePaths.add("bundles/org.apache.felix.metatype.jar");
- bundlePaths.add("bundles/org.osgi.compendium.jar");
- bundlePaths.add("bundles/pax-web-jetty-bundle.jar");
-
- Collections.shuffle(bundlePaths);
-
- List<Bundle> unresolved = new ArrayList<Bundle>();
- BundleContext sysContext = framework.getBundleContext();
- for (String path : bundlePaths)
- {
- Bundle bundle = sysContext.installBundle(getTestArchivePath(path));
- unresolved.add(bundle);
- }
-
- OSGiBundleManager bundleManager = ((OSGiFramework)framework).getBundleManager();
- Resolver bundleResolver = bundleManager.getPlugin(ResolverPlugin.class);
- assertEquals("All bundles installed", bundlePaths.size(), bundleResolver.getBundles().size());
-
- List<Resolvable> resolved = bundleResolver.resolve(unresolved);
- assertEquals("All bundles resolved", unresolved.size(), resolved.size());
-
- framework.stop();
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java 2009-11-09 20:04:21 UTC (rev 96195)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.resolver;
-
-// $Id$
-
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.testing.OSGiTest;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-
-/**
- * Test import directive 'resolution'
- *
- * @author thomas.diesler(a)jboss.com
- * @since 09-Nov-2009
- */
-@Ignore
-public class ImportDirectiveResolutionTest extends OSGiTest
-{
-
- private static Framework framework;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
- {
- OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
- framework = bootProvider.getFramework();
- framework.start();
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (framework != null)
- {
- framework.stop();
- framework = null;
- }
- }
- /**
- * [TODO] testImportAvailable
- *
- * @throws BundleException
- */
- public void testImportAvailable() throws BundleException
- {
- }
-
- /**
- * [TODO] testImportNotAvailable
-
- * @throws BundleException
- */
- public void testImportNotAvailable() throws BundleException
- {
- }
-}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.resolver;
+
+// $Id$
+
+import java.util.List;
+
+import org.jboss.osgi.framework.plugins.ResolverPlugin;
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.ImportPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.test.osgi.FrameworkTestCase;
+import org.jboss.test.osgi.classloader.support.a.A;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * Test {@link Resolver} metadata.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-Jul-2009
+ */
+public class ResolverMetadataTest extends FrameworkTestCase
+{
+ public ResolverMetadataTest(String name)
+ {
+ super(name);
+ }
+
+ @Test
+ public void testBasicExport() throws Exception
+ {
+ //Bundle-Name: BundleA
+ //Bundle-Version: 1.0.0
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
+ Bundle bundleA = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+
+ Resolver resolver = getBundleManager().getPlugin(ResolverPlugin.class);
+ assertEquals(1, resolver.getBundles().size());
+
+ Resolvable resolvableA = resolver.getBundle(bundleA.getSymbolicName(), null);
+ assertNull("Resolvable 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(bundleA.getSymbolicName(), resolvableA.getSymbolicName());
+ assertEquals(bundleA.getVersion(), 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.parseVersion("1.0.0"), exportPackage.getVersion());
+ assertEquals(0, exportPackage.getUses().size());
+ assertEquals(0, exportPackage.getMandatoryAttributes().size());
+ assertEquals("x", exportPackage.getAttribute("test"));
+ 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());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java (from rev 96188, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTest.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTest.java 2009-11-09 22:11:53 UTC (rev 96196)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.resolver;
+
+// $Id: FrameworkLaunchTestCase.java 92733 2009-08-24 09:40:32Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+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.Resolvable;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.osgi.testing.OSGiTest;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Smoketest for the {@link Resolver}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-Jul-2009
+ */
+public class ResolverSmokeTest extends OSGiTest
+{
+ @Test
+ public void testBundleResolver() throws BundleException
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ OSGiFramework framework = (OSGiFramework)factory.newFramework(null);
+
+ OSGiBundleManager bundleManager = framework.getBundleManager();
+ Resolver resolver = bundleManager.getPlugin(ResolverPlugin.class);
+
+ try
+ {
+ framework.start();
+
+ List<String> bundlePaths = new ArrayList<String>();
+ bundlePaths.add("bundles/jboss-osgi-apache-xerces.jar");
+ bundlePaths.add("bundles/jboss-osgi-common.jar");
+ bundlePaths.add("bundles/jboss-osgi-common-core.jar");
+ bundlePaths.add("bundles/jboss-osgi-husky.jar");
+ bundlePaths.add("bundles/jboss-osgi-jaxb.jar");
+ bundlePaths.add("bundles/jboss-osgi-jmx.jar");
+ bundlePaths.add("bundles/jboss-osgi-jndi.jar");
+ bundlePaths.add("bundles/jboss-osgi-xml-binding.jar");
+ bundlePaths.add("bundles/org.apache.felix.configadmin.jar");
+ bundlePaths.add("bundles/org.apache.felix.log.jar");
+ bundlePaths.add("bundles/org.apache.felix.metatype.jar");
+ bundlePaths.add("bundles/org.osgi.compendium.jar");
+ bundlePaths.add("bundles/pax-web-jetty-bundle.jar");
+
+ Collections.shuffle(bundlePaths);
+
+ List<Bundle> unresolved = new ArrayList<Bundle>();
+ BundleContext sysContext = framework.getBundleContext();
+ for (String path : bundlePaths)
+ {
+ Bundle bundle = sysContext.installBundle(getTestArchivePath(path));
+ unresolved.add(bundle);
+ }
+
+ List<Resolvable> installedBundles = resolver.getBundles();
+ assertEquals("All bundles installed", bundlePaths.size(), installedBundles.size());
+
+ List<Resolvable> resolved = resolver.resolve(unresolved);
+ assertEquals("All bundles resolved", unresolved.size(), resolved.size());
+ }
+ finally
+ {
+ framework.stop();
+ }
+ }
+}
\ No newline at end of file
14 years, 6 months
JBoss-OSGI SVN: r96193 - in projects/jboss-osgi/trunk/reactor/framework: src/test/java/org/jboss/test/osgi and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-09 14:47:51 -0500 (Mon, 09 Nov 2009)
New Revision: 96193
Added:
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/classloader/BundleClassPathTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloading/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/classloading/
Modified:
projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml
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/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/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
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/web.xml
Log:
Move BundleClassPathTest together with other classloader tests
Rename OSGiTestCase to FrameworkTestCase to reduce confusion with Husky OSGiTest
Modified: projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml 2009-11-09 19:47:51 UTC (rev 96193)
@@ -44,12 +44,12 @@
<!-- bundle-classpath -->
<war destfile="${tests.output.dir}/test-libs/bundle-classpath.war"
- manifest="${tests.resources.dir}/classloading/bundleclasspath/MANIFEST.MF"
- webxml="${tests.resources.dir}/classloading/bundleclasspath/web.xml">
+ manifest="${tests.resources.dir}/bundles/classloader/bundleclasspath/MANIFEST.MF"
+ webxml="${tests.resources.dir}/bundles/classloader/bundleclasspath/web.xml">
<classes dir="${tests.classes.dir}">
- <include name="**/classloading/EndpointServlet.class"/>
+ <include name="**/classloader/support/a/A.class"/>
</classes>
- <fileset dir="${tests.resources.dir}/classloading/bundleclasspath">
+ <fileset dir="${tests.resources.dir}/bundles/classloader/bundleclasspath">
<include name="message.txt"/>
</fileset>
</war>
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java (from rev 96190, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -0,0 +1,572 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.osgi;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+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.spi.util.ConstantsHelper;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.SynchronousBundleListener;
+
+/**
+ * OSGiTestCase - Parent Test Case for OSGi tests.
+ *
+ * @author <a href="baileyje(a)gmail.com">John Bailey</a>
+ * @version $Revision: 87848 $
+ */
+public abstract class FrameworkTestCase extends MicrocontainerTest implements FrameworkListener, SynchronousBundleListener, ServiceListener
+{
+ private List<FrameworkEvent> frameworkEvents = new CopyOnWriteArrayList<FrameworkEvent>();
+ private List<BundleEvent> bundleEvents = new CopyOnWriteArrayList<BundleEvent>();
+ private List<ServiceEvent> serviceEvents = new CopyOnWriteArrayList<ServiceEvent>();
+
+ /**
+ * Create a new OSGiTestCase.
+ *
+ * @param name the test name
+ */
+ public FrameworkTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get the AbstractTestDelegate
+ *
+ * @param clazz the test class
+ * @return The AbstractTestDelegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ FrameworkTestDelegate delegate = new FrameworkTestDelegate(clazz);
+ //delegate.enableSecurity = true;
+ return delegate;
+ }
+
+ /**
+ * Get OSGiTestDelegate
+ */
+ protected FrameworkTestDelegate getDelegate()
+ {
+ return (FrameworkTestDelegate)super.getDelegate();
+ }
+
+ /**
+ * Get BundleManager from Delegate
+ *
+ * @return The BundleManager
+ */
+ protected OSGiBundleManager getBundleManager()
+ {
+ return getDelegate().getBundleManager();
+ }
+
+ /**
+ * Get the system bundle
+ *
+ * @return the system bundle
+ */
+ protected Bundle getSystemBundle()
+ {
+ return getBundleManager().getBundleById(0).getBundleInternal();
+ }
+
+ /**
+ * Add the base bundles
+ *
+ * @param expected the collection to add to
+ */
+ protected void addBaseBundles(Collection<Bundle> expected)
+ {
+ expected.add(getSystemBundle());
+ }
+
+ /**
+ * 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 addBundle(String root, String child) throws Exception
+ {
+ return getDelegate().addBundle(root, child);
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle addBundle(VirtualFile file) throws Exception
+ {
+ return getDelegate().addBundle(file);
+ }
+
+ /**
+ * Remove a bundle
+ *
+ * @param bundle the bundle to remove
+ * @throws Exception for any error
+ */
+ protected void uninstall(Bundle bundle) throws Exception
+ {
+ getDelegate().uninstall(bundle);
+ }
+
+ protected DeploymentUnit getDeploymentUnit(Bundle bundle)
+ {
+ return getDelegate().getDeploymentUnit(bundle);
+ }
+
+ protected Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+ {
+ return getDelegate().assembleBundle(name, new String[] { resources }, packages);
+ }
+
+ protected Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ return getDelegate().assembleBundle(name, resourcePaths, packages);
+ }
+
+ protected AssembledDirectory createAssembledDirectory(String name) throws Exception
+ {
+ return getDelegate().createAssembledDirectory(name, "");
+ }
+
+ protected AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
+ {
+ return getDelegate().createAssembledDirectory(name, rootName);
+ }
+
+ protected void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ {
+ getDelegate().addPackage(dir, reference);
+ }
+
+ protected void addPath(final AssembledDirectory dir, String path, String name) throws Exception
+ {
+ getDelegate().addPath(dir, path, name);
+ }
+
+ protected void assertClassEquality(Class<?> expected, Class<?> actual)
+ {
+ assertTrue("Should be the same " + ClassLoaderUtils.classToString(expected) + " and " + ClassLoaderUtils.classToString(actual), expected == actual);
+ }
+
+ protected void assertNoClassEquality(Class<?> expected, Class<?> actual)
+ {
+ assertTrue("Should NOT be the same " + ClassLoaderUtils.classToString(expected) + " and " + ClassLoaderUtils.classToString(actual), expected != actual);
+ }
+
+ protected void assertClassLoader(Class<?> clazz, Bundle expected)
+ {
+ if (expected == null)
+ return;
+ ClassLoader cl = clazz.getClassLoader();
+ ClassLoader bundleClassLoader = getBundleClassLoader(expected);
+ boolean result = bundleClassLoader.equals(cl);
+ assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected classloader=" + expected, result);
+ }
+
+ protected ClassLoader getBundleClassLoader(Bundle expected)
+ {
+ return getDeploymentUnit(expected).getClassLoader();
+ }
+
+ protected Class<?> assertLoadClass(Bundle start, Class<?> reference) throws Exception
+ {
+ return assertLoadClass(start, reference, start);
+ }
+
+ protected Class<?> assertLoadClass(Bundle start, Class<?> reference, Bundle expected) throws Exception
+ {
+ return assertLoadClass(start, reference, expected, false);
+ }
+
+ protected Class<?> assertLoadClass(Bundle start, Class<?> reference, Bundle expected, boolean isReference) throws Exception
+ {
+ Class<?> result = assertLoadClass(reference.getName(), start, expected);
+ if (isReference)
+ assertClassEquality(reference, result);
+ else
+ assertNoClassEquality(reference, result);
+ return result;
+ }
+
+ protected Class<?> assertLoadClass(String name, Bundle bundle, Bundle expected)
+ {
+ Class<?> result = null;
+ try
+ {
+ result = bundle.loadClass(name);
+ getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + bundle);
+ }
+ catch (ClassNotFoundException e)
+ {
+ failure("Did not expect CNFE for " + name + " from " + bundle, e);
+ }
+ assertClassLoader(result, expected);
+ return result;
+ }
+
+ protected void assertLoadClassFail(Bundle start, Class<?> reference)
+ {
+ assertLoadClassFail(start, reference.getName());
+ }
+
+ protected void assertLoadClassFail(Bundle start, String name)
+ {
+ try
+ {
+ start.loadClass(name);
+ fail("Should not be here!");
+ }
+ catch (Exception expected)
+ {
+ checkThrowable(ClassNotFoundException.class, expected);
+ }
+ }
+
+ protected URL getBundleResource(Bundle bundle, String path)
+ {
+ return getDelegate().getBundleResource(bundle, path);
+ }
+
+ protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
+ {
+ return getDelegate().getBundleResources(bundle, path);
+ }
+
+ protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws Exception
+ {
+ assertNoAllReferences(bundleContext, clazz, null);
+ }
+
+ protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String filter) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
+ assertNull("Expected no references for clazz=" + clazz + " filter=" + filter, actual);
+ }
+
+ protected void assertAllReferences(BundleContext bundleContext, String clazz, ServiceReference... expected) throws Exception
+ {
+ assertAllReferences(bundleContext, clazz, null, expected);
+ }
+
+ protected void assertAllReferences(BundleContext bundleContext, String clazz, String filter, ServiceReference... expected) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
+ assertEquals(bundleContext + " with clazz=" + clazz + " filter=" + filter, expected, actual);
+ }
+
+ protected void assertNoReferences(BundleContext bundleContext, String clazz) throws Exception
+ {
+ assertNoReferences(bundleContext, clazz, null);
+ }
+
+ protected void assertNoReferences(BundleContext bundleContext, String clazz, String filter) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
+ assertNull("Expected no references for clazz=" + clazz + " filter=" + filter, actual);
+ }
+
+ protected void assertReferences(BundleContext bundleContext, String clazz, ServiceReference... expected) throws Exception
+ {
+ assertReferences(bundleContext, clazz, null, expected);
+ }
+
+ protected void assertReferences(BundleContext bundleContext, String clazz, String filter, ServiceReference... expected) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
+ assertEquals(bundleContext + " with clazz=" + clazz + " filter=" + filter, expected, actual);
+ }
+
+ protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws Exception
+ {
+ ServiceReference actual = bundleContext.getServiceReference(clazz);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + actual + " for clazz=" + clazz);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
+ assertNull("Expected no references for clazz=" + clazz, actual);
+ }
+
+ protected void assertGetReference(BundleContext bundleContext, String clazz, ServiceReference expected) throws Exception
+ {
+ ServiceReference actual = bundleContext.getServiceReference(clazz);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
+ assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
+ }
+
+ protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
+ {
+ Set<Bundle> expected = new HashSet<Bundle>();
+ for (Bundle bundle : bundles)
+ expected.add(bundle);
+
+ Set<Bundle> actual = new HashSet<Bundle>();
+ Bundle[] users = reference.getUsingBundles();
+ if (users != null)
+ for (Bundle bundle : users)
+ actual.add(bundle);
+
+ getLog().debug(reference + " users=" + actual);
+
+ assertEquals(expected, actual);
+ }
+
+ protected void assertObjectClass(String expected, ServiceReference reference)
+ {
+ assertObjectClass(new String[] { expected }, reference);
+ }
+
+ protected void assertObjectClass(String[] expected, ServiceReference reference)
+ {
+ Object actual = reference.getProperty(Constants.OBJECTCLASS);
+ if (actual == null)
+ fail("no object class???");
+ if (actual instanceof String[] == false)
+ fail(actual + " is not a string array??? " + actual.getClass().getName());
+ assertEquals(expected, (String[])actual);
+ }
+
+ public void frameworkEvent(FrameworkEvent event)
+ {
+ synchronized (frameworkEvents)
+ {
+ getLog().debug("FrameworkEvent type=" + ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
+ frameworkEvents.add(event);
+ frameworkEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoFrameworkEvent() throws Exception
+ {
+ getLog().debug("frameworkEvents=" + frameworkEvents);
+ assertEquals(0, frameworkEvents.size());
+ }
+
+ protected void assertFrameworkEvent(int type) throws Exception
+ {
+ assertFrameworkEvent(type, getSystemBundle(), null);
+ }
+
+ protected void assertFrameworkEvent(int type, Class<? extends Throwable> expectedThrowable) throws Exception
+ {
+ assertFrameworkEvent(type, getSystemBundle(), expectedThrowable);
+ }
+
+ protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends Throwable> expectedThrowable) throws Exception
+ {
+ waitForEvent(frameworkEvents, type);
+ getLog().debug("frameworkEvents=" + frameworkEvents);
+ int size = frameworkEvents.size();
+ assertTrue("" + size, size > 0);
+ FrameworkEvent event = frameworkEvents.remove(0);
+ assertEquals(ConstantsHelper.frameworkEvent(type), ConstantsHelper.frameworkEvent(event.getType()));
+ Throwable t = event.getThrowable();
+ if (expectedThrowable == null)
+ {
+ if (t != null)
+ {
+ getLog().error("Unexpected error in Framework event: ", t);
+ fail("Unexpected throwable: " + t);
+ }
+ }
+ else
+ {
+ checkThrowable(BundleException.class, t);
+ checkDeepThrowable(expectedThrowable, t);
+ }
+ assertEquals(bundle, event.getSource());
+ assertEquals(bundle, event.getBundle());
+ }
+
+ public void bundleChanged(BundleEvent event)
+ {
+ synchronized (bundleEvents)
+ {
+ getLog().debug("BundleChanged type=" + ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
+ bundleEvents.add(event);
+ bundleEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoBundleEvent() throws Exception
+ {
+ getLog().debug("bundleEvents=" + bundleEvents);
+ assertEquals(0, bundleEvents.size());
+ }
+
+ protected void assertBundleEvent(int type, Bundle bundle) throws Exception
+ {
+ waitForEvent(bundleEvents, type);
+
+ getLog().debug("bundleEvents=" + bundleEvents);
+ int size = bundleEvents.size();
+ assertTrue("" + size, size > 0);
+
+ if (bundle instanceof AbstractBundleState)
+ bundle = ((AbstractBundleState)bundle).getBundle();
+
+ BundleEvent foundEvent = null;
+ for(int i=0; i < bundleEvents.size(); i++)
+ {
+ BundleEvent aux = bundleEvents.get(i);
+ if (type == aux.getType())
+ {
+ if (bundle.equals(aux.getSource()) && bundle.equals(aux.getBundle()))
+ {
+ bundleEvents.remove(aux);
+ foundEvent = aux;
+ break;
+ }
+ }
+ }
+
+ if (foundEvent == null)
+ fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + " from " + bundle);
+ }
+
+ public void serviceChanged(ServiceEvent event)
+ {
+ synchronized (serviceEvents)
+ {
+ getLog().debug("ServiceChanged type=" + ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
+ serviceEvents.add(event);
+ serviceEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoServiceEvent() throws Exception
+ {
+ getLog().debug("serviceEvents=" + serviceEvents);
+ assertEquals(0, serviceEvents.size());
+ }
+
+ protected void assertServiceEvent(int type, ServiceReference reference) throws Exception
+ {
+ waitForEvent(serviceEvents, type);
+ getLog().debug("serviceEvents=" + serviceEvents);
+ int size = serviceEvents.size();
+ assertTrue("" + size, size > 0);
+ ServiceEvent event = serviceEvents.remove(0);
+ assertEquals(ConstantsHelper.serviceEvent(type), ConstantsHelper.serviceEvent(event.getType()));
+ assertEquals(reference, event.getSource());
+ assertEquals(reference, event.getServiceReference());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void waitForEvent(List events, int type) throws InterruptedException
+ {
+ // Timeout for event delivery: 3 sec
+ int timeout = 30;
+
+ boolean eventFound = false;
+ while (eventFound == false && 0 < timeout)
+ {
+ synchronized (events)
+ {
+ events.wait(100);
+ for (Object aux : events)
+ {
+ if (aux instanceof BundleEvent)
+ {
+ BundleEvent event = (BundleEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof ServiceEvent)
+ {
+ ServiceEvent event = (ServiceEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof FrameworkEvent)
+ {
+ FrameworkEvent event = (FrameworkEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ }
+ }
+ timeout--;
+ }
+ }
+}
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java (from rev 96190, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General 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 License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.osgi;
+
+// $Id: $
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+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.launch.OSGiFramework;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A OSGiTestDelegate
+ *
+ * @author <a href="baileyje(a)gmail.com">John Bailey</a>
+ * @author Thomas.Diesler(a)jboss.com
+ */
+class FrameworkTestDelegate extends MicrocontainerTestDelegate
+{
+ private OSGiBundleManager bundleManager;
+
+ /**
+ * Create a new OSGiTestDelegate.
+ */
+ FrameworkTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ OSGiBundleManager getBundleManager()
+ {
+ if (bundleManager == null)
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ OSGiFramework framework = (OSGiFramework)factory.newFramework(null);
+ try
+ {
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+ bundleManager = framework.getBundleManager();
+ }
+ return bundleManager;
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param root the location to deploy
+ * @param child the child to deploy
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ Bundle addBundle(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);
+ AbstractBundleState bundleState = getBundleManager().install(childResource);
+ return bundleState.getBundleInternal();
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ Bundle addBundle(VirtualFile file) throws Exception
+ {
+ AbstractBundleState bundleState = getBundleManager().install(file);
+ return bundleState.getBundleInternal();
+ }
+
+ /**
+ * Remove a bundle
+ *
+ * @param bundle the bundle to remove
+ * @throws Exception for any error
+ */
+ void uninstall(Bundle bundle) throws Exception
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ getBundleManager().uninstall(bundle);
+ }
+
+ DeploymentUnit getDeploymentUnit(Bundle bundle)
+ {
+ DeploymentUnit deploymentUnit = getBundleManager().getDeployment(bundle.getBundleId());
+ if (deploymentUnit == null)
+ throw new AssertionFailedError("Bundle not installed: " + bundle);
+ return deploymentUnit;
+ }
+
+ Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+ {
+ return assembleBundle(name, new String[] { resources }, packages);
+ }
+
+ 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);
+ return addBundle(assembledDirectory);
+ }
+
+ AssembledDirectory createAssembledDirectory(String name) throws Exception
+ {
+ return createAssembledDirectory(name, "");
+ }
+
+ AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
+ {
+ return AssembledDirectory.createAssembledDirectory(name, rootName);
+ }
+
+ void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ {
+ String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
+ dir.addResources(reference, new String[] { packagePath + "/*.class" } , new String[0]);
+ }
+
+ void addPath(final AssembledDirectory dir, String path, String name) throws Exception
+ {
+ URL url = getClass().getResource(path);
+ if (url == null)
+ throw new AssertionFailedError(path + " not found");
+
+ VirtualFile file = VFS.getVirtualFile(url, name);
+ // TODO - remove this filter after new VFS relase
+ SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
+ dir.addPath(file, noJars);
+ }
+
+ URL getBundleResource(Bundle bundle, String path)
+ {
+ return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
+ }
+
+ Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
+ {
+ return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
+ }
+}
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -1,572 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.osgi;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-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.spi.util.ConstantsHelper;
-import org.jboss.test.AbstractTestDelegate;
-import org.jboss.test.kernel.junit.MicrocontainerTest;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.SynchronousBundleListener;
-
-/**
- * OSGiTestCase - Parent Test Case for OSGi tests.
- *
- * @author <a href="baileyje(a)gmail.com">John Bailey</a>
- * @version $Revision: 87848 $
- */
-public abstract class OSGiTestCase extends MicrocontainerTest implements FrameworkListener, SynchronousBundleListener, ServiceListener
-{
- private List<FrameworkEvent> frameworkEvents = new CopyOnWriteArrayList<FrameworkEvent>();
- private List<BundleEvent> bundleEvents = new CopyOnWriteArrayList<BundleEvent>();
- private List<ServiceEvent> serviceEvents = new CopyOnWriteArrayList<ServiceEvent>();
-
- /**
- * Create a new OSGiTestCase.
- *
- * @param name the test name
- */
- public OSGiTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Get the AbstractTestDelegate
- *
- * @param clazz the test class
- * @return The AbstractTestDelegate
- * @throws Exception for any error
- */
- public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
- {
- OSGiTestDelegate delegate = new OSGiTestDelegate(clazz);
- //delegate.enableSecurity = true;
- return delegate;
- }
-
- /**
- * Get OSGiTestDelegate
- */
- protected OSGiTestDelegate getDelegate()
- {
- return (OSGiTestDelegate)super.getDelegate();
- }
-
- /**
- * Get BundleManager from Delegate
- *
- * @return The BundleManager
- */
- protected OSGiBundleManager getBundleManager()
- {
- return getDelegate().getBundleManager();
- }
-
- /**
- * Get the system bundle
- *
- * @return the system bundle
- */
- protected Bundle getSystemBundle()
- {
- return getBundleManager().getBundleById(0).getBundleInternal();
- }
-
- /**
- * Add the base bundles
- *
- * @param expected the collection to add to
- */
- protected void addBaseBundles(Collection<Bundle> expected)
- {
- expected.add(getSystemBundle());
- }
-
- /**
- * 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 addBundle(String root, String child) throws Exception
- {
- return getDelegate().addBundle(root, child);
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle addBundle(VirtualFile file) throws Exception
- {
- return getDelegate().addBundle(file);
- }
-
- /**
- * Remove a bundle
- *
- * @param bundle the bundle to remove
- * @throws Exception for any error
- */
- protected void uninstall(Bundle bundle) throws Exception
- {
- getDelegate().uninstall(bundle);
- }
-
- protected DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- return getDelegate().getDeploymentUnit(bundle);
- }
-
- protected Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
- {
- return getDelegate().assembleBundle(name, new String[] { resources }, packages);
- }
-
- protected Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
- {
- return getDelegate().assembleBundle(name, resourcePaths, packages);
- }
-
- protected AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return getDelegate().createAssembledDirectory(name, "");
- }
-
- protected AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
- {
- return getDelegate().createAssembledDirectory(name, rootName);
- }
-
- protected void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
- {
- getDelegate().addPackage(dir, reference);
- }
-
- protected void addPath(final AssembledDirectory dir, String path, String name) throws Exception
- {
- getDelegate().addPath(dir, path, name);
- }
-
- protected void assertClassEquality(Class<?> expected, Class<?> actual)
- {
- assertTrue("Should be the same " + ClassLoaderUtils.classToString(expected) + " and " + ClassLoaderUtils.classToString(actual), expected == actual);
- }
-
- protected void assertNoClassEquality(Class<?> expected, Class<?> actual)
- {
- assertTrue("Should NOT be the same " + ClassLoaderUtils.classToString(expected) + " and " + ClassLoaderUtils.classToString(actual), expected != actual);
- }
-
- protected void assertClassLoader(Class<?> clazz, Bundle expected)
- {
- if (expected == null)
- return;
- ClassLoader cl = clazz.getClassLoader();
- ClassLoader bundleClassLoader = getBundleClassLoader(expected);
- boolean result = bundleClassLoader.equals(cl);
- assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected classloader=" + expected, result);
- }
-
- protected ClassLoader getBundleClassLoader(Bundle expected)
- {
- return getDeploymentUnit(expected).getClassLoader();
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference) throws Exception
- {
- return assertLoadClass(start, reference, start);
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference, Bundle expected) throws Exception
- {
- return assertLoadClass(start, reference, expected, false);
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference, Bundle expected, boolean isReference) throws Exception
- {
- Class<?> result = assertLoadClass(reference.getName(), start, expected);
- if (isReference)
- assertClassEquality(reference, result);
- else
- assertNoClassEquality(reference, result);
- return result;
- }
-
- protected Class<?> assertLoadClass(String name, Bundle bundle, Bundle expected)
- {
- Class<?> result = null;
- try
- {
- result = bundle.loadClass(name);
- getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + bundle);
- }
- catch (ClassNotFoundException e)
- {
- failure("Did not expect CNFE for " + name + " from " + bundle, e);
- }
- assertClassLoader(result, expected);
- return result;
- }
-
- protected void assertLoadClassFail(Bundle start, Class<?> reference)
- {
- assertLoadClassFail(start, reference.getName());
- }
-
- protected void assertLoadClassFail(Bundle start, String name)
- {
- try
- {
- start.loadClass(name);
- fail("Should not be here!");
- }
- catch (Exception expected)
- {
- checkThrowable(ClassNotFoundException.class, expected);
- }
- }
-
- protected URL getBundleResource(Bundle bundle, String path)
- {
- return getDelegate().getBundleResource(bundle, path);
- }
-
- protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
- {
- return getDelegate().getBundleResources(bundle, path);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws Exception
- {
- assertNoAllReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + " filter=" + filter, actual);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz, ServiceReference... expected) throws Exception
- {
- assertAllReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz, String filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
- assertEquals(bundleContext + " with clazz=" + clazz + " filter=" + filter, expected, actual);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz) throws Exception
- {
- assertNoReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz, String filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + " filter=" + filter, actual);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz, ServiceReference... expected) throws Exception
- {
- assertReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz, String filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz + " filter=" + filter);
- assertEquals(bundleContext + " with clazz=" + clazz + " filter=" + filter, expected, actual);
- }
-
- protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- getLog().debug(bundleContext + " got " + actual + " for clazz=" + clazz);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
- assertNull("Expected no references for clazz=" + clazz, actual);
- }
-
- protected void assertGetReference(BundleContext bundleContext, String clazz, ServiceReference expected) throws Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) + " for clazz=" + clazz);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
- assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
- }
-
- protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
- {
- Set<Bundle> expected = new HashSet<Bundle>();
- for (Bundle bundle : bundles)
- expected.add(bundle);
-
- Set<Bundle> actual = new HashSet<Bundle>();
- Bundle[] users = reference.getUsingBundles();
- if (users != null)
- for (Bundle bundle : users)
- actual.add(bundle);
-
- getLog().debug(reference + " users=" + actual);
-
- assertEquals(expected, actual);
- }
-
- protected void assertObjectClass(String expected, ServiceReference reference)
- {
- assertObjectClass(new String[] { expected }, reference);
- }
-
- protected void assertObjectClass(String[] expected, ServiceReference reference)
- {
- Object actual = reference.getProperty(Constants.OBJECTCLASS);
- if (actual == null)
- fail("no object class???");
- if (actual instanceof String[] == false)
- fail(actual + " is not a string array??? " + actual.getClass().getName());
- assertEquals(expected, (String[])actual);
- }
-
- public void frameworkEvent(FrameworkEvent event)
- {
- synchronized (frameworkEvents)
- {
- getLog().debug("FrameworkEvent type=" + ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
- frameworkEvents.add(event);
- frameworkEvents.notifyAll();
- }
- }
-
- protected void assertNoFrameworkEvent() throws Exception
- {
- getLog().debug("frameworkEvents=" + frameworkEvents);
- assertEquals(0, frameworkEvents.size());
- }
-
- protected void assertFrameworkEvent(int type) throws Exception
- {
- assertFrameworkEvent(type, getSystemBundle(), null);
- }
-
- protected void assertFrameworkEvent(int type, Class<? extends Throwable> expectedThrowable) throws Exception
- {
- assertFrameworkEvent(type, getSystemBundle(), expectedThrowable);
- }
-
- protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends Throwable> expectedThrowable) throws Exception
- {
- waitForEvent(frameworkEvents, type);
- getLog().debug("frameworkEvents=" + frameworkEvents);
- int size = frameworkEvents.size();
- assertTrue("" + size, size > 0);
- FrameworkEvent event = frameworkEvents.remove(0);
- assertEquals(ConstantsHelper.frameworkEvent(type), ConstantsHelper.frameworkEvent(event.getType()));
- Throwable t = event.getThrowable();
- if (expectedThrowable == null)
- {
- if (t != null)
- {
- getLog().error("Unexpected error in Framework event: ", t);
- fail("Unexpected throwable: " + t);
- }
- }
- else
- {
- checkThrowable(BundleException.class, t);
- checkDeepThrowable(expectedThrowable, t);
- }
- assertEquals(bundle, event.getSource());
- assertEquals(bundle, event.getBundle());
- }
-
- public void bundleChanged(BundleEvent event)
- {
- synchronized (bundleEvents)
- {
- getLog().debug("BundleChanged type=" + ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
- bundleEvents.add(event);
- bundleEvents.notifyAll();
- }
- }
-
- protected void assertNoBundleEvent() throws Exception
- {
- getLog().debug("bundleEvents=" + bundleEvents);
- assertEquals(0, bundleEvents.size());
- }
-
- protected void assertBundleEvent(int type, Bundle bundle) throws Exception
- {
- waitForEvent(bundleEvents, type);
-
- getLog().debug("bundleEvents=" + bundleEvents);
- int size = bundleEvents.size();
- assertTrue("" + size, size > 0);
-
- if (bundle instanceof AbstractBundleState)
- bundle = ((AbstractBundleState)bundle).getBundle();
-
- BundleEvent foundEvent = null;
- for(int i=0; i < bundleEvents.size(); i++)
- {
- BundleEvent aux = bundleEvents.get(i);
- if (type == aux.getType())
- {
- if (bundle.equals(aux.getSource()) && bundle.equals(aux.getBundle()))
- {
- bundleEvents.remove(aux);
- foundEvent = aux;
- break;
- }
- }
- }
-
- if (foundEvent == null)
- fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + " from " + bundle);
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- synchronized (serviceEvents)
- {
- getLog().debug("ServiceChanged type=" + ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
- serviceEvents.add(event);
- serviceEvents.notifyAll();
- }
- }
-
- protected void assertNoServiceEvent() throws Exception
- {
- getLog().debug("serviceEvents=" + serviceEvents);
- assertEquals(0, serviceEvents.size());
- }
-
- protected void assertServiceEvent(int type, ServiceReference reference) throws Exception
- {
- waitForEvent(serviceEvents, type);
- getLog().debug("serviceEvents=" + serviceEvents);
- int size = serviceEvents.size();
- assertTrue("" + size, size > 0);
- ServiceEvent event = serviceEvents.remove(0);
- assertEquals(ConstantsHelper.serviceEvent(type), ConstantsHelper.serviceEvent(event.getType()));
- assertEquals(reference, event.getSource());
- assertEquals(reference, event.getServiceReference());
- }
-
- @SuppressWarnings("unchecked")
- private void waitForEvent(List events, int type) throws InterruptedException
- {
- // Timeout for event delivery: 3 sec
- int timeout = 30;
-
- boolean eventFound = false;
- while (eventFound == false && 0 < timeout)
- {
- synchronized (events)
- {
- events.wait(100);
- for (Object aux : events)
- {
- if (aux instanceof BundleEvent)
- {
- BundleEvent event = (BundleEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof ServiceEvent)
- {
- ServiceEvent event = (ServiceEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof FrameworkEvent)
- {
- FrameworkEvent event = (FrameworkEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- }
- }
- timeout--;
- }
- }
-}
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -1,187 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.osgi;
-
-// $Id: $
-
-import java.net.URL;
-import java.util.Enumeration;
-
-import junit.framework.AssertionFailedError;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-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.launch.OSGiFramework;
-import org.jboss.osgi.spi.util.ServiceLoader;
-import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.FrameworkFactory;
-
-/**
- * A OSGiTestDelegate
- *
- * @author <a href="baileyje(a)gmail.com">John Bailey</a>
- * @author Thomas.Diesler(a)jboss.com
- */
-public class OSGiTestDelegate extends MicrocontainerTestDelegate
-{
- private OSGiBundleManager bundleManager;
-
- /**
- * Create a new OSGiTestDelegate.
- */
- public OSGiTestDelegate(Class<?> clazz) throws Exception
- {
- super(clazz);
- }
-
- protected OSGiBundleManager getBundleManager()
- {
- if (bundleManager == null)
- {
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- OSGiFramework framework = (OSGiFramework)factory.newFramework(null);
- try
- {
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start framework", ex);
- }
- bundleManager = framework.getBundleManager();
- }
- return bundleManager;
- }
-
- /**
- * Create a bundle
- *
- * @param root the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- public Bundle addBundle(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);
- AbstractBundleState bundleState = getBundleManager().install(childResource);
- return bundleState.getBundleInternal();
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- public Bundle addBundle(VirtualFile file) throws Exception
- {
- AbstractBundleState bundleState = getBundleManager().install(file);
- return bundleState.getBundleInternal();
- }
-
- /**
- * Remove a bundle
- *
- * @param bundle the bundle to remove
- * @throws Exception for any error
- */
- public void uninstall(Bundle bundle) throws Exception
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- getBundleManager().uninstall(bundle);
- }
-
- protected DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- DeploymentUnit deploymentUnit = getBundleManager().getDeployment(bundle.getBundleId());
- if (deploymentUnit == null)
- throw new AssertionFailedError("Bundle not installed: " + bundle);
- return deploymentUnit;
- }
-
- public Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
- {
- return assembleBundle(name, new String[] { resources }, packages);
- }
-
- 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);
- return addBundle(assembledDirectory);
- }
-
- public AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return createAssembledDirectory(name, "");
- }
-
- public AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
- {
- return AssembledDirectory.createAssembledDirectory(name, rootName);
- }
-
- public void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
- {
- String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
- dir.addResources(reference, new String[] { packagePath + "/*.class" } , new String[0]);
- }
-
- public void addPath(final AssembledDirectory dir, String path, String name) throws Exception
- {
- URL url = getClass().getResource(path);
- if (url == null)
- throw new AssertionFailedError(path + " not found");
-
- VirtualFile file = VFS.getVirtualFile(url, name);
- // TODO - remove this filter after new VFS relase
- SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
- dir.addPath(file, noJars);
- }
-
- protected URL getBundleResource(Bundle bundle, String path)
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
- }
-
- protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
- }
-}
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -29,7 +29,7 @@
import java.util.Locale;
import java.util.Set;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
@@ -46,7 +46,7 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class BundleContextUnitTestCase extends OSGiTestCase
+public class BundleContextUnitTestCase extends FrameworkTestCase
{
public BundleContextUnitTestCase(String 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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -28,7 +28,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
/**
@@ -39,7 +39,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class BundleEntriesUnitTestCase extends OSGiTestCase
+public class BundleEntriesUnitTestCase extends FrameworkTestCase
{
public BundleEntriesUnitTestCase(String 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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -25,7 +25,7 @@
import java.util.Hashtable;
import java.util.jar.Attributes;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -38,7 +38,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class BundleUnitTestCase extends OSGiTestCase
+public class BundleUnitTestCase extends FrameworkTestCase
{
public BundleUnitTestCase(String 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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -36,7 +36,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class SystemBundleUnitTestCase extends OSGiTestCase
+public class SystemBundleUnitTestCase extends FrameworkTestCase
{
public SystemBundleUnitTestCase(String name)
{
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java (from rev 96188, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloading/BundleClassPathTest.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.test.osgi.classloader;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.test.osgi.classloader.support.a.A;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * BundleClassPathTest.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 07-Oct-2009
+ */
+public class BundleClassPathTest extends OSGiTest
+{
+ @Test
+ public void testBundleClassPath() throws Exception
+ {
+ OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+ framework.start();
+
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(getTestArchivePath("bundle-classpath.war"));
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ Class<?> clazz = bundle.loadClass(A.class.getName());
+ assertNotNull("Loaded class", clazz);
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ framework.stop();
+ }
+}
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.classloader;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
import org.osgi.framework.Bundle;
@@ -39,7 +39,7 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class ExportImportPackageUnitTestCase extends OSGiTestCase
+public class ExportImportPackageUnitTestCase extends FrameworkTestCase
{
public ExportImportPackageUnitTestCase(String 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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.classloader;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
import org.osgi.framework.Bundle;
@@ -34,7 +34,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class RequireBundleUnitTestCase extends OSGiTestCase
+public class RequireBundleUnitTestCase extends FrameworkTestCase
{
public RequireBundleUnitTestCase(String name)
{
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.b.B;
import org.osgi.framework.Bundle;
@@ -41,7 +41,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class GetServiceReferencesUnitTestCase extends OSGiTestCase
+public class GetServiceReferencesUnitTestCase extends FrameworkTestCase
{
public GetServiceReferencesUnitTestCase(String 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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.service;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.BrokenServiceFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -35,7 +35,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class GetUnGetServiceUnitTestCase extends OSGiTestCase
+public class GetUnGetServiceUnitTestCase extends FrameworkTestCase
{
static String OBJCLASS = BundleContext.class.getName();
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -38,7 +38,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class RegisterServiceUnitTestCase extends OSGiTestCase
+public class RegisterServiceUnitTestCase extends FrameworkTestCase
{
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -22,7 +22,7 @@
package org.jboss.test.osgi.service;
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -37,7 +37,7 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision$
*/
-public class ServiceFactoryUnitTestCase extends OSGiTestCase
+public class ServiceFactoryUnitTestCase extends FrameworkTestCase
{
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -28,7 +28,7 @@
import java.util.Set;
import java.util.TreeSet;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -43,7 +43,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ServiceReferenceUnitTestCase extends OSGiTestCase
+public class ServiceReferenceUnitTestCase extends FrameworkTestCase
{
public ServiceReferenceUnitTestCase(String name)
{
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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -23,7 +23,7 @@
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -38,7 +38,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ServiceRegistrationUnitTestCase extends OSGiTestCase
+public class ServiceRegistrationUnitTestCase extends FrameworkTestCase
{
public ServiceRegistrationUnitTestCase(String 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-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.io.InputStream;
import java.net.URL;
-import org.jboss.test.osgi.OSGiTestCase;
+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;
import org.jboss.test.osgi.smoke.support.c.C;
@@ -36,7 +36,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class OSGiSmokeTestCase extends OSGiTestCase
+public class OSGiSmokeTestCase extends FrameworkTestCase
{
public OSGiSmokeTestCase(String name)
{
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath (from rev 96188, projects/jboss-osgi/trunk/reactor/framework/src/test/resources/classloading/bundleclasspath)
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/web.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/classloading/bundleclasspath/web.xml 2009-11-09 19:04:43 UTC (rev 96188)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/web.xml 2009-11-09 19:47:51 UTC (rev 96193)
@@ -2,11 +2,9 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.4">
- <display-name>WebApp Sample</display-name>
-
<servlet>
<servlet-name>servlet</servlet-name>
- <servlet-class>org.jboss.test.osgi.classloading.EndpointServlet</servlet-class>
+ <servlet-class>org.jboss.test.osgi.classloader.some.servlet</servlet-class>
<init-param>
<param-name>initProp</param-name>
<param-value>SomeValue</param-value>
14 years, 6 months