|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.gjt.sp.jedit.ServiceManager
public class ServiceManager
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.
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.
SERVICE
element should the BeanShell code that returns a
new instance of the named class. Note that this code can return
null
.
To have your plugin accept services, no extra steps are needed other than
a piece of code somewhere that calls getServiceNames(String)
and
getService(String,String)
.
BeanShell
,
PluginJAR
Constructor Summary | |
---|---|
ServiceManager()
|
Method Summary | |
---|---|
static java.lang.Object |
getService(java.lang.String clazz,
java.lang.String name)
Returns an instance of the given service. |
static java.lang.String[] |
getServiceNames(java.lang.String clazz)
Returns the names of all registered services with the given class. |
static java.lang.String[] |
getServiceTypes()
Returns all known service class types. |
static void |
loadServices(PluginJAR plugin,
java.net.URL uri,
PluginJAR.PluginCacheEntry cache)
Loads a services.xml file. |
static void |
registerService(java.lang.String clazz,
java.lang.String name,
java.lang.String code,
PluginJAR plugin)
Registers a service. |
static void |
unloadServices(PluginJAR plugin)
Removes all services belonging to the specified plugin. |
static void |
unregisterService(java.lang.String clazz,
java.lang.String name)
Unregisters a service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServiceManager()
Method Detail |
---|
public static void loadServices(PluginJAR plugin, java.net.URL uri, PluginJAR.PluginCacheEntry cache)
services.xml
file.
public static void unloadServices(PluginJAR plugin)
plugin
- The pluginpublic static void registerService(java.lang.String clazz, java.lang.String name, java.lang.String code, PluginJAR plugin)
services.xml
file instead of calling this directly.
clazz
- The service classname
- The service namecode
- BeanShell code to create an instance of thisplugin
- The plugin JAR, or null if this is a built-in servicepublic static void unregisterService(java.lang.String clazz, java.lang.String name)
clazz
- The service classname
- The service namepublic static java.lang.String[] getServiceTypes()
public static java.lang.String[] getServiceNames(java.lang.String clazz)
clazz
- The class namepublic static java.lang.Object getService(java.lang.String clazz, java.lang.String name)
clazz
- The service classname
- The service name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |