KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > extensions > types > Plugin


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.extensions.types;
21
22 import org.jdom.Element;
23
24 import com.sslexplorer.extensions.ExtensionDescriptor;
25 import com.sslexplorer.extensions.ExtensionException;
26
27 /**
28  * Interface to be implemented by all extension components that provide one or
29  * more <i>Plugin</i>.
30  * <p>
31  * When the core server starts up, first all plugins have their {@link #startPlugin(PluginDefinition, ExtensionDescriptor, Element)}
32  * method called. Any plugins which throw an exception at this point are discarded
33  * and will not be available for the remaining lifetime of the server.
34  * <p>
35  * Any plugins that successfully initialised are then checked to see if the
36  * have been used before. If they haven't then the {@link #installPlugin()} method
37  * is invoked. Here the plugin may perform any one-off tasks such as adding
38  * default resources.
39  * <p>
40  * Next, the {@link #activatePlugin()} method is called.
41  * <p>
42  * When the server shuts down, the {@link #canStopPlugin()} method is called,
43  * if this is <code>true</code> then the {@link #stopPlugin()} method is called.
44  * <p>
45  * Plugins are defined in the <i>Extension Description</i> for the extension
46  * they are part of. Information required for plugin includes the fully
47  * qualified class name of this interface implementation, sort order, names
48  * and descriptions and dependencies.
49  *
50  * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
51  */

52 public interface Plugin {
53
54     /**
55      * This is the first call to the plugin, made when the server is first
56      * starting up. If an exception is thrown at this point, the plugin will
57      * first be stopped, then ignored for the remainder of the servers lifetime.
58      *
59      * @param definition plugin definition to stop
60      * @param descriptor descriptor
61      * @param element configuration element
62      * @throws ExtensionException on any error
63      */

64     public void startPlugin(PluginDefinition definition, ExtensionDescriptor descriptor, Element element) throws ExtensionException;
65     
66     /**
67      * Start the plugin. Invoked after <i>all</i> registered plugins have had their
68      * {@link #startPlugin(PluginDefinition, ExtensionDescriptor, Element)} method called.
69      *
70      * @throws ExtensionException on any error
71      */

72     public void activatePlugin() throws ExtensionException;
73
74     /**
75      * Get if this plugin may be stopped. This is invoked when the server is
76      * shutting down or when a plugin fails to initialise. If <code>true</code> is returned, then {@link #stopPlugin()}
77      * will be called next. If <code>false</code> is returned, then {@link #stopPlugin()}
78      * will not be called and the plugin manager will attempt to stop the next
79      * registered plugin.
80      *
81      * @return can stop plugin
82      */

83     public boolean canStopPlugin();
84
85     /**
86      * Stop the plugin. This is invoked when the server is
87      * shutting down or when a plugin fails to initialise. It will only be called
88      * if {@link #canStopPlugin()} returned <code>true</code>
89      * @throws ExtensionException TODO
90      */

91     public void stopPlugin() throws ExtensionException;
92
93     /**
94      * If this plugin contributes any new tiles, this method returns the
95      * path to the tiles configure file (within the context of the webapp).
96      *
97      * @return path to tiles configuration resource
98      */

99     public String JavaDoc getTilesConfigFile();
100 }
101
Popular Tags