/** * {@inheritDoc} */ public DelegatingClassLoader getConnectorClassLoader() { return clh.getConnectorClassLoader(null); }
public ClassLoader getLifecycleParentClassLoader() { return services.<ClassLoaderHierarchy>getService(ClassLoaderHierarchy.class).getConnectorClassLoader(null); }
public ClassLoader getSharedClassLoader() { return services.<ClassLoaderHierarchy>getService(ClassLoaderHierarchy.class).getConnectorClassLoader(null); }
public ConnectorClassFinder createRARClassLoader(String moduleDir, ClassLoader deploymentParent, String moduleName, List<URI> appLibs) throws ConnectorRuntimeException { ClassLoader parent = null; //For standalone rar : //this is not a normal application and hence cannot use the provided parent during deployment. //setting the parent to connector-class-loader's parent as this is a .rar //For embedded rar : //use the deploymentParent as the class-finder created won't be part of connector class loader //service hierarchy if(deploymentParent == null){ parent = clh.getConnectorClassLoader(null).getParent(); }else{ parent = deploymentParent; } return createRARClassLoader(parent, moduleDir, moduleName, appLibs); }
ClassLoader contextCL = Thread.currentThread().getContextClassLoader(); try { ClassLoader ccl = clh.getConnectorClassLoader(null); Thread.currentThread().setContextClassLoader(ccl); switch (type) {
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; }
DelegatingClassLoader dcl = clh.getConnectorClassLoader(null); for(DelegatingClassLoader.ClassFinder cf : dcl.getDelegates()){ ConnectorClassFinder ccf = (ConnectorClassFinder)cf;
clh.getConnectorClassLoader(null).addDelegate(ccf); clh.getConnectorClassLoader(null).removeDelegate(ccf);