001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package net.tridentsdk.plugin;
018
019import net.tridentsdk.docs.PossiblyThreadSafe;
020
021import java.util.Map;
022
023/**
024 * Loads plugin classes
025 *
026 * @author The TridentSDK Team
027 * @since 0.4-alpha
028 */
029@PossiblyThreadSafe
030public interface PluginLoader {
031    /**
032     * Links all of the class dependencies
033     *
034     * @param c the class to link
035     */
036    void link(Class<?> c);
037
038    /**
039     * Creates a new Java class object for the class and the class source given
040     *
041     * @param name   the class name
042     * @param source the class bytecode
043     * @return the class representing the bytes given
044     */
045    Class<?> defineClass(String name, byte[] source);
046
047    /**
048     * Lists the class as loaded
049     *
050     * @param cls the class to list
051     */
052    void putClass(Class<?> cls);
053
054    /**
055     * Obtains the classes loaded by this plugin loader
056     *
057     * @return the class mapped to the class name, class
058     */
059    Map<String, Class<?>> loadedClasses();
060
061    /**
062     * Unloads the classes that were loaded from this class loader
063     */
064    void unloadClasses();
065}