Author: rickhall
Date: Wed Sep 15 19:13:56 2010
New Revision: 997459
URL: http://svn.apache.org/viewvc?rev=997459&view=rev
Log:
Do not hold lock while firing RESOLVED event. (FELIX-2597)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=997459&r1=997458&r2=997459&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Wed Sep 15 19:13:56 2010
@@ -3956,6 +3956,7 @@ public class Felix extends BundleImpl im
"Unable to acquire global lock for resolve.",
rootModule, null);
}
+ Map<Module, List<Wire>> wireMap = null;
try
{
BundleImpl bundle = (BundleImpl) rootModule.getBundle();
@@ -3983,8 +3984,7 @@ public class Felix extends BundleImpl im
try
{
// Resolve the module.
- Map<Module, List<Wire>> wireMap =
- m_resolver.resolve(m_resolverState,
newRootModule);
+ wireMap = m_resolver.resolve(m_resolverState,
newRootModule);
// Mark all modules as resolved.
markResolvedModules(wireMap);
@@ -4015,6 +4015,8 @@ public class Felix extends BundleImpl im
// Always release the global lock.
releaseGlobalLock();
}
+
+ fireResolvedEvents(wireMap);
}
}
@@ -4036,6 +4038,7 @@ public class Felix extends BundleImpl im
"Unable to acquire global lock for resolve.", module,
null);
}
+ Map<Module, List<Wire>> wireMap = null;
try
{
// Double check to make sure that someone hasn't beaten us
to
@@ -4051,8 +4054,7 @@ public class Felix extends BundleImpl im
}
}
- Map<Module, List<Wire>> wireMap =
- m_resolver.resolve(m_resolverState, module, pkgName);
+ wireMap = m_resolver.resolve(m_resolverState, module,
pkgName);
if ((wireMap != null) && wireMap.containsKey(module))
{
@@ -4078,6 +4080,8 @@ m_logger.log(Logger.LOG_DEBUG, "DYNAMIC
// Always release the global lock.
releaseGlobalLock();
}
+
+ fireResolvedEvents(wireMap);
}
return candidateWire;
@@ -4196,7 +4200,6 @@ m_logger.log(Logger.LOG_DEBUG, "DYNAMIC
BundleImpl bundle = (BundleImpl) module.getBundle();
// Lock the bundle first.
- boolean fire = false;
try
{
// Acquire bundle lock.
@@ -4219,7 +4222,6 @@ m_logger.log(Logger.LOG_DEBUG, "DYNAMIC
else
{
setBundleStateAndNotify(bundle, Bundle.RESOLVED);
- fire = true;
}
}
}
@@ -4227,11 +4229,27 @@ m_logger.log(Logger.LOG_DEBUG, "DYNAMIC
{
releaseBundleLock(bundle);
}
+ }
- // Fire event while not holding the bundle lock.
- if (fire)
+ private void fireResolvedEvents(Map<Module, List<Wire>> wireMap)
+ {
+ if (wireMap != null)
{
- fireBundleEvent(BundleEvent.RESOLVED, bundle);
+ Iterator<Entry<Module, List<Wire>>> iter =
wireMap.entrySet().iterator();
+ // Iterate over the map to fire necessary RESOLVED events.
+ while (iter.hasNext())
+ {
+ Entry<Module, List<Wire>> entry = iter.next();
+ Module module = entry.getKey();
+
+ // Fire RESOLVED events for all fragments.
+ List<Module> fragments = ((ModuleImpl)
module).getFragments();
+ for (int i = 0; (fragments != null) && (i <
fragments.size()); i++)
+ {
+ fireBundleEvent(BundleEvent.RESOLVED,
fragments.get(i).getBundle());
+ }
+ fireBundleEvent(BundleEvent.RESOLVED, module.getBundle());
+ }
}
}
}