Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.gjt.sp.jedit
Class ServiceManager  view ServiceManager download ServiceManager.java

java.lang.Object
  extended byorg.gjt.sp.jedit.ServiceManager

public class ServiceManager
extends java.lang.Object

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: 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 getServiceNames(String) 55 and getService(String,String) 55 .

Since:
jEdit 4.2pre1
Version:
$Id: ServiceManager.java,v 1.7 2003/05/10 00:43:19 spestov Exp $

Nested Class Summary
(package private) static class ServiceManager.Descriptor
           
 
Field Summary
private static java.util.Map serviceMap
           
 
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.
(package private) static void registerService(ServiceManager.Descriptor d)
          Registers a service.
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
 

Field Detail

serviceMap

private static java.util.Map serviceMap
Constructor Detail

ServiceManager

public ServiceManager()
Method Detail

loadServices

public static void loadServices(PluginJAR plugin,
                                java.net.URL uri,
                                PluginJAR.PluginCacheEntry cache)
Loads a services.xml file.

Since:
jEdit 4.2pre1

unloadServices

public static void unloadServices(PluginJAR plugin)
Removes all services belonging to the specified plugin.

Since:
jEdit 4.2pre1

registerService

public static void registerService(java.lang.String clazz,
                                   java.lang.String name,
                                   java.lang.String code,
                                   PluginJAR plugin)
Registers a service. Plugins should provide a services.xml file instead of calling this directly.

Since:
jEdit 4.2pre1

unregisterService

public static void unregisterService(java.lang.String clazz,
                                     java.lang.String name)
Unregisters a service.

Since:
jEdit 4.2pre1

getServiceTypes

public static java.lang.String[] getServiceTypes()
Returns all known service class types.

Since:
jEdit 4.2pre1

getServiceNames

public static java.lang.String[] getServiceNames(java.lang.String clazz)
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.

Since:
jEdit 4.2pre1

getService

public static java.lang.Object getService(java.lang.String clazz,
                                          java.lang.String name)
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.

Since:
jEdit 4.2pre1

registerService

static void registerService(ServiceManager.Descriptor d)
Registers a service.

Since:
jEdit 4.2pre1