/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Specialized web application class loader.
* <p>
* This class loader is a full reimplementation of the
* <code>URLClassLoader</code> from the JDK. It is desinged to be fully
* compatible with a normal <code>URLClassLoader</code>, although its internal
* behavior may be completely different.
* <p>
* <strong>IMPLEMENTATION NOTE</strong> - This class loader faithfully follows
* the delegation model recommended in the specification. The system class
* loader will be queried first, then the local repositories, and only then
* delegation to the parent class loader will occur. This allows the web
* application to override any shared class except the classes from J2SE.
* Special handling is provided from the JAXP XML parser interfaces, the JNDI
* interfaces, and the classes from the servlet API, which are never loaded
* from the webapp repository.
* <p>
* <strong>IMPLEMENTATION NOTE</strong> - Due to limitations in Jasper
* compilation technology, any repository which contains classes from
* the servlet API will be ignored by the class loader.
* <p>
* <strong>IMPLEMENTATION NOTE</strong> - The class loader generates source
* URLs which include the full JAR URL when a class is loaded from a JAR file,
* which allows setting security permission at the class level, even when a
* class is contained inside a JAR.
* <p>
* <strong>IMPLEMENTATION NOTE</strong> - Local repositories are searched in
* calls to <code>addRepository()</code> or <code>addJar()</code>.
* <p>
* <strong>IMPLEMENTATION NOTE</strong> - No check for sealing violations or
* security is made unless a security manager is present.
*
* @author Remy Maucherat
* @author Craig R. McClanahan
* @version $Revision: 1.1.2.1 $ $Date: 2007/08/17 15:46:27 $
*/
public class WebappClassLoader
extends URLClassLoader
{
// ------------------------------------------------------- Static Variables
/**
* Set of package names which are not allowed to be loaded from a webapp
* class loader without delegating first.
*/
"javax", // Java extensions
// START PE 4985680
"sun", // Sun classes
// END PE 4985680
"org.xml.sax", // SAX 1 & 2
"org.w3c.dom", // DOM 1 & 2
"org.apache.taglibs.standard", // JSTL (Java EE 5)
"com.sun.faces", // JSF (Java EE 5)
"org.apache.commons.logging" // Commons logging
};
public static final boolean ENABLE_CLEAR_REFERENCES =
Boolean.valueOf(System.getProperty("org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES", "true")).booleanValue();
/**
* All permission.
*/
// ----------------------------------------------------- Instance Variables
// START PE 4989455
/**
* Use this variable to invoke the security manager when a resource is
* loaded by this classloader.
*/
private boolean packageDefinitionEnabled =
// END OF PE 4989455
/**
* Associated directory context giving access to the resources in this
* webapp.
*/
/**
* The cache of ResourceEntry for classes and resources we have loaded,
* keyed by resource name.
*/
/**
* The list of not found resources.
*/
/**
* The debugging detail level of this component.
*/
/**
* Should this class loader delegate to the parent class loader
* <strong>before</strong> searching its own repositories (i.e. the
* usual Java2 delegation model)? If set to <code>false</code>,
* this class loader will search its own repositories first, and
* delegate to the parent only if the class or resource is not
* found locally.
*/
protected boolean delegate = false;
/**
* Last time a JAR was accessed.
*/
/**
* The list of local repositories, in the order they should be searched
* for locally loaded classes or resources.
*/
/**
* Repositories URLs, used to cache the result of getURLs.
*/
/**
* Repositories translated as path in the work directory (for Jasper
* originally), but which is used to generate fake URLs should getURLs be
* called.
*/
/**
* The list of JARs, in the order they should be searched
* for locally loaded classes or resources.
*/
/**
* The list of JARs, in the order they should be searched
* for locally loaded classes or resources.
*/
/**
* The path which will be monitored for added Jar files.
*/
/**
* The list of JARs, in the order they should be searched
* for locally loaded classes or resources.
*/
/**
* The list of JARs last modified dates, in the order they should be
* searched for locally loaded classes or resources.
*/
/**
* The list of resources which should be checked when checking for
* modifications.
*/
/**
* A list of read File and Jndi Permission's required if this loader
* is for a web application context.
*/
new ConcurrentLinkedQueue<Permission>();
/**
* Path where resources loaded from JARs will be extracted.
*/
/**
* The PermissionCollection for each CodeSource for a web
* application context.
*/
/**
* Instance of the SecurityManager installed.
*/
/**
* The parent class loader.
*/
/**
* The system class loader.
*/
/**
* Has this component been started?
*/
protected boolean started = false;
/**
* Has external repositories.
*/
protected boolean hasExternalRepositories = false;
// START SJSAS 6344989
/**
* List of byte code pre-processors per webapp class loader.
*/
// END SJSAS 6344989
private boolean useMyFaces;
// START PE 4985680
/**
* List of packages that may always be overridden, regardless of whether
* they belong to a protected namespace (i.e., a namespace that may never
* be overridden by any webapp)
*/
// END PE 4985680
private volatile boolean resourcesExtracted = false;
// ----------------------------------------------------------- Constructors
/**
* Construct a new ClassLoader with no defined repositories and no
* parent ClassLoader.
*/
public WebappClassLoader() {
super(new URL[0]);
init();
}
/**
* Construct a new ClassLoader with the given parent ClassLoader,
* but no defined repositories.
*/
init();
}
/**
* Construct a new ClassLoader with the given parent ClassLoader
* and defined repositories.
*/
}
}
init();
}
// ------------------------------------------------------------- Properties
protected class PrivilegedFindResource
implements PrivilegedAction<ResourceEntry> {
}
}
}
protected static final class PrivilegedGetClassLoader
implements PrivilegedAction<ClassLoader> {
}
return clazz.getClassLoader();
}
}
// START PE 4985680
/**
* Adds the given package name to the list of packages that may always be
* overriden, regardless of whether they belong to a protected namespace
*/
if (overridablePackages == null){
}
}
// END PE 4985680
/**
* Get associated resources.
*/
return this.resources;
}
/**
* Set associated resources.
*/
}
return resourceEntries;
}
/**
* Return the debugging detail level for this component.
*/
public int getDebug() {
return (this.debug);
}
/**
* Set the debugging detail level for this component.
*
* @param debug The new debugging detail level
*/
}
/**
* Return the "delegate first" flag for this class loader.
*/
public boolean getDelegate() {
return (this.delegate);
}
/**
* Set the "delegate first" flag for this class loader.
*
* @param delegate The new "delegate first" flag
*/
}
/**
* If there is a Java SecurityManager create a read FilePermission
* or JndiPermission for the file directory path.
*
* @param path file directory path
*/
return;
}
if (securityManager != null) {
}
} else {
}
}
}
}
/**
* If there is a Java SecurityManager create a read FilePermission
* or JndiPermission for URL.
*
* @param url URL for a file or directory on local system
*/
}
}
/**
* If there is a Java SecurityManager create a Permission.
*
* @param permission permission to add
*/
}
}
/**
* Return the JAR path.
*/
return this.jarPath;
}
/**
* Change the Jar path.
*/
}
/**
* Change the work directory.
*/
try {
}
} catch (IOException ioe) {
}
}
this.useMyFaces = useMyFaces;
if (useMyFaces) {
addOverridablePackage("javax.faces");
addOverridablePackage("com.sun.faces");
}
}
// ------------------------------------------------------- Reloader Methods
/**
* Add a new repository to the set of places this ClassLoader can look for
* classes to be loaded.
*
* @param repository Name of a source of classes to be loaded, such as a
* directory pathname, a JAR file pathname, or a ZIP file pathname
*
* @exception IllegalArgumentException if the specified repository is
* invalid or does not exist
*/
// Ignore any of the standard repositories, as they are set up using
// either addJar or addRepository
return;
// Add this repository to our underlying class loader
try {
} catch (MalformedURLException e) {
("Invalid repository: " + repository);
throw iae;
}
}
hasExternalRepositories = true;
}
/**
* Add a new repository to the set of places this ClassLoader can look for
* classes to be loaded.
*
* @param repository Name of a source of classes to be loaded, such as a
* directory pathname, a JAR file pathname, or a ZIP file pathname
*
* @exception IllegalArgumentException if the specified repository is
* invalid or does not exist
*/
// Note : There should be only one (of course), but I think we should
// keep this a bit generic
if (repository == null)
return;
int i;
// Add this repository to our internal list
result[i] = repositories[i];
}
// Add the file to the list
}
}
throws IOException {
return;
return;
return;
// See IT 11417
int i;
}
}
try {
// Register the JAR for tracking
long lastModified =
.getLastModified();
}
result3[i] = lastModifiedDates[i];
}
} catch (NamingException e) {
// Ignore
}
}
// Add the file to the list
result4[i] = jarRealFiles[i];
}
}
/**
* Have one or more classes or resources been modified so that a reload
* is appropriate?
*/
public boolean modified() {
// Checking for modified loaded resources
// A rare race condition can occur in the updates of the two arrays
// It's totally ok if the latest class added is not checked (it will
// be checked the next time
for (int i = 0; i < length; i++) {
try {
long lastModified =
.getLastModified();
if (lastModified != lastModifiedDates[i]) {
+ "' was modified; Date is now: "
return (true);
}
} catch (NamingException e) {
return (true);
}
}
// Check if JARs have been added or removed
if (getJarPath() != null) {
try {
int i = 0;
// Ignore non JARs present in the lib folder
// START OF IASRI 4657979
// END OF IASRI 4657979
continue;
// Missing JAR
+ name + "'");
return (true);
}
i++;
}
if (enumeration.hasMoreElements()) {
while (enumeration.hasMoreElements()) {
// Additional non-JAR files are allowed
// START OF IASRI 4657979
// END OF IASRI 4657979
// There was more JARs
return (true);
}
}
// There was less JARs
return (true);
}
} catch (NamingException e) {
+ getJarPath() + "'");
} catch (ClassCastException e) {
}
}
// No classes have been modified
return (false);
}
/**
* Render a String representation of this object.
*/
if (repositories != null) {
}
}
}
}
// ---------------------------------------------------- ClassLoader Methods
/**
* Find the specified class in our local repositories, if possible. If
* not found, throw <code>ClassNotFoundException</code>.
*
* @param name Name of the class to be loaded
*
* @exception ClassNotFoundException if the class was not found
*/
// (1) Permission to define this class when using a SecurityManager
// START PE 4989455
//if (securityManager != null) {
// END PE 4989455
if (i >= 0) {
try {
}
}
}
// Ask our superclass to locate this class, if possible
// (throws ClassNotFoundException if it is not found)
try {
try {
// Create the code source object
synchronized (this) {
/* START GlassFish [680]
clazz = defineClass(name, entry.binaryContent, 0,
entry.binaryContent.length,
codeSource);
*/
// START GlassFish [680]
// We use a temporary byte[] so that we don't change
// the content of entry in case bytecode
// preprocessing takes place.
if (!byteCodePreprocessors.isEmpty()) {
// ByteCodePreprpcessor expects name as
// java/lang/Object.class
}
}
// END GlassFish [680]
} else {
}
}
} catch(ClassNotFoundException cnfe) {
if (!hasExternalRepositories) {
throw cnfe;
}
} catch (UnsupportedClassVersionError ucve) {
"webappClassLoader.unsupportedVersion");
throw new UnsupportedClassVersionError(msg);
} catch(AccessControlException ace) {
}
} catch(RuntimeException rex) {
throw rex;
throw err;
} catch (Throwable t) {
"webappClassLoader.unableToLoadClass");
throw new RuntimeException(msg, t);
}
try {
} catch(AccessControlException ace) {
}
} catch (RuntimeException e) {
throw e;
}
}
throw new ClassNotFoundException(name);
}
} catch (ClassNotFoundException e) {
throw e;
}
// Return the class we have located
if (securityManager != null) {
new PrivilegedGetClassLoader(clazz));
} else {
}
}
return (clazz);
}
/**
* Find the specified resource in our local repository, and return a
* <code>URL</code> referring to it, or <code>null</code> if this resource
* cannot be found.
*
* @param name Name of the resource to be found
*/
return findResource(name, false);
}
name = "";
}
}
}
else
}
return (url);
}
/**
* Return an enumeration of <code>URLs</code> representing all of the
* resources with the given name. If no resources with this name are
* found, return an empty enumeration.
*
* @param name Name of the resources to be found
*
*/
if (repositories != null) {
int i;
// Looking at the repositories
for (i = 0; i < repositoriesLength; i++) {
try {
// Note : Not getting an exception here means the resource was
// found
try {
} catch (MalformedURLException e) {
// Ignore
}
} catch (NamingException e) {
}
}
}
while (otherResourcePaths.hasMoreElements()) {
}
}
/**
* From the resource with the given name. This is the same as findResouce
* except that the resources from the local files are excluded. This is
*/
return getResource(name, true);
}
/**
* Find the resource with the given name. A resource is some data
* (images, audio, text, etc.) that can be accessed by class code in a
* way that is independent of the location of the code. The name of a
* resource is a "/"-separated path name that identifies the resource.
* If the resource cannot be found, return <code>null</code>.
* <p>
* This method searches according to the following algorithm, returning
* as soon as it finds the appropriate URL. If the resource cannot be
* found, returns <code>null</code>.
* <ul>
* <li>If the <code>delegate</code> property is set to <code>true</code>,
* call the <code>getResource()</code> method of the parent class
* loader, if any.</li>
* <li>Call <code>findResource()</code> to find this resource in our
* locally defined repositories.</li>
* <li>Call the <code>getResource()</code> method of the parent class
* loader, if any.</li>
* </ul>
*
* @param name Name of the resource to return a URL for
*/
return getResource(name, false);
}
/*
* (1) Delegate to parent if requested, or if the requested resource
* belongs to one of the packages that are part of the Java EE platform
*/
if (isResourceDelegate(name)) {
return (url);
}
}
// (2) Search local repositories
// Locating the repository for special handling in the case
// of a JAR
try {
// Copy binary content to the work directory if not present
}
} catch (Exception e) {
// Ignore
}
return (url);
}
// (3) Delegate to parent unconditionally if not already attempted
if (!delegate) {
return (url);
}
}
// (4) Resource was not found
return (null);
}
/**
* Find the resource with the given name, and return an input stream
* that can be used for reading it. The search order is as described
* for <code>getResource()</code>, after checking to see if the resource
* data has been previously cached. If the resource cannot be found,
* return <code>null</code>.
*
* @param name Name of the resource to return an input stream for
*/
// (0) Check for a cached copy of this resource
return (stream);
}
/*
* (1) Delegate to parent if requested, or if the requested resource
* belongs to one of the packages that are part of the Java EE platform
*/
if (isResourceDelegate(name)) {
// FIXME - cache???
return (stream);
}
}
// (2) Search local repositories
// FIXME - cache???
try {
} catch (IOException e) {
; // Ignore
}
return (stream);
}
// (3) Delegate to parent unconditionally
if (!delegate) {
// FIXME - cache???
return (stream);
}
}
// (4) Resource was not found
return (null);
}
/**
* Finds all the resources with the given name.
*/
} else {
}
if (delegate) {
} else {
}
return new Enumeration<URL>() {
int index = 0;
private boolean next() {
return true;
}
index++;
}
return false;
}
public boolean hasMoreElements() {
return next();
}
public URL nextElement() {
if (!next()) {
throw new NoSuchElementException();
}
}
};
}
/**
* Load the class with the specified name. This method searches for
* classes in the same manner as <code>loadClass(String, boolean)</code>
* with <code>false</code> as the second argument.
*
* @param name Name of the class to be loaded
*
* @exception ClassNotFoundException if the class was not found
*/
}
/**
* Load the class with the specified name, searching using the following
* algorithm until it finds and returns the class. If the class cannot
* be found, returns <code>ClassNotFoundException</code>.
* <ul>
* <li>Call <code>findLoadedClass(String)</code> to check if the
* class has already been loaded. If it has, the same
* <code>Class</code> object is returned.</li>
* <li>If the <code>delegate</code> property is set to <code>true</code>,
* call the <code>loadClass()</code> method of the parent class
* loader, if any.</li>
* <li>Call <code>findClass()</code> to find this class in our locally
* defined repositories.</li>
* <li>Call the <code>loadClass()</code> method of our parent
* class loader, if any.</li>
* </ul>
* If the class was found using the above steps, and the
* <code>resolve</code> flag is <code>true</code>, this method will then
* call <code>resolveClass(Class)</code> on the resulting Class object.
*
* @param name Name of the class to be loaded
* @param resolve If <code>true</code> then resolve the class
*
* @exception ClassNotFoundException if the class was not found
*/
throws ClassNotFoundException {
}
// Don't load classes if class loader is stopped
if (!started) {
throw new IllegalStateException(
}
// (0) Check our previously loaded local class cache
}
if (resolve)
return (clazz);
}
// (0.1) Check our previously loaded class cache
}
if (resolve)
return (clazz);
}
// (0.5) Permission to access this class when using a SecurityManager
if (i >= 0) {
try {
} catch (SecurityException se) {
"Restricted Class: " + name;
}
}
}
if (delegateLoader == null) {
}
// (1) Delegate to our parent if requested
if (delegateLoad) {
// Check delegate first
}
try {
}
if (resolve)
return clazz;
}
} catch (ClassNotFoundException e) {
// Ignore
}
}
// (2) Search local repositories
}
try {
}
if (resolve)
return clazz;
}
} catch (ClassNotFoundException e) {
// Ignore
}
// (3) Delegate if class was not found locally
if (!delegateLoad) {
}
try {
}
if (resolve)
return clazz;
}
} catch (ClassNotFoundException e) {
// Ignore
}
}
throw new ClassNotFoundException(name);
}
/**
* Get the Permissions for a CodeSource. If this instance
* of WebappClassLoader is for a web application context,
* add read FilePermission or JndiPermissions for the base
* directory (if unpacked),
* the context URL, and jar file resources.
*
* @param codeSource where the code was loaded from
* @return PermissionCollection for CodeSource
*/
}
}
}
return (pc);
}
/**
* Returns the search path of URLs for loading classes and resources.
* This includes the original list of URLs specified to the constructor,
* along with any URLs subsequently appended by the addURL() method.
* @return the search path of URLs for loading classes and resources.
*/
if (repositoryURLs != null) {
return repositoryURLs;
}
int i;
try {
for (i = 0; i < length; i++) {
if (i < filesLength) {
} else if (i < filesLength + jarFilesLength) {
} else {
}
}
} catch (MalformedURLException e) {
}
return repositoryURLs;
}
@SuppressWarnings("unchecked")
}
// ------------------------------------------------------ Lifecycle Methods
private void init() {
/* SJSAS 6317864
system = getSystemClassLoader();
*/
// START SJSAS 6317864
// END SJSAS 6317864
if (securityManager != null) {
}
addOverridablePackage("com.sun.faces.extensions");
}
/**
* Start the class loader.
*/
public void start() {
started = true;
}
public boolean isStarted() {
return started;
}
public void preDestroy() {
try {
stop();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Stop the class loader.
*
* @exception LifecycleException if a lifecycle error occurs
*/
if (!started) {
return;
}
// START GlassFish Issue 587
// END GlassFish Issue 587
/*
* Clearing references should be done before setting started to
* false, due to possible side effects.
* In addition, set this classloader as the Thread's context
* classloader, see IT 9894 for details
*/
try {
} finally {
}
}
// START SJSAS 6258619
ClassLoaderUtil.releaseLoader(this);
// END SJSAS 6258619
started = false;
for (int i = 0; i < length; i++) {
}
for (int i = 0; i < length; i++) {
try {
}
} catch (IOException e) {
// Ignore
}
}
try {
URLClassLoader.class);
if (m != null) {
}
}
} catch (Exception e) {
// ignore
}
repositories = null;
jarRealFiles = null;
hasExternalRepositories = false;
}
DirContextURLStreamHandler.unbind(this);
}
/**
* Used to periodically signal to the classloader to release
* JAR resources.
*/
synchronized (jarFiles) {
> (lastJarAccessed + 90000))) {
try {
}
} catch (IOException e) {
}
}
}
}
}
}
}
/**
* Clear references.
*/
protected void clearReferences() {
// Unregister any JDBC drivers loaded by this classloader
while (drivers.hasMoreElements()) {
try {
} catch (SQLException e) {
}
}
}
// Null out any static or final fields from loaded classes,
// as a workaround for apparent garbage collection bugs
if (ENABLE_CLEAR_REFERENCES) {
/*
* Step 1: Enumerate all classes loaded by this WebappClassLoader
* and trigger the initialization of any uninitialized ones.
* This is to prevent the scenario where the initialization of
* one class would call a previously cleared class in Step 2 below.
*/
while(loadedClasses.hasNext()) {
synchronized(this) {
}
try {
break;
}
}
} catch(Throwable t) {
}
}
}
/**
* Step 2: Clear all loaded classes
*/
while (loadedClasses.hasNext()) {
synchronized(this) {
}
try {
continue;
}
try {
}
} else {
}
}
} catch (Throwable t) {
}
}
}
}
} catch (Throwable t) {
}
}
}
}
}
// Clear the classloader reference in the VM's bean introspector
}
return;
}
continue;
}
try {
// Doing something recursively is too risky
continue;
} else {
if (!loadedByThisOrChild(valueClass)) {
" to null in object of class " +
" because the referenced object was of type " +
valueClass.getName() +
" which was not loaded by this WebappClassLoader.");
}
} else {
}
}
}
} catch (Throwable t) {
+ " to null in object instance of class "
}
}
}
}
/**
* Determine whether a class was loaded by this class loader or one of
* its child class loaders.
*/
boolean result = false;
if (classLoader.equals(this)) {
result = true;
break;
}
}
return result;
}
// ------------------------------------------------------ Protected Methods
/**
* Used to periodically signal to the classloader to release JAR resources.
*/
protected boolean openJARs() {
try {
} catch (IOException e) {
}
for (int j = 0; j < i; j++) {
try {
} catch (Throwable t) {
// Ignore
}
}
return false;
}
}
}
}
return true;
}
/**
* Find specified class in local repositories.
*
* @return the loaded class, or null if the class isn't found
*/
throws ClassNotFoundException {
throw new ClassNotFoundException(name);
throw new ClassNotFoundException(name);
synchronized (this) {
return entry;
throw new ClassNotFoundException(name);
}
// Looking up the package
if (pos != -1)
if (packageName != null) {
// START OF IASRI 4717252
synchronized (loaderPC) {
// END OF IASRI 4717252
// Define the package (if null)
} else {
}
}
// START OF IASRI 4717252
}
// END OF IASRI 4717252
}
if (securityManager != null) {
// Checking sealing
boolean sealCheck = true;
} else {
}
if (!sealCheck)
throw new SecurityException
+ packageName + " is sealed.");
}
}
return entry;
}
/**
* Find specified resource in local repositories. This block
* will execute under an AccessControl.doPrivilege block.
*
* @return the loaded resource, or null if the resource isn't found
*/
try {
} catch (MalformedURLException e) {
return null;
}
return entry;
}
/**
* Attempts to find the specified resource in local repositories.
*
* @return the loaded resource, or null if the resource isn't found
*/
}
boolean fromJarsOnly) {
if (!started) {
throw new IllegalStateException(
}
return null;
}
return entry;
return null;
}
if (! fromJarsOnly) {
}
synchronized (jarFiles) {
}
}
return null;
}
// Add the entry in the local resource repository
// Ensures that all the threads which may be in a race to load
// a particular class all end up with the same ResourceEntry
// instance
}
return entry;
}
/**
* Attempts to load the requested resource from this classloader's
* internal repositories.
*
* @return The requested resource, or null if not found
*/
if (repositories == null) {
return null;
}
int contentLength = -1;
try {
if (lookupResult instanceof Resource) {
}
// Note : Not getting an exception here means the resource was
// found
if (securityManager != null) {
} else {
}
try {
} catch (IOException e) {
return null;
}
// Register the full path for modification checking
// Note: Only syncing on a 'constant' object is needed
synchronized (ALL_PERMISSION) {
int j;
long[] result2 =
result2[j] = lastModifiedDates[j];
}
}
}
}
} catch (NamingException e) {
}
}
}
return entry;
}
/**
* Attempts to load the requested resource from this classloader's
* JAR files.
*
* @return The requested resource, or null if not found
*/
int contentLength = -1;
if (!openJARs()){
return null;
}
entry = new ResourceEntry();
try {
} catch (MalformedURLException e) {
return null;
}
try {
} catch (IOException e) {
return null;
}
// Extract resources contained in JAR to the workdir
if (!resourceFile.exists()) {
}
}
}
}
}
return entry;
}
private synchronized void extractResources() {
if (resourcesExtracted) {
return;
}
extractResource(jarFiles[i]);
}
resourcesExtracted = true;
}
byte[] buf = new byte[1024];
while (entries.hasMoreElements()) {
if (!(jarEntry2.isDirectory())
try {
throw new IllegalArgumentException(msg);
}
} catch (IOException ioe) {
throw new IllegalArgumentException(msg);
}
try {
while (true) {
if (n <= 0) {
break;
}
}
} catch (IOException e) {
// Ignore
} finally {
try {
}
} catch (IOException e) {
}
try {
}
} catch (IOException e) {
}
}
}
}
}
}
/**
* Reads the resource's binary data from the given input stream.
*/
int contentLength,
if (binaryStream == null) {
return;
}
byte[] binaryContent = new byte[contentLength];
try {
int pos = 0;
while (true) {
if (n <= 0)
break;
pos += n;
}
} catch (Exception e) {
return;
} finally {
try {
} catch(IOException e) {
}
}
// START OF IASRI 4709374
// Preprocess the loaded byte code if bytecode preprocesser is
// enabled
if (PreprocessorUtil.isPreprocessorEnabled()) {
}
// END OF IASRI 4709374
// The certificates are only available after the JarEntry
// associated input stream has been fully read
}
}
/**
* Returns true if the specified package name is sealed according to the
* given manifest.
*/
}
}
}
}
/**
* Finds the resource with the given name if it has previously been
* loaded and cached by this class loader, and return an input stream
* to the resource data. If this resource has not been cached, return
* <code>null</code>.
*
* @param name Name of the resource to return
*/
}
return (null);
}
/**
* Finds the class with the given name if it has previously been
* loaded and cached by this class loader, and return the Class object.
* If this class has not been cached, return <code>null</code>.
*
* @param name Name of the resource to return
*/
synchronized(this) {
return entry.loadedClass;
}
}
return (null); // FIXME - findLoadedResource()
}
/**
* Refresh the system policy file, to pick up eventual changes.
*/
protected void refreshPolicy() {
try {
// The policy file may have been modified to adjust
// permissions, so we're reloading it when loading or
// reloading a Context
} catch (AccessControlException e) {
// Some policy files may restrict this, even for the core,
// so this exception is ignored
}
}
/**
* Filter classes.
*
* @param name class name
* @return true if the class should be filtered
*/
return false;
// START PE 4985680
// Special case for performance reason.
return true;
// END PE 4985680
// Looking up the package
if (pos != -1)
else
return false;
if (overridablePackages != null){
return false;
}
}
return true;
}
return false;
}
/**
* Validate a classname. As per SRV.9.7.2, we must restrict loading of
* classes from J2SE (java.*) and classes of the servlet API
* (javax.servlet.*). That should enhance robustness and prevent a number
* of user error (where an older version of servlet.jar would be present
*
* @param name class name
* @return true if the name is valid
*/
return false;
return false;
return true;
}
/**
* Get URL.
*/
throws MalformedURLException {
try {
} catch (IOException e) {
// Ignore
}
}
/**
* Get URL.
*/
throws MalformedURLException {
try {
} catch (IOException e) {
// Ignore
}
}
/**
* Delete the specified directory, including all of its contents and
* subdirectories recursively.
*
* @param dir File object representing the directory to be deleted
*/
}
if (file.isDirectory()) {
} else {
}
}
}
// START SJSAS 6344989
}
// END SJSAS 6344989
// START GlassFish Issue 587
/*
* Purges all bean classes that were loaded by this WebappClassLoader
* from the caches maintained by javax.el.BeanELResolver, in order to
* avoid this WebappClassLoader from leaking.
*/
private void purgeELBeanClasses() {
break;
}
}
}
/*
* Purges all bean classes that were loaded by this WebappClassLoader
* from the cache represented by the given reflected field.
*
* @param fld The reflected field from which to remove the bean classes
* that were loaded by this WebappClassLoader
*/
try {
} catch (IllegalAccessException iae) {
return;
}
if (m.size() == 0) {
return;
}
}
}
}
@SuppressWarnings("unchecked")
}
// END GlassFish Issue 587
/**
* Create and return a temporary loader with the same visibility
* as this loader. The temporary loader may be used to load
* resources or any other application classes for the purposes of
* introspecting them for annotations. The persistence provider
* should not maintain any references to the temporary loader,
* or any objects loaded by it.
*
* @return A temporary classloader with the same classpath as this loader
*/
// set getParent() as the parent of the cloned class loader
}
/**
* Add a new ClassFileTransformer to this class loader. This transfomer should be called for
* each class loading event.
*
* @param transformer new class file transformer to do byte code enhancement.
*/
final WebappClassLoader cl = this;
/*
* This class adapts ClassFileTransformer to ByteCodePreprocessor that
* is used inside WebappClassLoader.
*/
return true;
}
try {
// ClassFileTransformer returns null if no transformation
// took place, where as ByteCodePreprocessor is expected
// to return non-null byte array.
} catch (IllegalClassFormatException e) {
"WebModuleListener$InstrumentableClassLoader$BytecodePreprocessor",
"preprocess", e.getMessage());
throw new RuntimeException(e);
}
}
});
}
new PrivilegedAction<String>() {
}
});
} else {
}
return version;
}
field.setAccessible(true);
return null;
}
});
} else {
field.setAccessible(true);
}
}
/**
* To determine whether one should delegate to parent for loading
* resource of the given resource name.
*
* @param name
*/
return (delegate
}
}