All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alee.managers.plugin.PluginClassLoader Maven / Gradle / Ivy

The newest version!
/*
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see .
 */

package com.alee.managers.plugin;

import com.alee.api.annotations.NotNull;

import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory;

/**
 * Custom {@link ClassLoader} for plugins based on {@link URLClassLoader}.
 * This class loader is used when a sandbox is required for loaded plugins.
 *
 * @author Mikle Garin
 */
public class PluginClassLoader extends URLClassLoader
{
    /**
     * Constructs a new {@link PluginClassLoader} for the given URLs.
     * The URLs will be searched in the order specified for classes and resources after first searching in the specified parent class
     * loader. Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which
     * will be downloaded and opened as needed.
     *
     * 

If there is a security manager, this method first calls the security manager's {@code checkCreateClassLoader} method to ensure * creation of a class loader is allowed. * * @param urls the URLs from which to load classes and resources * @param parent the parent class loader for delegation * @throws SecurityException if a security manager exists and its {@code checkCreateClassLoader} * method doesn't allow creation of a class loader * @see SecurityManager#checkCreateClassLoader */ public PluginClassLoader ( @NotNull final URL[] urls, @NotNull final ClassLoader parent ) { super ( urls, parent ); } /** * Constructs a new {@link PluginClassLoader} for the specified URLs using the default delegation parent {@code ClassLoader}. * The URLs will be searched in the order specified for classes and resources after first searching in the parent class loader. * Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which will be * downloaded and opened as needed. * *

If there is a security manager, this method first calls the security manager's {@code checkCreateClassLoader} method to ensure * creation of a class loader is allowed. * * @param urls the URLs from which to load classes and resources * @throws SecurityException if a security manager exists and its {@code checkCreateClassLoader} * method doesn't allow creation of a class loader. * @see SecurityManager#checkCreateClassLoader */ public PluginClassLoader ( @NotNull final URL[] urls ) { super ( urls ); } /** * Constructs a new {@link PluginClassLoader} for the specified URLs, parent class loader, and URLStreamHandlerFactory. * The parent argument will be used as the parent class loader for delegation. * The factory argument will be used as the stream handler factory to obtain protocol handlers when creating new jar URLs. * *

If there is a security manager, this method first calls the security manager's {@code checkCreateClassLoader} method to ensure * creation of a class loader is allowed. * * @param urls the URLs from which to load classes and resources * @param parent the parent class loader for delegation * @param factory the URLStreamHandlerFactory to use when creating URLs * @throws SecurityException if a security manager exists and its{@code checkCreateClassLoader} * method doesn't allow creation of a class loader. * @see SecurityManager#checkCreateClassLoader */ public PluginClassLoader ( @NotNull final URL[] urls, @NotNull final ClassLoader parent, @NotNull final URLStreamHandlerFactory factory ) { super ( urls, parent, factory ); } /** * Adds specified {@link URL} to the classpath of this {@link ClassLoader}. * * @param url {@link URL} to the add to the classpath of this {@link ClassLoader} */ @Override public void addURL ( @NotNull final URL url ) { super.addURL ( url ); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy