public ClassLoader getCommonClassLoader() { return clHierarchy.getCommonClassLoader(); }
/** * {@inheritDoc} */ public DelegatingClassLoader getConnectorClassLoader() { return clh.getConnectorClassLoader(null); }
private ClassLoader createClassLoader(ClassLoaderHierarchy clh, ArchiveHandler handler, String appName) throws URISyntaxException, MalformedURLException { // first we create the appLib class loader, this is non shared libraries class loader ClassLoader applibCL = clh.getAppLibClassLoader(appName, getAppLibs()); ClassLoader parentCL = clh.createApplicationParentCL(applibCL, this); return handler.getClassLoader(parentCL, this); }
public Object run() throws Exception { return clh.getAppLibClassFinder(appLibs); } });
/** * Loads the requested class using the Common Classloader * * @param className the name of the class to load * * @return the loaded class */ Class loadClass(String className) throws Exception { return clh.getCommonClassLoader().loadClass(className); } }
public ClassLoader getLifecycleParentClassLoader() { return services.<ClassLoaderHierarchy>getService(ClassLoaderHierarchy.class).getConnectorClassLoader(null); }
public Class loadCommonClass(String className) throws Exception { return clh.getCommonClassLoader().loadClass(className); }
public ClassLoader getSharedClassLoader() { return services.<ClassLoaderHierarchy>getService(ClassLoaderHierarchy.class).getConnectorClassLoader(null); }
/** * Check if the ClassLoader of the Bean type being proxied is a * GlassFish application ClassLoader. The current logic checks if * the common classloader appears as a parent in the classloader hierarchy * of the Bean's classloader. */ private boolean isApplicationClassLoader(ClassLoader prxCL) { boolean isAppCL = false; while (prxCL != null) { if (prxCL.equals(clh.getCommonClassLoader())) { isAppCL = true; break; } prxCL = prxCL.getParent(); } return isAppCL; }
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); }
private ClassLoader getCommonClassLoader(){ return habitat.getComponent(ClassLoaderHierarchy.class).getCommonClassLoader(); }
ClassLoader contextCL = Thread.currentThread().getContextClassLoader(); try { ClassLoader ccl = clh.getConnectorClassLoader(null); Thread.currentThread().setContextClassLoader(ccl); switch (type) {
try { ClassLoader commonClassLoader = ConnectorRuntime.getRuntime().getClassLoaderHierarchy().getCommonClassLoader(); if (f.isDirectory()) { List<URL> urls = new ArrayList<URL>();
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 + " ]"); }
private void generatePolicy(WebBundleDescriptor wbd) { String name = null; ClassLoader oldTcc = Thread.currentThread().getContextClassLoader(); try { //TODO: workaround here. Once fixed in V3 we should be able to use //Context ClassLoader instead. ClassLoaderHierarchy hierarchy = habitat.getComponent(ClassLoaderHierarchy.class); ClassLoader tcc = hierarchy.getCommonClassLoader(); Thread.currentThread().setContextClassLoader(tcc); policyLoader.loadPolicy(); WebSecurityManagerFactory wsmf =habitat.getComponent(WebSecurityManagerFactory.class); // this should create all permissions wsmf.createManager(wbd,true,serverContext); // for an application the securityRoleMapper should already be // created. I am just creating the web permissions and handing // it to the security component. name = WebSecurityManager.getContextID(wbd); SecurityUtil.generatePolicyFile(name); websecurityProbeProvider.policyCreationEvent(name); } catch (IASSecurityException se) { String msg = "Error in generating security policy for " + name; throw new RuntimeException(msg, se); } finally { Thread.currentThread().setContextClassLoader(oldTcc); } }
/** * @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; }
realmClass = hierarchy.getCommonClassLoader().loadClass(className); Object obj = realmClass.newInstance(); r = (Realm) obj;
DelegatingClassLoader dcl = clh.getConnectorClassLoader(null); for(DelegatingClassLoader.ClassFinder cf : dcl.getDelegates()){ ConnectorClassFinder ccf = (ConnectorClassFinder)cf;
throws IOException { ClassLoader commonCL = clh.getCommonClassLoader();
clh.getConnectorClassLoader(null).addDelegate(ccf); clh.getConnectorClassLoader(null).removeDelegate(ccf);