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.concurrent.SelectableThread;
020import net.tridentsdk.registry.Registry;
021
022import javax.annotation.concurrent.ThreadSafe;
023import java.io.File;
024
025/**
026 * Handles server plugins, loading and unloading, class management, and lifecycle management for plugins
027 *
028 * <p>To access this handler, use this code:
029 * <pre><code>
030 *     PluginHandler handler = Registered.plugins();
031 * </code></pre></p>
032 *
033 * @author The TridentSDK Team
034 * @since 0.3-alpha-DP
035 */
036@ThreadSafe
037public interface Plugins extends Registry<Plugin> {
038    /**
039     * Loads the plugin file
040     *
041     * @param pluginFile the plugin file to load
042     */
043    Plugin load(File pluginFile);
044
045    /**
046     * Enables the given plugin
047     *
048     * @param plugin the plugin to enable
049     */
050    void enable(Plugin plugin);
051
052    /**
053     * Disables the plugin unloading the classes and removing the subprocess
054     *
055     * @param plugin the plugin to disable
056     */
057    void disable(Plugin plugin);
058
059    /**
060     * Obtains the worker used to load plugins. Use this executor to send plugin tasks from the server.
061     *
062     * @return the worker
063     */
064    SelectableThread executor();
065}