[jboss-cvs] JBossAS SVN: r104780 - in projects/jboss-cl/branches/tdi/jbosgi323: classloading/src/main/java/org/jboss/classloading/spi/dependency and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 13 16:38:17 EDT 2010
Author: thomas.diesler at jboss.com
Date: 2010-05-13 16:38:16 -0400 (Thu, 13 May 2010)
New Revision: 104780
Modified:
projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java
projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/RequirementDependencyItem.java
projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java
projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/DynamicClassLoaderPolicyFactory.java
Log:
[JBOSGI-323] Add logic that finds a loader which can be lazily added to the policy
Modified: projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-13 20:33:05 UTC (rev 104779)
+++ projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-13 20:38:16 UTC (rev 104780)
@@ -905,8 +905,31 @@
return delegate;
}
}
+
+ // Process potential delegates that were added lazily to the policy
+ // This could for example be done in a {@link ClassNotFoundHandler}
+ List<? extends DelegateLoader> policyDelegates = info.getPolicy().getDelegates();
+ if (policyDelegates != null && policyDelegates.isEmpty() == false)
+ {
+ for (DelegateLoader delegate : policyDelegates)
+ {
+ if (delegates.contains(delegate) || delegate.getImportType() != type)
+ continue;
+
+ if (trace)
+ log.trace(this + " trying to load " + name + " from delegate added lazily to policy " + delegate + " for " + info.getClassLoader());
+
+ if (delegate.getResource(name) != null)
+ {
+ info.cacheLoader(name, delegate);
+ return delegate;
+ }
+ }
+ }
+
if (type == ImportType.AFTER) // TODO -- is this really OK?
info.blackListClass(name);
+
return null;
}
Modified: projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java
===================================================================
--- projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java 2010-05-13 20:33:05 UTC (rev 104779)
+++ projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java 2010-05-13 20:38:16 UTC (rev 104780)
@@ -354,7 +354,8 @@
List<Capability> capabilities = module.getCapabilitiesRaw();
if (capabilities != null && capabilities.isEmpty() == false)
{
- ModuleRequirement requirement = new ModuleRequirement(name, range);
+ String auxModuleName = (name != null ? name : "auxModuleName");
+ ModuleRequirement requirement = new ModuleRequirement(auxModuleName, range);
for (Capability capability : capabilities)
{
if (capability.resolves(module, requirement))
@@ -366,7 +367,9 @@
}
else
{
- if (name.equals(module.getName()) && range.isInRange(module.getVersion()))
+ boolean nameMatch = (name == null || name.equals(module.getName()));
+ boolean versionMatch = range.isInRange(module.getVersion());
+ if (nameMatch && versionMatch)
{
result.add(module);
return;
Modified: projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/RequirementDependencyItem.java
===================================================================
--- projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/RequirementDependencyItem.java 2010-05-13 20:33:05 UTC (rev 104779)
+++ projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/RequirementDependencyItem.java 2010-05-13 20:38:16 UTC (rev 104780)
@@ -39,7 +39,6 @@
public class RequirementDependencyItem extends AbstractDependencyItem
{
/** The log */
- @SuppressWarnings("hiding")
private static final Logger log = Logger.getLogger(RequirementDependencyItem.class);
/** The module */
Modified: projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java
===================================================================
--- projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java 2010-05-13 20:33:05 UTC (rev 104779)
+++ projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java 2010-05-13 20:38:16 UTC (rev 104780)
@@ -266,7 +266,6 @@
if (requirement instanceof PackageRequirement)
{
PackageRequirement pr = (PackageRequirement)requirement;
- // TODO -- handle wildcards
return new FilteredDelegateLoader(factory, pr.toClassFilter());
}
else
Modified: projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/DynamicClassLoaderPolicyFactory.java
===================================================================
--- projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/DynamicClassLoaderPolicyFactory.java 2010-05-13 20:33:05 UTC (rev 104779)
+++ projects/jboss-cl/branches/tdi/jbosgi323/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/DynamicClassLoaderPolicyFactory.java 2010-05-13 20:38:16 UTC (rev 104780)
@@ -23,10 +23,13 @@
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderPolicyFactory;
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
import org.jboss.classloading.spi.dependency.Domain;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.dependency.RequirementDependencyItem;
+import org.jboss.classloading.spi.metadata.Requirement;
import org.jboss.dependency.spi.Controller;
+import org.jboss.logging.Logger;
/**
* DynamicClassLoaderPolicyFactory.
@@ -36,12 +39,15 @@
*/
public class DynamicClassLoaderPolicyFactory implements ClassLoaderPolicyFactory
{
+ /** The log */
+ private static final Logger log = Logger.getLogger(DynamicClassLoaderPolicyFactory.class);
+
/** The controller */
private Controller controller;
/** The domain */
private Domain domain;
-
+
/** The requirement dependency item */
private RequirementDependencyItem item;
@@ -67,13 +73,38 @@
public ClassLoaderPolicy createClassLoaderPolicy()
{
+ Requirement req = item.getRequirement();
+ if (req instanceof PackageRequirement == false)
+ return getWiredModuleClassLoaderPolicy();
+
+ PackageRequirement preq = (PackageRequirement)req;
+ if (preq.isWildcard())
+ {
+ return getWildcardClassLoaderPolicy();
+ }
+ else
+ {
+ return getWiredModuleClassLoaderPolicy();
+ }
+ }
+
+ private ClassLoaderPolicy getWildcardClassLoaderPolicy()
+ {
+ // [TODO] A dynamic import with wildcard at the end does not wire to
+ // a dependent module. We need to figure out how to handle this case.
+ log.warn("Cannot obtain policy for: " + item.getRequirement());
+ return null;
+ }
+
+ private ClassLoaderPolicy getWiredModuleClassLoaderPolicy()
+ {
// Still undetermined
- String name = (String) item.getIDependOn();
+ String name = (String)item.getIDependOn();
if (name == null)
{
// Try to resolve
item.resolve(controller);
- name = (String) item.getIDependOn();
+ name = (String)item.getIDependOn();
if (name == null)
return null;
}
@@ -85,7 +116,8 @@
// Get the policy for the module
if (iDependOnModule instanceof ClassLoaderPolicyModule == false)
throw new IllegalStateException("Unable to determine ClassLoaderPolicy from module: " + iDependOnModule);
- ClassLoaderPolicyModule classLoaderPolicyModule = (ClassLoaderPolicyModule) iDependOnModule;
+
+ ClassLoaderPolicyModule classLoaderPolicyModule = (ClassLoaderPolicyModule)iDependOnModule;
return classLoaderPolicyModule.getPolicy();
}
}
More information about the jboss-cvs-commits
mailing list