/** * Given the module directory, creates a connector-class-finder (class-loader) for the module * @param moduleDirectory rar module directory for which classloader is needed * @param parent parent classloader<br> * For standalone rars, pass null, as the parent should be common-class-loader * that will be automatically taken care by ConnectorClassLoaderService.<br> * For embedded rars, parent is necessary<br> * @return classloader created for the module */ public ClassLoader createConnectorClassLoader(String moduleDirectory, ClassLoader parent, String rarModuleName) throws ConnectorRuntimeException{ List<URI> libraries = ConnectorsUtil.getInstalledLibrariesFromManifest(moduleDirectory, env); return cclUtil.createRARClassLoader(moduleDirectory, parent, rarModuleName, libraries); }
private void appendJars(File moduleDir, ASURLClassLoader cl) throws MalformedURLException { //TODO for embedded rars -consider MANIFEST.MF's classpath attribute if (moduleDir.isDirectory()) { for (File file : moduleDir.listFiles()) { if (file.getName().toUpperCase(Locale.getDefault()).endsWith(".JAR")) { cl.appendURL(file.toURI().toURL()); } else if (file.isDirectory()) { appendJars(file, cl); //recursive add } } } } }
public ClassLoader getSystemRARClassLoader(String rarName) throws ConnectorRuntimeException{ return cclUtil.getSystemRARClassLoader(rarName); }
File rarDir = new File(rarPath); if(!rarDir.exists()){ extractRar(jdbcRarName, installDir); ConnectorClassFinder ccf = createRARClassLoader(location, null, rarName, libraries); classLoaders.add(ccf);
final DelegatingClassLoader.ClassFinder librariesCL = getLibrariesClassLoader(appLibs); cl = (ConnectorClassFinder)AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { try { cl.appendURL(file.toURI().toURL()); appendJars(file, cl); } catch (MalformedURLException e) { throw new RuntimeException(e);
public Collection<ConnectorClassFinder> getSystemRARClassLoaders() { try { return getConnectorsClassLoaderUtil().getSystemRARClassLoaders(); } catch (ConnectorRuntimeException cre) { throw new RuntimeException(cre.getMessage(), cre); } }
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); }