Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) 2015 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.bonitasoft.engine.classloader;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.CodeSource;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.cert.Certificate;
import java.util.Enumeration;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.apache.xbean.classloader.NamedClassLoader;
import org.apache.xbean.classloader.ResourceHandle;
import org.apache.xbean.classloader.UnionEnumeration;
import org.apache.xbean.classloader.UrlResourceFinder;
/**
* This class is higlhy inspired form JarFileClassLoader from xbean. The main diffrence is that
* it inherits from NamedClassLoader instead of MultiParentClassLoader.
*/
public class MonoParentJarFileClassLoader extends NamedClassLoader {
private static final URL[] EMPTY_URLS = new URL[0];
private final UrlResourceFinder resourceFinder = new UrlResourceFinder();
private final AccessControlContext acc;
/**
* Creates a JarFileClassLoader that is a child of the system class loader.
*
* @param name
* the name of this class loader
* @param urls
* a list of URLs from which classes and resources should be loaded
*/
public MonoParentJarFileClassLoader(String name, URL[] urls) {
super(name, EMPTY_URLS);
this.acc = AccessController.getContext();
addURLs(urls);
}
/**
* Creates a JarFileClassLoader that is a child of the specified class loader.
*
* @param name
* the name of this class loader
* @param urls
* a list of URLs from which classes and resources should be loaded
* @param parent
* the parent of this class loader
*/
public MonoParentJarFileClassLoader(String name, URL[] urls, ClassLoader parent) {
super(name, EMPTY_URLS, parent);
this.acc = AccessController.getContext();
addURLs(urls);
}
/**
* {@inheritDoc}
*/
@Override
public URL[] getURLs() {
return this.resourceFinder.getUrls();
}
/**
* {@inheritDoc}
*/
@Override
public void addURL(final URL url) {
AccessController.doPrivileged(new PrivilegedAction