[jboss-osgi-commits] JBoss-OSGI SVN: r93319 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade: service and 1 other directory.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Wed Sep 9 12:57:03 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-09-09 12:57:02 -0400 (Wed, 09 Sep 2009)
New Revision: 93319
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
Log:
[JBOSGI-151] Cannot resolve circular dependencies
Bundles resolve, but optional packages might come from different modules
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java 2009-09-09 16:51:54 UTC (rev 93318)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java 2009-09-09 16:57:02 UTC (rev 93319)
@@ -154,10 +154,10 @@
}
Module cachedModule = capabilityCache.getCachedModule(packageRequirement);
- if (cachedModule == capModule)
+ if (cachedModule != null)
{
log.debug("Cached: " + requirement + " " + capModule);
- return true;
+ return cachedModule == capModule;
}
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java 2009-09-09 16:51:54 UTC (rev 93318)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java 2009-09-09 16:57:02 UTC (rev 93319)
@@ -51,7 +51,7 @@
private Map<String, List<Module>> moduleAssociations = new HashMap<String, List<Module>>();
private Map<String, Module> blacklistedModules = new HashMap<String, Module>();
- private Map<String, Module> cachedModules = new HashMap<String, Module>();
+ private Map<String, Module> endorsedModules = new HashMap<String, Module>();
private static ThreadLocal<OSGiPackageCapabilityCache> threadLocal = new ThreadLocal<OSGiPackageCapabilityCache>();
public static OSGiPackageCapabilityCache createInstance()
@@ -103,7 +103,7 @@
public Module getCachedModule(PackageRequirement requirement)
{
String packageName = requirement.getName();
- return cachedModules.get(packageName);
+ return endorsedModules.get(packageName);
}
public boolean isBlacklisted(PackageRequirement requirement, Module module)
@@ -114,20 +114,23 @@
return blacklisted;
}
- public void endorseModuleAssociations()
+ public void endorseModuleAssociations(OSGiBundleState bundleState)
{
- Map<String, Module> firstMatches = getMapOfFirstMatches(moduleAssociations);
+ Module module = assertModule(bundleState);
+ Map<String, Module> firstMatches = getMapOfFirstMatches(module);
if (firstMatches.isEmpty() == false)
{
log.info(getLogMessage("Endorse module associations", firstMatches));
- cachedModules.putAll(firstMatches);
+ endorsedModules.putAll(firstMatches);
}
+ blacklistedModules.clear();
moduleAssociations.clear();
}
-
+
public void blacklistModuleAssociations(OSGiBundleState bundleState)
{
- Map<String, Module> firstMatches = getMapOfFirstMatches(moduleAssociations);
+ Module module = assertModule(bundleState);
+ Map<String, Module> firstMatches = getMapOfFirstMatches(module);
if (firstMatches.isEmpty() == false)
{
log.info(getLogMessage("Blacklist module associations", firstMatches));
@@ -135,12 +138,10 @@
}
moduleAssociations.clear();
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- ControllerContext context = unit.getAttachment(ControllerContext.class);
- DependencyInfo di = context.getDependencyInfo();
-
- StringBuffer message = new StringBuffer("Unresolved requirements: ");
- for (DependencyItem iDependOn : di.getIDependOn(RequirementDependencyItem.class))
+ StringBuffer message = new StringBuffer("Unresolved requirements ");
+ ControllerContext context = assertControllerContext(bundleState);
+ DependencyInfo dependencyInfo = context.getDependencyInfo();
+ for (DependencyItem iDependOn : dependencyInfo.getIDependOn(RequirementDependencyItem.class))
{
// Reset all resolved dependency items
// [JBKERNEL-54] DependencyItem inconsistency when multiple possible matches
@@ -160,15 +161,34 @@
log.info(message);
}
- private Map<String, Module> getMapOfFirstMatches(Map<String, List<Module>> moduleAssociations)
+ private ControllerContext assertControllerContext(OSGiBundleState bundleState)
{
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ ControllerContext context = unit.getAttachment(ControllerContext.class);
+ if (context == null)
+ throw new IllegalStateException("Cannot obtain ControllerContext from: " + unit);
+ return context;
+ }
+
+ private Module assertModule(OSGiBundleState bundleState)
+ {
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ Module module = unit.getAttachment(Module.class);
+ if (module == null)
+ throw new IllegalStateException("Cannot obtain Module from: " + unit);
+ return module;
+ }
+
+ private Map<String, Module> getMapOfFirstMatches(Module module)
+ {
Map<String, Module> firstMatches = new HashMap<String, Module>();
for (Entry<String, List<Module>> entry : moduleAssociations.entrySet())
{
String packageName = entry.getKey();
List<Module> modules = entry.getValue();
- if (modules.size() > 1)
- firstMatches.put(packageName, modules.get(0));
+ Module other = modules.get(0);
+ if (module == other)
+ firstMatches.put(packageName, other);
}
return firstMatches;
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java 2009-09-09 16:51:54 UTC (rev 93318)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java 2009-09-09 16:57:02 UTC (rev 93319)
@@ -196,7 +196,7 @@
OSGiBundleState bundleState = assertBundleState(it.next());
if (bundleManager.resolve(bundleState, false))
{
- cacheInstance.endorseModuleAssociations();
+ cacheInstance.endorseModuleAssociations(bundleState);
it.remove();
resolved++;
}
More information about the jboss-osgi-commits
mailing list