|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectartofillusion.PluginRegistry
public class PluginRegistry
Nested Class Summary | |
---|---|
static class |
PluginRegistry.PluginResource
A PluginResource represents a resource that was loaded from a plugin. |
Constructor Summary | |
---|---|
PluginRegistry()
|
Method Summary | ||
---|---|---|
static void |
addCategory(java.lang.Class category)
Define a new category of plugins. |
|
static java.util.List<java.lang.Class> |
getCategories()
Get all categories of plugins that have been defined. |
|
static java.util.List<java.lang.String> |
getExportedMethodIds()
Get a list of the identifiers of all exported methods which have been registered. |
|
static java.util.List<java.lang.ClassLoader> |
getPluginClassLoaders()
Get the ClassLoaders for all jar files in the Plugins directory. |
|
static java.lang.Object |
getPluginObject(java.lang.String classname)
Get the registered plugin object of a particular class. |
|
static
|
getPlugins(java.lang.Class<T> category)
Get all registered plugins in a particular category. |
|
static PluginRegistry.PluginResource |
getResource(java.lang.String type,
java.lang.String id)
Get the PluginResource with a particular type and id, or null if there is no such resource. |
|
static java.util.List<PluginRegistry.PluginResource> |
getResources(java.lang.String type)
Get a list of all registered PluginResources of a particular type. |
|
static java.util.List<java.lang.String> |
getResourceTypes()
Get a list of all type identifiers for which there are PluginResources available. |
|
static java.lang.Object |
invokeExportedMethod(java.lang.String id,
java.lang.Object... args)
Invoke an exported method of a plugin object. |
|
static void |
registerExportedMethod(java.lang.Object plugin,
java.lang.String method,
java.lang.String id)
Register a method which may be invoked on a plugin object. |
|
static void |
registerPlugin(java.lang.Object plugin)
Register a new plugin. |
|
static void |
registerResource(java.lang.String type,
java.lang.String id,
java.lang.ClassLoader loader,
java.lang.String name,
java.util.Locale locale)
Register a new resource. |
|
static void |
scanPlugins()
Scan all files in the Plugins directory, read in their indices, and record all plugins contained in them. |
|
static void |
scanPlugins(java.util.List<java.lang.ClassLoader> loaders)
Process a set of ClassLoaders corresponding to jar files, read in their indices, and record all plugins contained in them. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PluginRegistry()
Method Detail |
---|
public static void scanPlugins()
public static void scanPlugins(java.util.List<java.lang.ClassLoader> loaders)
public static java.util.List<java.lang.ClassLoader> getPluginClassLoaders()
public static void addCategory(java.lang.Class category)
registerPlugin(Object)
will check the registered object
to see if it is an instance of the specified class. If so, it is added to the list of plugins
in that category.
public static java.util.List<java.lang.Class> getCategories()
public static void registerPlugin(java.lang.Object plugin)
public static <T> java.util.List<T> getPlugins(java.lang.Class<T> category)
public static java.lang.Object getPluginObject(java.lang.String classname)
getPlugins(Class)
,
the specified class name must be the exact class of the object, not a superclass or interface.
If multiple plugins of the same class have been registered, this returns the most recently
registered one.
classname
- the fully qualified name of the class of the plugin object to return
public static void registerResource(java.lang.String type, java.lang.String id, java.lang.ClassLoader loader, java.lang.String name, java.util.Locale locale) throws java.lang.IllegalArgumentException
getResource(String, String)
to look up
a particular resource, or getResources(String)
to find all registered resources of
a particular type.
type
- the type of resource being registeredid
- the id of this resourceloader
- the ClassLoader with which to load the resourcename
- the fully qualified name of the resource, that should be passed to
loader.getResource()
to load itlocale
- the locale this resource represents (may be null)
java.lang.IllegalArgumentException
- if there is already a registered resource with the same type, id, and localepublic static java.util.List<java.lang.String> getResourceTypes()
public static java.util.List<PluginRegistry.PluginResource> getResources(java.lang.String type)
public static PluginRegistry.PluginResource getResource(java.lang.String type, java.lang.String id)
public static void registerExportedMethod(java.lang.Object plugin, java.lang.String method, java.lang.String id) throws java.lang.IllegalArgumentException
getExportedMethodIds()
to get a list of all exported methods that have been
registered, and invokeExportedMethod(String, Object[])
to invoke one.
plugin
- the plugin object on which the method should be invokedmethod
- the name of the method to invokeid
- a unique identifier which may be passed to invokeExportedMethod()
to identify this method
java.lang.IllegalArgumentException
public static java.util.List<java.lang.String> getExportedMethodIds()
public static java.lang.Object invokeExportedMethod(java.lang.String id, java.lang.Object... args) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
id
- the unique identifier of the method to invokeargs
- the list of arguments to pass to the method. If the method has no arguments,
this may be null.
java.lang.NoSuchMethodException
- if there is no exported method with the specified ID, or if there
is no form of the exported method whose arguments are compatible with the specified args array.
java.lang.reflect.InvocationTargetException
- if the method threw an exception when it was invoked.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |