|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.plugin.PluginRegistry
public class PluginRegistry
A special registry that is capable to hold any number of plug-ins of any type.
Field Summary | |
---|---|
protected static boolean |
DEBUG
|
protected static java.lang.String |
DEBUG_PREFIX
|
protected static java.lang.String |
OPTIONS_END
|
protected static java.lang.String |
OPTIONS_START
|
protected static java.lang.String |
PLUGIN_DEF_SEPARATOR
|
protected static org.pfsw.text.StringPattern |
PLUGIN_OPTIONS_PATTERN
|
Constructor Summary | |
---|---|
PluginRegistry()
Initialize the new instance with default values (i.e. an empty registry). |
Method Summary | ||
---|---|---|
protected int |
addDefinitionsToRegistry(org.pfsw.util.OrderedProperties<?> definitions)
|
|
void |
clear()
Remove all registered plugins. |
|
protected org.pfsw.util.CollectionUtil |
coll()
|
|
protected void |
debug(java.lang.String text)
|
|
protected org.pfsw.file.FileUtil |
fileUtil()
|
|
protected java.lang.reflect.Method |
find_getPluginId_Method(java.lang.Object object)
|
|
protected java.lang.String |
getIdOfPlugin(java.lang.Object plugin,
java.lang.String defaultId)
|
|
java.lang.Object |
getPlugin(java.lang.String pluginId)
Returns the plug-in with the specified ID or null if no such plug-in can be found in the registry. |
|
|
getPlugin(java.lang.String pluginId,
java.lang.Class<T> pluginType)
Returns the plug-in with the specified ID and the given type or null if no such plug-in can be found in the registry. |
|
protected org.pfsw.file.Classpath |
getPluginClasspath()
Returns the classpath that is used to lookup any plug-in information files. |
|
java.lang.String[] |
getPluginIDsOfType(java.lang.Class<?> pluginType)
Returns the IDs of all plug-ins that are of the specified type. |
|
|
getPluginsOfType(java.lang.Class<T> pluginType)
Returns all plug-ins that are of the specified type. |
|
protected org.pfsw.util.NamedValueList<org.pfsw.plugin.PluginHolder> |
getRegistry()
|
|
|
loadPluginsByServiceLoader(java.lang.Class<T> pluginType,
java.lang.ClassLoader... classLoaders)
Utilizes the Java ServiceLoader mechanism to load all plugins
implementing the given type into this registry. |
|
int |
loadPluginsFrom(java.lang.String filename)
Load all plug-ins that are defined in any library in the specified file. |
|
protected boolean |
parseAndAddToRegistry(java.lang.String id,
java.lang.String pluginDefinition)
|
|
protected PluginUtil |
plugUtil()
|
|
protected int |
readPlugins(java.lang.String filename,
org.pfsw.file.Classpath classpath)
Read all classes specified in the given file, if it exists in the specified classpath element. |
|
protected int |
readPluginsFrom(org.pfsw.file.ClasspathElement element,
java.lang.String filename)
|
|
protected
|
registerPlugin(java.lang.Class<T> pluginType,
T plugin)
|
|
protected boolean |
registerPlugin(org.pfsw.plugin.PluginHolder pluginHolder)
|
|
protected void |
setRegistry(org.pfsw.util.NamedValueList<org.pfsw.plugin.PluginHolder> newValue)
|
|
protected org.pfsw.text.StringUtil |
str()
|
|
protected boolean |
validateClass(org.pfsw.reflect.ClassInfo<?> classInfo)
|
|
protected boolean |
validateClassFound(org.pfsw.reflect.ClassInfo<?> classInfo)
|
|
protected boolean |
validateInstanceCreation(org.pfsw.reflect.ClassInfo<?> classInfo)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final boolean DEBUG
protected static final java.lang.String DEBUG_PREFIX
protected static final java.lang.String PLUGIN_DEF_SEPARATOR
protected static final java.lang.String OPTIONS_START
protected static final java.lang.String OPTIONS_END
protected static final org.pfsw.text.StringPattern PLUGIN_OPTIONS_PATTERN
Constructor Detail |
---|
public PluginRegistry()
Method Detail |
---|
public int loadPluginsFrom(java.lang.String filename)
filename
- The name of the file where the plug-in definition is looked-up.
public <T> int loadPluginsByServiceLoader(java.lang.Class<T> pluginType, java.lang.ClassLoader... classLoaders)
ServiceLoader
mechanism to load all plugins
implementing the given type into this registry.
pluginType
- The type (i.e. interface) of the plug-in (must not be null).classLoaders
- An optional array of class loaders. The first non-null classloader
will be used for the lookup. If none is provided the thread context classloader and
the class loader of this class will be tried.
public java.lang.Object getPlugin(java.lang.String pluginId)
pluginId
- The identifier of the plug-in (must not be null)
public <T> T getPlugin(java.lang.String pluginId, java.lang.Class<T> pluginType)
pluginId
- The identifier of the plug-in (must not be null).pluginType
- The type of the plug-in (must not be null).
public <T> T[] getPluginsOfType(java.lang.Class<T> pluginType)
pluginType
- The type the plug-ins to look for must comply with.
public java.lang.String[] getPluginIDsOfType(java.lang.Class<?> pluginType)
pluginType
- The type the plug-ins to look for must comply with.
public void clear()
protected boolean registerPlugin(org.pfsw.plugin.PluginHolder pluginHolder)
protected <T> void registerPlugin(java.lang.Class<T> pluginType, T plugin)
protected java.lang.String getIdOfPlugin(java.lang.Object plugin, java.lang.String defaultId)
protected int readPlugins(java.lang.String filename, org.pfsw.file.Classpath classpath)
filename
- The name of the properties file that contains the class definitionsclasspath
- The classpath the specified filename to be looked up in
protected int readPluginsFrom(org.pfsw.file.ClasspathElement element, java.lang.String filename)
protected int addDefinitionsToRegistry(org.pfsw.util.OrderedProperties<?> definitions)
protected boolean parseAndAddToRegistry(java.lang.String id, java.lang.String pluginDefinition)
protected boolean validateClass(org.pfsw.reflect.ClassInfo<?> classInfo)
protected boolean validateClassFound(org.pfsw.reflect.ClassInfo<?> classInfo)
protected boolean validateInstanceCreation(org.pfsw.reflect.ClassInfo<?> classInfo)
protected java.lang.reflect.Method find_getPluginId_Method(java.lang.Object object)
protected org.pfsw.file.Classpath getPluginClasspath()
protected org.pfsw.util.NamedValueList<org.pfsw.plugin.PluginHolder> getRegistry()
protected void setRegistry(org.pfsw.util.NamedValueList<org.pfsw.plugin.PluginHolder> newValue)
protected org.pfsw.file.FileUtil fileUtil()
protected org.pfsw.text.StringUtil str()
protected org.pfsw.util.CollectionUtil coll()
protected PluginUtil plugUtil()
protected void debug(java.lang.String text)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |