use of com.sun.enterprise.loader.ASURLClassLoader in project Payara by payara.
the class EjbJarHandler method getClassLoader.
public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) {
ASURLClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>() {
@Override
public ASURLClassLoader run() {
return new ASURLClassLoader(parent);
}
});
try {
String compatProp = context.getAppProps().getProperty(DeploymentProperties.COMPATIBILITY);
// let's see if it's defined in glassfish-ejb-jar.xml
if (compatProp == null) {
GFEjbJarXMLParser gfEjbJarXMLParser = new GFEjbJarXMLParser(context.getSource());
compatProp = gfEjbJarXMLParser.getCompatibilityValue();
if (compatProp != null) {
context.getAppProps().put(DeploymentProperties.COMPATIBILITY, compatProp);
}
}
// let's see if it's defined in sun-ejb-jar.xml
if (compatProp == null) {
SunEjbJarXMLParser sunEjbJarXMLParser = new SunEjbJarXMLParser(context.getSourceDir());
compatProp = sunEjbJarXMLParser.getCompatibilityValue();
if (compatProp != null) {
context.getAppProps().put(DeploymentProperties.COMPATIBILITY, compatProp);
}
}
// compatibility of v2 jar visibility
if (compatProp != null && compatProp.equals("v2")) {
List<URL> moduleRootLibraries = ASClassLoaderUtil.getURLsAsList(null, new File[] { context.getSourceDir() }, true);
for (URL url : moduleRootLibraries) {
cloader.addURL(url);
}
}
cloader.addURL(context.getSource().getURI().toURL());
cloader.addURL(context.getScratchDir("ejb").toURI().toURL());
// add libraries referenced from manifest
for (URL url : getManifestLibraries(context)) {
cloader.addURL(url);
}
try {
final DeploymentContext dc = context;
final ClassLoader cl = cloader;
AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.ejb, dc, cl));
} catch (PrivilegedActionException e) {
throw new SecurityException(e.getException());
}
} catch (Exception e) {
_logger.log(Level.SEVERE, e.getMessage());
throw new RuntimeException(e);
}
return cloader;
}
use of com.sun.enterprise.loader.ASURLClassLoader in project Payara by payara.
the class CarHandler method getClassLoader.
@Override
public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) {
ASURLClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>() {
@Override
public ASURLClassLoader run() {
return new ASURLClassLoader(parent);
}
});
try {
cloader.addURL(context.getSource().getURI().toURL());
// add libraries referenced from manifest
for (URL url : getManifestLibraries(context)) {
cloader.addURL(url);
}
try {
final DeploymentContext dc = context;
final ClassLoader cl = cloader;
AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.car, dc, cl));
} catch (PrivilegedActionException e) {
throw new SecurityException(e.getException());
}
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
return cloader;
}
use of com.sun.enterprise.loader.ASURLClassLoader in project Payara by payara.
the class ConnectorClassLoader method getClasspath.
/**
* Returns all the resources of the connector classloaders in the chain,
* concatenated to a classpath string.
* <p/>
* Notice that this method is called by the setClassPath() method of
* org.apache.catalina.loader.WebappLoader, since the ConnectorClassLoader does
* not extend off of URLClassLoader.
*
* @return Classpath string containing all the resources of the connectors
* in the chain. An empty string if there exists no connectors in the chain.
*/
public String getClasspath() {
StringBuffer strBuf = new StringBuffer();
for (int i = 0; i < classLoaderChain.size(); i++) {
ASURLClassLoader ecl = (ASURLClassLoader) classLoaderChain.get(i);
String eclClasspath = ecl.getClasspath();
if (eclClasspath != null) {
if (i > 0)
strBuf.append(File.pathSeparator);
strBuf.append(eclClasspath);
}
}
return strBuf.toString();
}
use of com.sun.enterprise.loader.ASURLClassLoader in project Payara by payara.
the class ConnectorClassLoader method addResourceAdapter.
/**
* Adds the requested resource adapter to the ConnectorClassLoader. A
* ConnectorClassLoader is created with the moduleDir as its search path
* and this classloader is added to the classloader chain.
*
* @param rarName the resourceAdapter module name to add
* @param moduleDir the directory location where the RAR contents are exploded
*/
public void addResourceAdapter(String rarName, String moduleDir) {
try {
File file = new File(moduleDir);
ASURLClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>() {
public ASURLClassLoader run() {
return new ASURLClassLoader(parent);
}
});
cl.appendURL(file.toURI().toURL());
appendJars(file, cl);
classLoaderChain.add(cl);
rarModuleClassLoaders.put(rarName, cl);
} catch (MalformedURLException ex) {
_logger.log(Level.SEVERE, "enterprise_util.connector_malformed_url", ex);
}
}
use of com.sun.enterprise.loader.ASURLClassLoader in project Payara by payara.
the class ConnectorClassLoader method removeResourceAdapter.
/**
* Removes the resource adapter's class loader from the classloader linked
* list
*
* @param moduleName the connector module that needs to be removed.
*/
public void removeResourceAdapter(String moduleName) {
ASURLClassLoader classLoaderToRemove = (ASURLClassLoader) rarModuleClassLoaders.get(moduleName);
if (classLoaderToRemove != null) {
classLoaderChain.remove(classLoaderToRemove);
rarModuleClassLoaders.remove(moduleName);
_logger.log(Level.WARNING, "enterprise_util.remove_connector", moduleName);
}
}
Aggregations