public class ServiceManager
extends java.lang.Object
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 factory method for this
service singleton. The ServiceManager manages named singletons
created from these factory methods.
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
.
FoldHandler
FoldPainter
VFS
Encoding
EncodingDetector
StatusWidgetFactory
DockingFrameworkProvider
JEditTrayIcon
getServiceTypes()
.
getServiceNames(String)
and getService(String,String)
.Modifier and Type | Class and Description |
---|---|
static class |
ServiceManager.ServiceFoldHandlerProvider
A FoldHandler based on the ServiceManager
|
Constructor and Description |
---|
ServiceManager() |
Modifier and Type | Method and Description |
---|---|
static <E> E |
getService(java.lang.Class<E> clazz,
java.lang.String name)
Returns an instance of the given service.
|
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.Class clazz) |
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.
|
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.String[] getServiceNames(java.lang.Class clazz)
public static java.lang.Object getService(java.lang.String clazz, java.lang.String name)
clazz
- The service classname
- The service namepublic static <E> E getService(java.lang.Class<E> clazz, java.lang.String name)
clazz
- The service classname
- The service name