public ConnectorClassFinder(ClassLoader parent, String raName, DelegatingClassLoader.ClassFinder finder){ super(parent); this.raName = raName; // There should be better approach to skip libraries Classloader when none specified. // casting to DelegatingClassLoader is not a clean approach DelegatingClassLoader.ClassFinder libcf = null; if(finder!= null && (finder instanceof DelegatingClassLoader)){ if(((DelegatingClassLoader)finder).getDelegates().size() > 0){ libcf = finder; } } this.librariesClassFinder = libcf; }
private DelegatingClassLoader.ClassFinder getClassFinder(String raName) { List<DelegatingClassLoader.ClassFinder> delegates = globalConnectorCL.getDelegates(); DelegatingClassLoader.ClassFinder classFinder = null; for(DelegatingClassLoader.ClassFinder cf : delegates){ if(raName.equals(((ConnectorClassFinder)cf).getResourceAdapterName())){ classFinder = cf; break; } } return classFinder; }
private boolean isRARCL(ClassLoader loader) { DelegatingClassLoader connectorCL = (DelegatingClassLoader) this.getParent(); if (!(loader instanceof DelegatingClassLoader.ClassFinder)) { return false; } return connectorCL.getDelegates().contains((DelegatingClassLoader.ClassFinder)loader); }
public ConnectorClassFinder getSystemRARClassLoader(String rarName) throws ConnectorRuntimeException { if (ConnectorsUtil.belongsToSystemRA(rarName)) { DelegatingClassLoader dch = clh.getConnectorClassLoader(null); for (DelegatingClassLoader.ClassFinder cf : dch.getDelegates()) { if (cf instanceof ConnectorClassFinder) { if (rarName.equals(((ConnectorClassFinder) cf).getResourceAdapterName())) { return (ConnectorClassFinder) cf; } } } } throw new ConnectorRuntimeException("No Classloader found for RA [ " + rarName + " ]"); }
/** * @see org.glassfish.internal.api.ClassLoaderHierarchy#getAppLibClassLoader(String, List<URI>) */ public ClassLoader getAppLibClassLoader(String application, List<URI> libURIs) throws MalformedURLException { ClassLoaderHierarchy clh = habitat.getService(ClassLoaderHierarchy.class); DelegatingClassLoader connectorCL = clh.getConnectorClassLoader(application); if (libURIs == null || libURIs.isEmpty()) { // Optimization: when there are no libraries, why create an empty // class loader in the hierarchy? Instead return the parent. return connectorCL; } final ClassLoader commonCL = commonCLS.getCommonClassLoader(); DelegatingClassLoader applibCL = AccessController.doPrivileged(new PrivilegedAction<DelegatingClassLoader>() { public DelegatingClassLoader run() { return new DelegatingClassLoader(commonCL); } }); // order of classfinders is important here : // connector's classfinders should be added before libraries' classfinders // as the delegation hierarchy is appCL->app-libsCL->connectorCL->commonCL->API-CL // since we are merging connector and applib classfinders to be at same level, // connector classfinders need to be be before applib classfinders in the horizontal // search path for (DelegatingClassLoader.ClassFinder cf : connectorCL.getDelegates()) { applibCL.addDelegate(cf); } addDelegates(libURIs, applibCL); return applibCL; }
for(DelegatingClassLoader.ClassFinder cf : dcl.getDelegates()){ try { PreDestroy.class.cast(cf).preDestroy();
for(DelegatingClassLoader.ClassFinder cf : dcl.getDelegates()){ ConnectorClassFinder ccf = (ConnectorClassFinder)cf; if(ccf.getResourceAdapterName().equals(moduleName)){