| java.lang.Object org.gjt.sp.jedit.ServiceManager
ServiceManager | public class ServiceManager (Code) | | A generic way for plugins to provide various API extensions.
Services are loaded from files named services.xml inside the
plugin JAR. A service definition file has the following form:
<?xml version="1.0"?>
<!DOCTYPE SERVICES SYSTEM "services.dtd">
<SERVICES>
<SERVICE NAME="service name" CLASS="fully qualified class name">
// BeanShell code evaluated when the sevice is first activated
</SERVICE>
</SERVICES>
The following elements are valid:
-
SERVICES is the top-level element and refers
to the set of services offered by the plugin.
-
A
SERVICE contains the data for a particular service
activation.
It has two attributes, both required: NAME and
CLASS . The CLASS attribute must be the name of
a known sevice type; see below.
-
A
SERVICE element should the BeanShell code that returns a
new instance of the named class. Note that this code can return
null .
The jEdit core defines the following service types:
Plugins may provide more.
To have your plugin accept services, no extra steps are needed other than
a piece of code somewhere that calls
ServiceManager.getServiceNames(String) and
ServiceManager.getService(String,String) .
See Also: BeanShell See Also: PluginJAR since: jEdit 4.2pre1 author: Slava Pestov version: $Id: ServiceManager.java 9860 2007-06-27 20:58:22Z kpouer $ |
Inner Class :static class Descriptor | |
getService | public static Object getService(String clazz, String name)(Code) | | Returns an instance of the given service. The first time this is
called for a given service, the BeanShell code is evaluated. The
result is cached for future invocations, so in effect services are
singletons.
Parameters: clazz - The service class Parameters: name - The service name since: jEdit 4.2pre1 |
getServiceNames | public static String[] getServiceNames(String clazz)(Code) | | Returns the names of all registered services with the given
class. For example, calling this with a parameter of
"org.gjt.sp.jedit.io.VFS" returns all known virtual file
systems.
Parameters: clazz - The class name since: jEdit 4.2pre1 |
getServiceTypes | public static String[] getServiceTypes()(Code) | | Returns all known service class types.
since: jEdit 4.2pre1 |
registerService | public static void registerService(String clazz, String name, String code, PluginJAR plugin)(Code) | | Registers a service. Plugins should provide a
services.xml file instead of calling this directly.
Parameters: clazz - The service class Parameters: name - The service name Parameters: code - BeanShell code to create an instance of this Parameters: plugin - The plugin JAR, or null if this is a built-in service since: jEdit 4.2pre1 |
registerService | static void registerService(Descriptor d)(Code) | | Registers a service.
since: jEdit 4.2pre1 |
unloadServices | public static void unloadServices(PluginJAR plugin)(Code) | | Removes all services belonging to the specified plugin.
Parameters: plugin - The plugin since: jEdit 4.2pre1 |
unregisterService | public static void unregisterService(String clazz, String name)(Code) | | Unregisters a service.
Parameters: clazz - The service class Parameters: name - The service name since: jEdit 4.2pre1 |
|
|