1 22 package org.jboss.aop.deployment; 23 24 import org.jboss.aop.AspectManager; 25 import org.jboss.aop.Domain; 26 import org.jboss.aop.classpool.AOPScopedClassLoaderHelper; 27 import org.jboss.mx.loading.HeirarchicalLoaderRepository3; 28 import org.jboss.mx.loading.LoaderRepository; 29 import org.jboss.mx.loading.RepositoryClassLoader; 30 31 36 public class JBossScopedClassLoaderHelper implements AOPScopedClassLoaderHelper 37 { 38 public ClassLoader ifScopedDeploymentGetScopedParentUclForCL(ClassLoader loader) 39 { 40 ClassLoader parent = loader; 41 while (parent != null) 43 { 44 if (isScopedClassLoader(parent)) 45 { 46 return parent; 47 } 48 if (parent instanceof RepositoryClassLoader) 49 { 50 return null; 52 } 53 parent = parent.getParent(); 54 } 55 return null; 56 } 57 58 public static boolean isScopedClassLoader(ClassLoader loader) 59 { 60 boolean scoped = false; 61 if (loader instanceof RepositoryClassLoader) 62 { 63 LoaderRepository repository = ((RepositoryClassLoader)loader).getLoaderRepository(); 64 if (repository instanceof HeirarchicalLoaderRepository3) 65 { 66 scoped = true; 67 HeirarchicalLoaderRepository3 hlr = (HeirarchicalLoaderRepository3)repository; 68 boolean parentFirst = hlr.getUseParentFirst(); 69 } 70 } 71 return scoped; 72 } 73 74 75 public ClassLoader getTopLevelJBossClassLoader() 76 { 77 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 78 RepositoryClassLoader topRcl = null; 79 while (loader != null) 80 { 81 if (loader instanceof RepositoryClassLoader) 82 { 83 topRcl = (RepositoryClassLoader)loader; 84 } 85 loader = loader.getParent(); 86 } 87 return topRcl; 88 } 89 90 public Domain getScopedClassLoaderDomain(ClassLoader cl, AspectManager parent) 91 { 92 boolean parentDelegation = true; 93 if (cl instanceof RepositoryClassLoader) 94 { 95 HeirarchicalLoaderRepository3 repository = (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository(); 96 parentDelegation = repository.getUseParentFirst(); 97 } 98 String name = String.valueOf(System.identityHashCode(cl)); 99 return new ScopedClassLoaderDomain(cl, name, parentDelegation, parent, false); 100 } 101 102 } 103 | Popular Tags |