Ales Justin [
http://community.jboss.org/people/alesj] replied to the discussion
"Endless loop at AS server startup"
To view the discussion, visit:
http://community.jboss.org/message/549028#549028
--------------------------------------------------------------
The cache may have side effects because the code in #4 and #5 is not
always executed when a client calls #3.
Could you please review carefully or alternatively change the algorithm so it becomes
usable for large sets of reqs/caps and mods.
Adding this patch doesn't change AS
boot time in measurable way, at least not for default and all.
Index: classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java
===================================================================
--- classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java
(revision 106215)
+++ classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java
(working copy)
@@ -85,6 +85,9 @@
/** The requirements */
private List<RequirementDependencyItem> requirementDependencies;
+
+ /** Already resolved dependency items */
+ private Map<RequirementDependencyItem, Module> resolved;
/** Any lifecycle associated with the classloader */
private LifeCycle lifeCycle;
@@ -94,7 +97,7 @@
/** Requirements resolved to us */
private Set<RequirementDependencyItem> depends = new
CopyOnWriteArraySet<RequirementDependencyItem>();
-
+
/**
* Register a classloader for a module
*
@@ -1191,6 +1194,7 @@
addIDependOn(item);
requirementDependencies.add(item);
}
+ resolved = new ConcurrentHashMap<RequirementDependencyItem, Module>();
}
}
@@ -1205,6 +1209,7 @@
removeIDependOn(item);
}
requirementDependencies = null;
+ resolved = null;
}
/**
@@ -1216,7 +1221,10 @@
if (requirementDependencies != null && requirementDependencies.isEmpty() ==
false)
{
for (RequirementDependencyItem item : requirementDependencies)
+ {
item.unresolved(controller);
+ resolved.remove(item);
+ }
}
}
@@ -1336,14 +1344,33 @@
*/
protected Module resolveModule(RequirementDependencyItem dependency, boolean
resolveSpace)
{
+ if (resolved != null)
+ {
+ Module resolvedModule = resolved.get(dependency);
+ if (resolvedModule != null)
+ return resolvedModule;
+ }
+
ClassLoadingSpace space = getClassLoadingSpace();
if (resolveSpace && space != null)
space.resolve(this);
+ if (resolved != null)
+ {
+ Module resolvedModule = resolved.get(dependency);
+ if (resolvedModule != null)
+ return resolvedModule;
+ }
+
Requirement requirement = dependency.getRequirement();
- return checkDomain().resolveModule(this, requirement);
+ Module result = checkDomain().resolveModule(this, requirement);
+
+ if (result != null && resolved != null)
+ resolved.put(dependency, result);
+
+ return result;
}
Perhaps these large sets should be mocked in the CL testsuite.
But I guess, as you mentioned, it will only show in osgi config, with compendiums
large requirement set.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/549028#549028]
Start a new discussion in JBoss Microcontainer Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]