[jboss-osgi-commits] JBoss-OSGI SVN: r96171 - in projects/jboss-osgi/trunk: reactor/framework and 16 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Mon Nov 9 08:52:42 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-11-09 08:52:41 -0500 (Mon, 09 Nov 2009)
New Revision: 96171
Added:
projects/jboss-osgi/trunk/distribution/docbook/src/main/graphics/jbossosgi-enterprise.odp
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/
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/
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/BundleCapability.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/NoFilter.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/FilterImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/NoFilter.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/model/
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/parser/
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/property/
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleRequirement.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/ds/
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/FrameworkUtil.java
projects/jboss-osgi/trunk/reactor/framework/src/main/resources/schema/
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloading/bundleclasspath/
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/filter/test/
Modified:
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/framework/scripts/assembly-bundles.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/bundle/OSGiBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.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/resolver/BundleResolverTest.java
Log:
Remove stale Version impl.
Remove stale DS impl.
Expand bundle resolver API
Added: projects/jboss-osgi/trunk/distribution/docbook/src/main/graphics/jbossosgi-enterprise.odp
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/distribution/docbook/src/main/graphics/jbossosgi-enterprise.odp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-09 13:52:41 UTC (rev 96171)
@@ -259,6 +259,11 @@
<artifactId>jboss-osgi-xml-binding</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-jetty-bundle</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: projects/jboss-osgi/trunk/reactor/framework/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/scripts/assembly-bundles.xml 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/scripts/assembly-bundles.xml 2009-11-09 13:52:41 UTC (rev 96171)
@@ -37,6 +37,7 @@
<include>*:org.apache.felix.configadmin:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.apache.felix.metatype:jar</include>
+ <include>*:pax-web-jetty-bundle:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>test</scope>
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-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -63,7 +63,6 @@
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
-import org.jboss.osgi.framework.filter.NoFilter;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
import org.jboss.osgi.framework.plugins.AutoInstallPlugin;
@@ -72,7 +71,9 @@
import org.jboss.osgi.framework.plugins.PackageAdminServicePlugin;
import org.jboss.osgi.framework.plugins.Plugin;
import org.jboss.osgi.framework.plugins.ServicePlugin;
-import org.jboss.osgi.framework.resolver.BundleResolver;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.osgi.framework.resolver.internal.basic.BasicResolverImpl;
+import org.jboss.osgi.framework.util.NoFilter;
import org.jboss.util.collection.ConcurrentSet;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
@@ -126,8 +127,8 @@
/** The os version */
private static String OSGi_FRAMEWORK_PROCESSOR;
- /** The bundles resolver */
- private BundleResolver bundleResolver;
+ /** The bundle resolver */
+ private Resolver bundleResolver;
/** The bundles by id */
private List<AbstractBundleState> bundles = new CopyOnWriteArrayList<AbstractBundleState>();
@@ -204,7 +205,7 @@
this.kernel = kernel;
this.deployerClient = deployerClient;
this.deployerStructure = (MainDeployerStructure)deployerClient;
- this.bundleResolver = new BundleResolver(this);
+ this.bundleResolver = new BasicResolverImpl();
// TODO thread factory
if (executor == null)
@@ -360,7 +361,7 @@
*
* @return the resolver
*/
- public BundleResolver getBundleResolver()
+ public Resolver getBundleResolver()
{
return bundleResolver;
}
@@ -640,6 +641,7 @@
}
bundleState.setBundleManager(this);
+ bundleResolver.addBundle(bundleState);
bundles.add(bundleState);
bundleState.changeState(Bundle.INSTALLED);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -389,4 +389,18 @@
if (rethrow != null)
throw rethrow;
}
+
+ public static OSGiBundleState assertBundleState(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Null bundle");
+
+ if (bundle instanceof OSGiBundleWrapper)
+ bundle = ((OSGiBundleWrapper)bundle).getBundleState();
+
+ if (bundle instanceof OSGiBundleState == false)
+ throw new IllegalArgumentException("Not an OSGiBundleState: " + bundle);
+
+ return (OSGiBundleState)bundle;
+ }
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -30,6 +30,7 @@
import org.jboss.classloading.spi.metadata.Requirement;
import org.jboss.classloading.spi.version.VersionRange;
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.bundle.OSGiBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
@@ -37,8 +38,11 @@
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
-import org.jboss.osgi.framework.resolver.BundleCapability;
-import org.jboss.osgi.framework.resolver.BundleResolver;
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.framework.resolver.internal.basic.BundleCapability;
+import org.jboss.osgi.framework.resolver.internal.basic.BasicResolverImpl;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -138,20 +142,32 @@
if (requirement instanceof OSGiPackageRequirement == false)
return true;
+ PackageRequirement packageRequirement = (PackageRequirement)requirement;
+
// Get the bundle resolver from the bundle manager
OSGiBundleManager bundleManager = bundleState.getBundleManager();
- BundleResolver bundleResolver = bundleManager.getBundleResolver();
+ Resolver bundleResolver = bundleManager.getBundleResolver();
- // True if capModule matches with the resolved module
- PackageRequirement packageRequirement = (PackageRequirement)requirement;
- BundleCapability bundleCapability = bundleResolver.getMatchingCapability(reqModule, packageRequirement);
- if (bundleCapability == null)
+ String location = reqModule.getContextName();
+ AbstractBundleState bundle = bundleManager.getBundleByLocation(location);
+ if (bundle == null)
+ {
+ // Is this an illegal state?
return false;
+ }
- Module capModule = getModule();
- Module otherCapModule = bundleCapability.getExportingModule();
- PackageCapability otherCapability = bundleCapability.getPackageCapability();
- boolean isMatch = (otherCapModule == capModule && otherCapability == this);
+ // Get the exporter for this requirement
+ ExportPackage exporter = bundleResolver.getExporter(bundle, packageRequirement.getName());
+ if (exporter == null)
+ return false;
+
+ // Get the exporters module
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(exporter.getOwner().getBundle());
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ Module otherCapModule = unit.getAttachment(Module.class);
+
+ String otherCapability = exporter.getName();
+ boolean isMatch = (otherCapModule == getModule() && otherCapability.equals(getName()));
return isMatch;
}
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/FilterImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/FilterImpl.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/FilterImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -1,108 +0,0 @@
-/*
-* 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.filter;
-
-import java.util.Dictionary;
-
-import org.jboss.osgi.framework.filter.model.Operation;
-import org.jboss.osgi.framework.filter.parser.FilterParser;
-import org.jboss.osgi.framework.filter.property.PropertySource;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-/**
- * FilterImpl.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class FilterImpl implements Filter
-{
- /** The operation */
- private Operation operation;
-
- /** The cached string */
- private String cachedString;
-
- /**
- * Create a new FilterImpl.
- *
- * @param filter the filter
- * @throws InvalidSyntaxException if the filter syntax is invalid
- */
- public FilterImpl(String filter) throws InvalidSyntaxException
- {
- if (filter == null)
- throw new InvalidSyntaxException("Null filter", "?");
-
- FilterParser parser = new FilterParser();
- this.operation = parser.parse(filter);
- }
-
- @SuppressWarnings("unchecked")
- public boolean match(Dictionary dictionary)
- {
- return operation.match(PropertySource.fromDictionary(dictionary, false));
- }
-
- public boolean match(ServiceReference reference)
- {
- return operation.match(PropertySource.fromServiceReference(reference));
- }
-
- @SuppressWarnings("unchecked")
- public boolean matchCase(Dictionary dictionary)
- {
- return operation.match(PropertySource.fromDictionary(dictionary, true));
- }
-
- @Override
- public String toString()
- {
- if (cachedString == null)
- {
- StringBuilder builder = new StringBuilder();
- builder.append('(');
- operation.toString(builder);
- builder.append(')');
- cachedString = builder.toString();
- }
- return cachedString;
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof Filter == false)
- return false;
- return toString().equals(obj.toString());
- }
-}
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/NoFilter.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/NoFilter.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/NoFilter.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -1,63 +0,0 @@
-/*
-* 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.filter;
-
-import java.util.Dictionary;
-
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Dummy filter implementation
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class NoFilter implements Filter
-{
- /** Singleton instance */
- public static final Filter INSTANCE = new NoFilter();
-
- /**
- * Singleton
- */
- private NoFilter()
- {
- }
-
- @SuppressWarnings("unchecked")
- public boolean match(Dictionary dictionary)
- {
- return true;
- }
-
- public boolean match(ServiceReference reference)
- {
- return true;
- }
-
- @SuppressWarnings("unchecked")
- public boolean matchCase(Dictionary dictionary)
- {
- return true;
- }
-}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -52,6 +52,11 @@
this.bundleManager = bundleManager;
}
+ public OSGiBundleManager getBundleManager()
+ {
+ return bundleManager;
+ }
+
public void init() throws BundleException
{
bundleManager.initFramework();
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -40,8 +40,8 @@
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiServiceState;
-import org.jboss.osgi.framework.filter.NoFilter;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
+import org.jboss.osgi.framework.util.NoFilter;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.framework.resolver;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.classloading.plugins.metadata.PackageCapability;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.classloading.OSGiPackageCapability;
-import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
-
-/**
- * An association of bundle/capability.
- *
- * @author thomas.diesler at jboss.com
- * @since 10-Sep-2009
- */
-public class BundleCapability
-{
- private OSGiBundleState bundle;
- private PackageCapability packageCapability;
- private List<BundleRequirement> wires;
-
- BundleCapability(OSGiBundleState bundle, PackageCapability packageCapability)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
- if (packageCapability == null)
- throw new IllegalArgumentException("Null packageCapability");
-
- this.bundle = bundle;
- this.packageCapability = packageCapability;
- }
-
- public OSGiBundleState getExportingBundle()
- {
- return bundle;
- }
-
- public Module getExportingModule()
- {
- OSGiBundleState bundleState = BundleResolver.assertBundleState(bundle);
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- return unit.getAttachment(Module.class);
- }
-
- public PackageCapability getPackageCapability()
- {
- return packageCapability;
- }
-
- public List<BundleRequirement> getWiredRequirements()
- {
- if (wires == null)
- return Collections.emptyList();
-
- return Collections.unmodifiableList(wires);
- }
-
- boolean matches(BundleRequirement bundleRequirement)
- {
- OSGiPackageCapability osgiPackageCapability = (OSGiPackageCapability)packageCapability;
- OSGiPackageRequirement osgiPackageRequirement = (OSGiPackageRequirement)bundleRequirement.getPackageRequirement();
- return osgiPackageCapability.match(osgiPackageRequirement);
- }
-
- void wireRequirement(BundleRequirement bundleRequirement)
- {
- if (wires == null)
- wires = new CopyOnWriteArrayList<BundleRequirement>();
-
- wires.add(bundleRequirement);
- }
-
- void unwireRequirement(BundleRequirement bundleRequirement)
- {
- if (wires != null)
- wires.remove(bundleRequirement);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof BundleCapability == false)
- return false;
- if (obj == this)
- return true;
- return toString().equals(obj.toString());
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public String toString()
- {
- String name = packageCapability.getName();
- return "BundleCapability[" + name + "," + bundle + "]";
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleRequirement.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleRequirement.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleRequirement.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.framework.resolver;
-
-import org.jboss.classloading.plugins.metadata.PackageRequirement;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-
-/**
- * An association of bundle/requirement.
- *
- * @author thomas.diesler at jboss.com
- * @since 10-Sep-2009
- */
-public class BundleRequirement
-{
- private OSGiBundleState bundle;
- private PackageRequirement packageRequirement;
- private BundleCapability wire;
-
- BundleRequirement(OSGiBundleState bundle, PackageRequirement packageRequirement)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
- if (packageRequirement == null)
- throw new IllegalArgumentException("Null packageRequirement");
-
- this.bundle = bundle;
- this.packageRequirement = packageRequirement;
- }
-
- public BundleCapability getWiredCapability()
- {
- return wire;
- }
-
- public OSGiBundleState getImportingBundle()
- {
- return bundle;
- }
-
- public PackageRequirement getPackageRequirement()
- {
- return packageRequirement;
- }
-
- void wireCapability(BundleCapability bundleCapability)
- {
- wire = bundleCapability;
- if (bundleCapability != null)
- bundleCapability.wireRequirement(this);
- }
-
- void unwireCapability()
- {
- if (wire != null)
- {
- wire.unwireRequirement(this);
- wire = null;
- }
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof BundleRequirement == false)
- return false;
- if (obj == this)
- return true;
- return toString().equals(obj.toString());
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public String toString()
- {
- String name = packageRequirement.getName();
- return "BundleRequirement[" + name + "," + bundle + "]";
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -1,461 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.framework.resolver;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.jboss.classloading.plugins.metadata.PackageCapability;
-import org.jboss.classloading.plugins.metadata.PackageRequirement;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.metadata.Capability;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.classloading.spi.version.VersionRange;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
-import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-
-/**
- * The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
- *
- * @author thomas.diesler at jboss.com
- * @since 10-Sep-2009
- */
-public class BundleResolver
-{
- /** The log */
- private static final Logger log = Logger.getLogger(BundleResolver.class);
-
- private OSGiBundleManager bundleManager;
- private Map<OSGiBundleState, List<BundleCapability>> bundleCapabilitiesMap = new ConcurrentHashMap<OSGiBundleState, List<BundleCapability>>();
- private Map<OSGiBundleState, List<BundleRequirement>> bundleRequirementsMap = new ConcurrentHashMap<OSGiBundleState, List<BundleRequirement>>();
-
- public BundleResolver(OSGiBundleManager bundleManager)
- {
- this.bundleManager = bundleManager;
- }
-
- /**
- * Resolve the given list of bundles.
- *
- * This is an iterative process that tries to wire BundleRequirements to BundleCapabilities.
- *
- * @param bundles the bundles to resolve
- * @return The list of resolved bundles in the resolve order or an empty list
- */
- public List<OSGiBundleState> resolveBundles(List<Bundle> bundles)
- {
- if (bundles == null)
- throw new IllegalArgumentException("Null bundles");
-
- // Normalize to OSGiBundleState instances
- List<OSGiBundleState> unresolvedBundles = new ArrayList<OSGiBundleState>();
- for (Bundle bundle : bundles)
- {
- unresolvedBundles.add(assertBundleState(bundle));
- }
-
- int resolved = 1;
- int resolveRounds = 0;
-
- // Get the list of all capabilities
- List<BundleCapability> allCapabilities = new ArrayList<BundleCapability>();
- for (List<BundleCapability> list : bundleCapabilitiesMap.values())
- {
- allCapabilities.addAll(list);
- }
-
- List<OSGiBundleState> resolvedBundles = new ArrayList<OSGiBundleState>();
- while (resolved > 0 && unresolvedBundles.isEmpty() == false)
- {
- resolveRounds++;
-
- log.debug("#" + resolveRounds + " *****************************************************************");
- log.debug("Unresolved bundles: " + unresolvedBundles);
-
- resolved = 0;
- Iterator<OSGiBundleState> it = unresolvedBundles.iterator();
- while (it.hasNext())
- {
- OSGiBundleState bundleState = it.next();
- log.debug("Resolving: " + bundleState);
- if (resolveBundle(allCapabilities, bundleState))
- {
- resolvedBundles.add(bundleState);
- it.remove();
- resolved++;
- }
- }
- }
-
- log.debug("END *****************************************************************");
-
- // Log the unresolved bundles
- for (OSGiBundleState bundle : unresolvedBundles)
- {
- StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
- message.append("\n Cannot find exporter for");
- List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
- for (BundleRequirement requirement : bundleRequirements)
- {
- PackageRequirement packreq = requirement.getPackageRequirement();
- BundleCapability bestMatch = findBestMatch(allCapabilities, requirement);
- if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
- {
- message.append("\n " + packreq.getName() + ";version=" + packreq.getVersionRange());
- }
- }
- log.debug(message);
- }
-
- return resolvedBundles;
- }
-
- public void removeBundle(Bundle bundle)
- {
- OSGiBundleState bundleState = assertBundleState(bundle);
-
- bundleCapabilitiesMap.remove(bundleState);
-
- List<BundleRequirement> bundleRequirements = bundleRequirementsMap.remove(bundleState);
- if (bundleRequirements != null)
- {
- for (BundleRequirement requirement : bundleRequirements)
- {
- requirement.unwireCapability();
- }
- }
- }
-
- public BundleCapability getMatchingCapability(Module module, PackageRequirement packageRequirement)
- {
- String location = module.getContextName();
- AbstractBundleState bundle = bundleManager.getBundleByLocation(location);
- if (bundle == null)
- return null;
-
- List<BundleRequirement> requirements = bundleRequirementsMap.get(bundle);
- if (requirements == null)
- return null;
-
- BundleCapability result = null;
- for (BundleRequirement req : requirements)
- {
- if (req.getPackageRequirement() == packageRequirement)
- {
- result = req.getWiredCapability();
- break;
- }
- }
-
- return result;
- }
-
- private boolean resolveBundle(List<BundleCapability> allCapabilities, OSGiBundleState bundle)
- {
- List<BundleCapability> bundleCapabilities = getBundleCapabilities(bundle);
- List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
-
- List<BundleCapability> futureCapabilities = new ArrayList<BundleCapability>(allCapabilities);
- futureCapabilities.addAll(bundleCapabilities);
-
- for (BundleRequirement requirement : bundleRequirements)
- {
- PackageRequirement packreq = requirement.getPackageRequirement();
-
- BundleCapability bestMatch = findBestMatch(futureCapabilities, requirement);
- if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
- return false;
-
- requirement.wireCapability(bestMatch);
- }
-
- // Remove optional or dynamic requirements that don't have a wire
- Iterator<BundleRequirement> it = bundleRequirements.iterator();
- while (it.hasNext())
- {
- if (it.next().getWiredCapability() == null)
- it.remove();
- }
-
- if (processRequiredBundle(bundle, bundleCapabilities, bundleRequirements) == false)
- return false;
-
- allCapabilities.addAll(bundleCapabilities);
- bundleCapabilitiesMap.put(bundle, bundleCapabilities);
- bundleRequirementsMap.put(bundle, bundleRequirements);
-
- logResolvedBundleInfo(bundle, bundleCapabilities, bundleRequirements);
-
- return true;
- }
-
- /**
- * Logs information about a resolved bundle
- */
- private void logResolvedBundleInfo(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
- {
- // Log the package wiring information
- StringBuffer message = new StringBuffer("Resolved: " + bundle);
-
- // Log the exports
- int nameLengthMax = 0;
- for (BundleCapability capability : bundleCapabilities)
- {
- PackageCapability packcap = capability.getPackageCapability();
- String packNameVersion = packcap.getName() + ";version=" + packcap.getVersion();
- nameLengthMax = Math.max(nameLengthMax, packNameVersion.length());
- }
- if (bundleCapabilities.isEmpty() == false)
- {
- message.append("\n Exports");
- List<String> lines = new ArrayList<String>();
- for (BundleCapability capability : bundleCapabilities)
- {
- PackageCapability packcap = capability.getPackageCapability();
- String packNameVersion = packcap.getName() + ";version=" + packcap.getVersion();
- lines.add("\n " + packNameVersion);
- }
- Collections.sort(lines);
- for (String line : lines)
- message.append(line);
- }
-
- // Log the imports
- nameLengthMax = 0;
- for (BundleRequirement requirement : bundleRequirements)
- {
- PackageRequirement packreq = requirement.getPackageRequirement();
- String packNameVersion = packreq.getName() + ";version=" + packreq.getVersionRange();
- nameLengthMax = Math.max(nameLengthMax, packNameVersion.length());
- }
- if (bundleRequirements.isEmpty() == false)
- {
- message.append("\n Imports");
- List<String> lines = new ArrayList<String>();
- for (BundleRequirement requirement : bundleRequirements)
- {
- PackageRequirement packreq = requirement.getPackageRequirement();
- String packNameVersion = packreq.getName() + ";version=" + packreq.getVersionRange();
- StringBuffer line = new StringBuffer("\n " + packNameVersion);
- for (int i = 0; i < (nameLengthMax - packNameVersion.length()); i++)
- line.append(" ");
-
- BundleCapability wire = requirement.getWiredCapability();
- if (wire == null)
- {
- line.append(" <= null");
- }
- else
- {
- Bundle wireBundle = wire.getExportingBundle();
- PackageCapability wireCap = wire.getPackageCapability();
- packNameVersion = wireCap.getName() + ";version=" + wireCap.getVersion();
- line.append(" <= " + wireBundle + " " + packNameVersion);
- }
- lines.add(line.toString());
- }
- Collections.sort(lines);
- for (String line : lines)
- message.append(line);
- }
- log.debug(message);
- }
-
- private BundleCapability findBestMatch(List<BundleCapability> capabilities, BundleRequirement requirement)
- {
- BundleCapability result = null;
- for (BundleCapability capability : capabilities)
- {
- if (capability.matches(requirement))
- {
- if (result == null)
- {
- result = capability;
- }
- else
- {
- // [TODO] handle multiple matches
- }
- }
- }
- return result;
- }
-
- /**
- * Get the set of bundle capabilities
- */
- private List<BundleCapability> getBundleCapabilities(OSGiBundleState bundle)
- {
- List<BundleCapability> result = new ArrayList<BundleCapability>();
-
- OSGiBundleState bundleState = assertBundleState(bundle);
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- ClassLoadingMetaData metadata = unit.getAttachment(ClassLoadingMetaData.class);
-
- List<Capability> capabilities = metadata.getCapabilities().getCapabilities();
- if (capabilities != null)
- {
- for (Capability capability : capabilities)
- {
- if (capability instanceof PackageCapability)
- {
- PackageCapability packageCapability = (PackageCapability)capability;
- result.add(new BundleCapability(bundle, packageCapability));
- }
- }
- }
- return result;
- }
-
- /**
- * Get the set of bundle requirements
- */
- private List<BundleRequirement> getBundleRequirements(OSGiBundleState bundle)
- {
- List<BundleRequirement> result = new ArrayList<BundleRequirement>();
-
- OSGiBundleState bundleState = assertBundleState(bundle);
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- ClassLoadingMetaData classloadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
-
- List<Requirement> requirements = classloadingMetaData.getRequirements().getRequirements();
- if (requirements != null)
- {
- for (Requirement requirement : requirements)
- {
- if (requirement instanceof PackageRequirement)
- {
- PackageRequirement packageRequirement = (PackageRequirement)requirement;
- result.add(new BundleRequirement(bundle, packageRequirement));
- }
- }
- }
-
- return result;
- }
-
- private boolean processRequiredBundle(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
- {
- // The Require-Bundle header specifies that all exported packages from
- // another bundle must be imported, effectively requiring the public interface
- // of another bundle
- OSGiMetaData osgiMetaData = bundle.getOSGiMetaData();
- List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
- if (requireBundles != null)
- {
- for (ParameterizedAttribute attr : requireBundles)
- {
- String requiredBundleName = attr.getAttribute();
- if (requiredBundleName == null)
- throw new IllegalStateException("Cannot obtain value for: " + Constants.REQUIRE_BUNDLE);
-
- String visibility = Constants.VISIBILITY_PRIVATE;
- Parameter param = attr.getParameter(Constants.VISIBILITY_DIRECTIVE);
- if (param != null)
- visibility = (String)param.getValue();
-
- String resolution = Constants.RESOLUTION_MANDATORY;
- param = attr.getParameter(Constants.RESOLUTION_DIRECTIVE);
- if (param != null)
- resolution = (String)param.getValue();
-
- // [TODO] bundle-version
- //String bundleVersion = null;
- //param = attr.getParameter(Constants.BUNDLE_VERSION_ATTRIBUTE);
- //if (param != null)
- // bundleVersion = (String)param.getValue();
-
- if (Constants.RESOLUTION_MANDATORY.equals(resolution))
- {
- Bundle requiredBundle = getRequiredBundle(requiredBundleName);
- if (requiredBundle == null)
- {
- log.debug("Cannot find " + resolution + " required bundle: " + requiredBundleName);
- return false;
- }
-
- List<BundleCapability> otherCapabilities = bundleCapabilitiesMap.get(requiredBundle);
- for (BundleCapability otherCapability : otherCapabilities)
- {
- PackageCapability otherPackage = otherCapability.getPackageCapability();
- String packageName = otherPackage.getName();
- Object version = otherPackage.getVersion();
- VersionRange versionRange = new VersionRange(version, true, version, true);
-
- OSGiPackageRequirement newPackageRequirement = new OSGiPackageRequirement(bundle, packageName, versionRange, null);
- BundleRequirement newBundleRequirement = new BundleRequirement(bundle, newPackageRequirement);
- newBundleRequirement.wireCapability(otherCapability);
- bundleRequirements.add(newBundleRequirement);
-
- if (Constants.VISIBILITY_REEXPORT.equals(visibility))
- {
- BundleCapability newBundleCapability = new BundleCapability(bundle, otherPackage);
- bundleCapabilities.add(newBundleCapability);
- }
- }
- }
- else if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
- {
- // [TODO] resolution=optional
- }
- }
- }
-
- return true;
- }
-
- private Bundle getRequiredBundle(String requiredBundle)
- {
- for (Bundle bundle : bundleCapabilitiesMap.keySet())
- {
- if (bundle.getSymbolicName().equals(requiredBundle))
- return bundle;
- }
- return null;
- }
-
- static OSGiBundleState assertBundleState(Bundle bundle)
- {
- if (bundle instanceof OSGiBundleWrapper)
- bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-
- if (bundle instanceof OSGiBundleState == false)
- throw new IllegalArgumentException("Cannot obtain bunde state from: " + bundle);
-
- return (OSGiBundleState)bundle;
- }
-}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,47 @@
+/*
+ * 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.List;
+import java.util.Set;
+
+import org.osgi.framework.Version;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public interface ExportPackage extends NamedPackage
+{
+ Version getVersion();
+
+ List<NamedPackage> getUses();
+
+ Set<ImportPackage> getImporters();
+
+ List<String> getMandatoryAttributes();
+
+ List<String> getIncludes();
+
+ List<String> getExcludes();
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ExportPackage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,43 @@
+/*
+ * 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 org.jboss.osgi.framework.metadata.VersionRange;
+import org.osgi.framework.Version;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public interface ImportPackage extends NamedPackage
+{
+ ExportPackage getExporter();
+
+ VersionRange getVersion();
+
+ String getResolution();
+
+ String getBundleSymbolicName();
+
+ Version getBundleVersion();
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/ImportPackage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,39 @@
+/*
+ * 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.Map;
+
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public interface NamedPackage
+{
+ Resolvable getOwner();
+
+ String getName();
+
+ Map<String, String> getAttributes();
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/NamedPackage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,53 @@
+/*
+ * 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.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public interface Resolvable
+{
+ Bundle getBundle();
+
+ String getSymbolicName();
+
+ Version getVersion();
+
+ List<ExportPackage> getExportPackages();
+
+ ExportPackage getExportPackage(String packageName);
+
+ List<ImportPackage> getImportPackages();
+
+ ImportPackage getImportPackage(String packageName);
+
+ boolean isSingleton();
+
+ boolean isResolved();
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolvable.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,44 @@
+/*
+ * 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.List;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public interface Resolver
+{
+ List<Resolvable> getBundles();
+
+ Resolvable addBundle(Bundle bundle);
+
+ Resolvable removeBundle(Bundle bundle);
+
+ List<Resolvable> resolve(List<Bundle> bundles);
+
+ ExportPackage getExporter(Bundle bundle, String importPackage);
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/Resolver.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,75 @@
+/*
+ * 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 java.util.List;
+import java.util.Set;
+
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.ImportPackage;
+import org.jboss.osgi.framework.resolver.NamedPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Version;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public class ExportPackageImpl extends NamedPackageImpl implements ExportPackage
+{
+ public ExportPackageImpl(Resolvable owner, String packageName)
+ {
+ super(owner, packageName);
+ }
+
+ public List<String> getExcludes()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Set<ImportPackage> getImporters()
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<String> getIncludes()
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<String> getMandatoryAttributes()
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<NamedPackage> getUses()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Version getVersion()
+ {
+ 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/ExportPackageImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedPackageImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,60 @@
+/*
+ * 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 java.util.Map;
+
+import org.jboss.osgi.framework.resolver.NamedPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.spi.NotImplementedException;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public class NamedPackageImpl implements NamedPackage
+{
+ private Resolvable owner;
+ private String packageName;
+
+ public NamedPackageImpl(Resolvable owner, String packageName)
+ {
+ this.owner = owner;
+ this.packageName = packageName;
+ }
+
+ public Resolvable getOwner()
+ {
+ return owner;
+ }
+
+ public String getName()
+ {
+ return packageName;
+ }
+
+ public Map<String, String> getAttributes()
+ {
+ 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/NamedPackageImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,120 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+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.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;
+
+/**
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Noc-2009
+ */
+public class ResolvableImpl implements Resolvable
+{
+ private OSGiBundleState bundle;
+ private OSGiMetaData metaData;
+ private boolean resolved;
+
+ private Map<String, ExportPackage> exportedPackages = new LinkedHashMap<String, ExportPackage>();
+
+ public ResolvableImpl(Bundle bundle)
+ {
+ this.bundle = OSGiBundleState.assertBundleState(bundle);
+ this.metaData = ((OSGiBundleState)bundle).getOSGiMetaData();
+
+ // Initialize exported packages
+ List<PackageAttribute> exportPackages = metaData.getExportPackages();
+ if (exportPackages != null)
+ {
+ for (PackageAttribute attr: exportPackages)
+ {
+ String packageName = attr.getPackageInfo().getName();
+ exportedPackages.put(packageName, new ExportPackageImpl(this, packageName));
+ }
+ }
+ }
+
+ public Bundle getBundle()
+ {
+ return bundle;
+ }
+
+ public String getSymbolicName()
+ {
+ return bundle.getSymbolicName();
+ }
+
+ public Version getVersion()
+ {
+ return bundle.getVersion();
+ }
+
+ public ExportPackage getExportPackage(String packageName)
+ {
+ return exportedPackages.get(packageName);
+ }
+
+ public List<ExportPackage> getExportPackages()
+ {
+ List<ExportPackage> values = new ArrayList<ExportPackage>(exportedPackages.values());
+ return Collections.unmodifiableList(values);
+ }
+
+ public ImportPackage getImportPackage(String name)
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<ImportPackage> getImportPackages()
+ {
+ throw new NotImplementedException();
+ }
+
+ public boolean isResolved()
+ {
+ return resolved;
+ }
+
+ public void setResolved(boolean resolved)
+ {
+ this.resolved = resolved;
+ }
+
+ public boolean isSingleton()
+ {
+ return bundle.getOSGiMetaData().isSingleton();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java (from rev 96066, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,484 @@
+/*
+ * 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.basic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.classloading.plugins.metadata.PackageCapability;
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.version.VersionRange;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.Parameter;
+import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.osgi.framework.resolver.internal.ResolvableImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Sep-2009
+ */
+public class BasicResolverImpl implements Resolver
+{
+ /** 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>>();
+
+ public List<Resolvable> getBundles()
+ {
+ List<Resolvable> values = new ArrayList<Resolvable>(resolverBundleMap.values());
+ return Collections.unmodifiableList(values);
+ }
+
+ public Resolvable addBundle(Bundle bundle)
+ {
+ // [TODO] remove this restriction
+ if (bundle.getBundleId() == 0)
+ return null;
+
+ 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);
+ if (resBundle == null)
+ throw new IllegalStateException("Cannot obtain bundle for: " + aux);
+ resolvedBundles.add(resBundle);
+ }
+ return Collections.unmodifiableList(resolvedBundles);
+ }
+
+ /**
+ * Resolve the given list of bundles.
+ *
+ * This is an iterative process that tries to wire BundleRequirements to BundleCapabilities.
+ *
+ * @param bundles the bundles to resolve
+ * @return The list of resolved bundles in the resolve order or an empty list
+ */
+ private List<OSGiBundleState> resolveBundles(List<Bundle> bundles)
+ {
+ if (bundles == null)
+ throw new IllegalArgumentException("Null bundles");
+
+ // Normalize to OSGiBundleState instances
+ List<OSGiBundleState> unresolvedBundles = new ArrayList<OSGiBundleState>();
+ for (Bundle bundle : bundles)
+ {
+ unresolvedBundles.add(OSGiBundleState.assertBundleState(bundle));
+ }
+
+ int resolved = 1;
+ int resolveRounds = 0;
+
+ // Get the list of all capabilities
+ List<BundleCapability> allCapabilities = new ArrayList<BundleCapability>();
+ for (List<BundleCapability> list : bundleCapabilitiesMap.values())
+ {
+ allCapabilities.addAll(list);
+ }
+
+ List<OSGiBundleState> resolvedBundles = new ArrayList<OSGiBundleState>();
+ while (resolved > 0 && unresolvedBundles.isEmpty() == false)
+ {
+ resolveRounds++;
+
+ log.debug("#" + resolveRounds + " *****************************************************************");
+ log.debug("Unresolved bundles: " + unresolvedBundles);
+
+ resolved = 0;
+ Iterator<OSGiBundleState> it = unresolvedBundles.iterator();
+ while (it.hasNext())
+ {
+ OSGiBundleState bundleState = it.next();
+ log.debug("Resolving: " + bundleState);
+ if (resolveBundle(allCapabilities, bundleState))
+ {
+ resolvedBundles.add(bundleState);
+ it.remove();
+ resolved++;
+ }
+ }
+ }
+
+ log.debug("END *****************************************************************");
+
+ // Log the unresolved bundles
+ for (OSGiBundleState bundle : unresolvedBundles)
+ {
+ StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
+ message.append("\n Cannot find exporter for");
+ List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
+ for (BundleRequirement requirement : bundleRequirements)
+ {
+ PackageRequirement packreq = requirement.getPackageRequirement();
+ BundleCapability bestMatch = findBestMatch(allCapabilities, requirement);
+ if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
+ {
+ message.append("\n " + packreq.getName() + ";version=" + packreq.getVersionRange());
+ }
+ }
+ log.debug(message);
+ }
+
+ 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);
+ BundleCapability match = getMatchingCapability(bundleState, importPackage);
+ if (match == null)
+ return null;
+
+ OSGiBundleState exportingBundle = match.getExportingBundle();
+ Resolvable resolverBundle = resolverBundleMap.get(exportingBundle);
+ return resolverBundle.getExportPackage(importPackage);
+ }
+
+ private BundleCapability getMatchingCapability(OSGiBundleState bundle, String importPackage)
+ {
+ List<BundleRequirement> requirements = bundleRequirementsMap.get(bundle);
+ if (requirements == null)
+ return null;
+
+ BundleCapability result = null;
+ for (BundleRequirement aux : requirements)
+ {
+ String auxName = aux.getPackageRequirement().getName();
+ if (auxName.equals(importPackage))
+ {
+ result = aux.getWiredCapability();
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ private boolean resolveBundle(List<BundleCapability> allCapabilities, OSGiBundleState bundle)
+ {
+ List<BundleCapability> bundleCapabilities = getBundleCapabilities(bundle);
+ List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
+
+ List<BundleCapability> futureCapabilities = new ArrayList<BundleCapability>(allCapabilities);
+ futureCapabilities.addAll(bundleCapabilities);
+
+ for (BundleRequirement requirement : bundleRequirements)
+ {
+ PackageRequirement packreq = requirement.getPackageRequirement();
+
+ BundleCapability bestMatch = findBestMatch(futureCapabilities, requirement);
+ if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
+ return false;
+
+ requirement.wireCapability(bestMatch);
+ }
+
+ // Remove optional or dynamic requirements that don't have a wire
+ Iterator<BundleRequirement> it = bundleRequirements.iterator();
+ while (it.hasNext())
+ {
+ if (it.next().getWiredCapability() == null)
+ it.remove();
+ }
+
+ if (processRequiredBundle(bundle, bundleCapabilities, bundleRequirements) == false)
+ return false;
+
+ allCapabilities.addAll(bundleCapabilities);
+ bundleCapabilitiesMap.put(bundle, bundleCapabilities);
+ bundleRequirementsMap.put(bundle, bundleRequirements);
+
+ logResolvedBundleInfo(bundle, bundleCapabilities, bundleRequirements);
+
+ return true;
+ }
+
+ /**
+ * Logs information about a resolved bundle
+ */
+ private void logResolvedBundleInfo(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
+ {
+ // Log the package wiring information
+ StringBuffer message = new StringBuffer("Resolved: " + bundle);
+
+ // Log the exports
+ int nameLengthMax = 0;
+ for (BundleCapability capability : bundleCapabilities)
+ {
+ PackageCapability packcap = capability.getPackageCapability();
+ String packNameVersion = packcap.getName() + ";version=" + packcap.getVersion();
+ nameLengthMax = Math.max(nameLengthMax, packNameVersion.length());
+ }
+ if (bundleCapabilities.isEmpty() == false)
+ {
+ message.append("\n Exports");
+ List<String> lines = new ArrayList<String>();
+ for (BundleCapability capability : bundleCapabilities)
+ {
+ PackageCapability packcap = capability.getPackageCapability();
+ String packNameVersion = packcap.getName() + ";version=" + packcap.getVersion();
+ lines.add("\n " + packNameVersion);
+ }
+ Collections.sort(lines);
+ for (String line : lines)
+ message.append(line);
+ }
+
+ // Log the imports
+ nameLengthMax = 0;
+ for (BundleRequirement requirement : bundleRequirements)
+ {
+ PackageRequirement packreq = requirement.getPackageRequirement();
+ String packNameVersion = packreq.getName() + ";version=" + packreq.getVersionRange();
+ nameLengthMax = Math.max(nameLengthMax, packNameVersion.length());
+ }
+ if (bundleRequirements.isEmpty() == false)
+ {
+ message.append("\n Imports");
+ List<String> lines = new ArrayList<String>();
+ for (BundleRequirement requirement : bundleRequirements)
+ {
+ PackageRequirement packreq = requirement.getPackageRequirement();
+ String packNameVersion = packreq.getName() + ";version=" + packreq.getVersionRange();
+ StringBuffer line = new StringBuffer("\n " + packNameVersion);
+ for (int i = 0; i < (nameLengthMax - packNameVersion.length()); i++)
+ line.append(" ");
+
+ BundleCapability wire = requirement.getWiredCapability();
+ if (wire == null)
+ {
+ line.append(" <= null");
+ }
+ else
+ {
+ Bundle wireBundle = wire.getExportingBundle();
+ PackageCapability wireCap = wire.getPackageCapability();
+ packNameVersion = wireCap.getName() + ";version=" + wireCap.getVersion();
+ line.append(" <= " + wireBundle + " " + packNameVersion);
+ }
+ lines.add(line.toString());
+ }
+ Collections.sort(lines);
+ for (String line : lines)
+ message.append(line);
+ }
+ log.debug(message);
+ }
+
+ private BundleCapability findBestMatch(List<BundleCapability> capabilities, BundleRequirement requirement)
+ {
+ BundleCapability result = null;
+ for (BundleCapability capability : capabilities)
+ {
+ if (capability.matches(requirement))
+ {
+ if (result == null)
+ {
+ result = capability;
+ }
+ else
+ {
+ // [TODO] handle multiple matches
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the set of bundle capabilities
+ */
+ private List<BundleCapability> getBundleCapabilities(OSGiBundleState bundle)
+ {
+ List<BundleCapability> result = new ArrayList<BundleCapability>();
+
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ ClassLoadingMetaData metadata = unit.getAttachment(ClassLoadingMetaData.class);
+
+ List<Capability> capabilities = metadata.getCapabilities().getCapabilities();
+ if (capabilities != null)
+ {
+ for (Capability capability : capabilities)
+ {
+ if (capability instanceof PackageCapability)
+ {
+ PackageCapability packageCapability = (PackageCapability)capability;
+ result.add(new BundleCapability(bundle, packageCapability));
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the set of bundle requirements
+ */
+ private List<BundleRequirement> getBundleRequirements(OSGiBundleState bundle)
+ {
+ List<BundleRequirement> result = new ArrayList<BundleRequirement>();
+
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ ClassLoadingMetaData classloadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+
+ List<Requirement> requirements = classloadingMetaData.getRequirements().getRequirements();
+ if (requirements != null)
+ {
+ for (Requirement requirement : requirements)
+ {
+ if (requirement instanceof PackageRequirement)
+ {
+ PackageRequirement packageRequirement = (PackageRequirement)requirement;
+ result.add(new BundleRequirement(bundle, packageRequirement));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private boolean processRequiredBundle(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
+ {
+ // The Require-Bundle header specifies that all exported packages from
+ // another bundle must be imported, effectively requiring the public interface
+ // of another bundle
+ OSGiMetaData osgiMetaData = bundle.getOSGiMetaData();
+ List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
+ if (requireBundles != null)
+ {
+ for (ParameterizedAttribute attr : requireBundles)
+ {
+ String requiredBundleName = attr.getAttribute();
+ if (requiredBundleName == null)
+ throw new IllegalStateException("Cannot obtain value for: " + Constants.REQUIRE_BUNDLE);
+
+ String visibility = Constants.VISIBILITY_PRIVATE;
+ Parameter param = attr.getParameter(Constants.VISIBILITY_DIRECTIVE);
+ if (param != null)
+ visibility = (String)param.getValue();
+
+ String resolution = Constants.RESOLUTION_MANDATORY;
+ param = attr.getParameter(Constants.RESOLUTION_DIRECTIVE);
+ if (param != null)
+ resolution = (String)param.getValue();
+
+ // [TODO] bundle-version
+ //String bundleVersion = null;
+ //param = attr.getParameter(Constants.BUNDLE_VERSION_ATTRIBUTE);
+ //if (param != null)
+ // bundleVersion = (String)param.getValue();
+
+ if (Constants.RESOLUTION_MANDATORY.equals(resolution))
+ {
+ Bundle requiredBundle = getRequiredBundle(requiredBundleName);
+ if (requiredBundle == null)
+ {
+ log.debug("Cannot find " + resolution + " required bundle: " + requiredBundleName);
+ return false;
+ }
+
+ List<BundleCapability> otherCapabilities = bundleCapabilitiesMap.get(requiredBundle);
+ for (BundleCapability otherCapability : otherCapabilities)
+ {
+ PackageCapability otherPackage = otherCapability.getPackageCapability();
+ String packageName = otherPackage.getName();
+ Object version = otherPackage.getVersion();
+ VersionRange versionRange = new VersionRange(version, true, version, true);
+
+ OSGiPackageRequirement newPackageRequirement = new OSGiPackageRequirement(bundle, packageName, versionRange, null);
+ BundleRequirement newBundleRequirement = new BundleRequirement(bundle, newPackageRequirement);
+ newBundleRequirement.wireCapability(otherCapability);
+ bundleRequirements.add(newBundleRequirement);
+
+ if (Constants.VISIBILITY_REEXPORT.equals(visibility))
+ {
+ BundleCapability newBundleCapability = new BundleCapability(bundle, otherPackage);
+ bundleCapabilities.add(newBundleCapability);
+ }
+ }
+ }
+ else if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
+ {
+ // [TODO] resolution=optional
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private Bundle getRequiredBundle(String requiredBundle)
+ {
+ for (Bundle bundle : bundleCapabilitiesMap.keySet())
+ {
+ if (bundle.getSymbolicName().equals(requiredBundle))
+ return bundle;
+ }
+ return null;
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java (from rev 96066, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleCapability.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.framework.resolver.internal.basic;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.classloading.plugins.metadata.PackageCapability;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.classloading.OSGiPackageCapability;
+import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
+
+/**
+ * An association of bundle/capability.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Sep-2009
+ */
+public class BundleCapability
+{
+ private OSGiBundleState bundle;
+ private PackageCapability packageCapability;
+ private List<BundleRequirement> wires;
+
+ BundleCapability(OSGiBundleState bundle, PackageCapability packageCapability)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Null bundle");
+ if (packageCapability == null)
+ throw new IllegalArgumentException("Null packageCapability");
+
+ this.bundle = bundle;
+ this.packageCapability = packageCapability;
+ }
+
+ public OSGiBundleState getExportingBundle()
+ {
+ return bundle;
+ }
+
+ public Module getExportingModule()
+ {
+ OSGiBundleState bundleState = OSGiBundleState.assertBundleState(bundle);
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ return unit.getAttachment(Module.class);
+ }
+
+ public PackageCapability getPackageCapability()
+ {
+ return packageCapability;
+ }
+
+ public List<BundleRequirement> getWiredRequirements()
+ {
+ if (wires == null)
+ return Collections.emptyList();
+
+ return Collections.unmodifiableList(wires);
+ }
+
+ boolean matches(BundleRequirement bundleRequirement)
+ {
+ OSGiPackageCapability osgiPackageCapability = (OSGiPackageCapability)packageCapability;
+ OSGiPackageRequirement osgiPackageRequirement = (OSGiPackageRequirement)bundleRequirement.getPackageRequirement();
+ return osgiPackageCapability.match(osgiPackageRequirement);
+ }
+
+ void wireRequirement(BundleRequirement bundleRequirement)
+ {
+ if (wires == null)
+ wires = new CopyOnWriteArrayList<BundleRequirement>();
+
+ wires.add(bundleRequirement);
+ }
+
+ void unwireRequirement(BundleRequirement bundleRequirement)
+ {
+ if (wires != null)
+ wires.remove(bundleRequirement);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof BundleCapability == false)
+ return false;
+ if (obj == this)
+ return true;
+ return toString().equals(obj.toString());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ String name = packageCapability.getName();
+ return "BundleCapability[" + name + "," + bundle + "]";
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java (from rev 96066, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleRequirement.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BundleRequirement.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,103 @@
+/*
+ * 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.basic;
+
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+
+/**
+ * An association of bundle/requirement.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 10-Sep-2009
+ */
+public class BundleRequirement
+{
+ private OSGiBundleState bundle;
+ private PackageRequirement packageRequirement;
+ private BundleCapability wire;
+
+ BundleRequirement(OSGiBundleState bundle, PackageRequirement packageRequirement)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Null bundle");
+ if (packageRequirement == null)
+ throw new IllegalArgumentException("Null packageRequirement");
+
+ this.bundle = bundle;
+ this.packageRequirement = packageRequirement;
+ }
+
+ public BundleCapability getWiredCapability()
+ {
+ return wire;
+ }
+
+ public OSGiBundleState getImportingBundle()
+ {
+ return bundle;
+ }
+
+ public PackageRequirement getPackageRequirement()
+ {
+ return packageRequirement;
+ }
+
+ void wireCapability(BundleCapability bundleCapability)
+ {
+ wire = bundleCapability;
+ if (bundleCapability != null)
+ bundleCapability.wireRequirement(this);
+ }
+
+ void unwireCapability()
+ {
+ if (wire != null)
+ {
+ wire.unwireRequirement(this);
+ wire = null;
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof BundleRequirement == false)
+ return false;
+ if (obj == this)
+ return true;
+ return toString().equals(obj.toString());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ String name = packageRequirement.getName();
+ return "BundleRequirement[" + name + "," + bundle + "]";
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -39,7 +39,8 @@
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
import org.jboss.osgi.framework.plugins.PackageAdminServicePlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractServicePluginImpl;
-import org.jboss.osgi.framework.resolver.BundleResolver;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.osgi.framework.resolver.Resolvable;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -177,8 +178,12 @@
if (unresolvedBundles.isEmpty())
return true;
- BundleResolver bundleResolver = bundleManager.getBundleResolver();
- List<OSGiBundleState> resolvableBundles = bundleResolver.resolveBundles(unresolvedBundles);
+ // Resolve the bundles through the resolver
+ Resolver bundleResolver = bundleManager.getBundleResolver();
+ List<OSGiBundleState> resolvableBundles = new ArrayList<OSGiBundleState>();
+ for (Resolvable aux : bundleResolver.resolve(unresolvedBundles))
+ resolvableBundles.add(OSGiBundleState.assertBundleState(aux.getBundle()));
+
boolean allResolved = resolvableBundles.containsAll(unresolvedBundles);
int resolved = 1;
@@ -241,7 +246,6 @@
return capability.getName();
}
- @SuppressWarnings("deprecation")
public String getSpecificationVersion()
{
throw new NotImplementedException();
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/FrameworkUtil.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/FrameworkUtil.java 2009-11-09 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/FrameworkUtil.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -1,40 +0,0 @@
-/*
-* 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.util;
-
-import org.jboss.osgi.framework.filter.FilterImpl;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * FrameworkUtil.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class FrameworkUtil
-{
- public static Filter createFilter(String filter) throws InvalidSyntaxException
- {
- return new FilterImpl(filter);
- }
-}
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/NoFilter.java (from rev 96066, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/filter/NoFilter.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/NoFilter.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/util/NoFilter.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,63 @@
+/*
+* 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.util;
+
+import java.util.Dictionary;
+
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Dummy filter implementation
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoFilter implements Filter
+{
+ /** Singleton instance */
+ public static final Filter INSTANCE = new NoFilter();
+
+ /**
+ * Singleton
+ */
+ private NoFilter()
+ {
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean match(Dictionary dictionary)
+ {
+ return true;
+ }
+
+ public boolean match(ServiceReference reference)
+ {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean matchCase(Dictionary dictionary)
+ {
+ return true;
+ }
+}
Modified: 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 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -83,8 +83,6 @@
{
URL url = getClass().getResource("/META-INF/jboss-osgi-bootstrap.xml");
if (url == null)
- url = getClass().getResource("/META-INF/jboss-osgi-default-bootstrap.xml");
- if (url == null)
throw new IllegalStateException("Cannot find: jboss-osgi-bootstrap.xml");
deploy(url);
try
Modified: 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 13:49:05 UTC (rev 96170)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTest.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -29,8 +29,10 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.resolver.BundleResolver;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.launch.OSGiFramework;
+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;
@@ -65,11 +67,11 @@
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.http.jetty.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>();
@@ -80,8 +82,11 @@
unresolved.add(bundle);
}
- BundleResolver bundleResolver = new BundleResolver(null);
- List<OSGiBundleState> resolved = bundleResolver.resolveBundles(unresolved);
+ OSGiBundleManager bundleManager = ((OSGiFramework)framework).getBundleManager();
+ Resolver bundleResolver = bundleManager.getBundleResolver();
+ 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();
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java 2009-11-09 13:52:41 UTC (rev 96171)
@@ -0,0 +1,77 @@
+/*
+ * 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 at jboss.com
+ * @since 09-Nov-2009
+ */
+ at 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
+ */
+ public void testImportAvailable() throws BundleException
+ {
+ }
+
+ /**
+ * [TODO] testImportNotAvailable
+ */
+ public void testImportNotAvailable() throws BundleException
+ {
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ImportDirectiveResolutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-osgi-commits
mailing list