org.fabric3.spi.classloader.MultiParentClassLoader Maven / Gradle / Ivy
/*
* Fabric3
* Copyright (c) 2009-2015 Metaform Systems
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* Portions originally based on Apache Tuscany 2007
* licensed under the Apache 2.0 license.
*/
package org.fabric3.spi.classloader;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import sun.security.util.SecurityConstants;
import org.fabric3.api.host.classloader.DelegatingResourceClassLoader;
/**
* A classloader implementation that supports a multi-parent hierarchy and extension resolution mechanism. Class resolution is performed in the following
* order:
*
*
* - Parents are searched. Parents will delegate to their classloader hierarchy.
*
- If a resource is not found, the current classloader is searched.
*
- If a resource is not found, extension classloaders are searched. Extension classloaders will not delegate to their classloader hierarchy.
*
*
* The extension mechanism allows classes to be dynamically loaded via Class.forName() and ClassLoader.loadClass(). This is used to accommodate contributions
* and libraries that rely on Java reflection to add additional capabilities provided by another contribution. Since resolution is performed dynamically, cycles
* between classloaders are supported where one classloader is a parent of the other and the former is an extension of the latter.
*
* Each classloader has a name that can be used to reference it in the runtime.
*/
public class MultiParentClassLoader extends DelegatingResourceClassLoader {
private static final URL[] NOURLS = {};
private final URI name;
private final List© 2015 - 2024 Weber Informatics LLC | Privacy Policy