|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.plugin.PluginCollector<TType>
public class PluginCollector<TType>
The responsibility of this class is to detect all properties files with a specific name on a given classpath and load the defined classes that fit to a given class/interface into a class regitry.
Since version 1.3 it is possible to specify a system property named "org.pf.plugin.path" to define the path on which the plugin collector must search for plug-ins.
Since version 1.4 it is also possible to load all plugin definitions from a single file that is looked-up via the standard classloader mechanism getResourceStream().
Since version 1.5 it is also possible to load plugin definitions
from classes that implement the PluginRegistration
interface. These
classes are found by the Java service loader mechanism on the whole classpath
(based on classloader hierarchy).
Field Summary | |
---|---|
static boolean |
DEBUG
|
protected static java.lang.String |
DEBUG_PREFIX
|
Constructor Summary | |
---|---|
PluginCollector()
Initialize the new instance with default values. |
|
PluginCollector(java.lang.Class<TType> pluginType)
Initialize the new instance the type the plugins to collect must be compliant with. |
|
PluginCollector(ClassRegistry<TType> registry)
Initialize the new instance with a class registry. |
Method Summary | |
---|---|
protected void |
addMappings(java.util.Map<java.lang.String,java.lang.Class<?>> classesToRegister)
|
protected void |
addMappings(java.util.Properties properties)
|
protected void |
debug(java.lang.String text)
|
protected org.pfsw.file.FileUtil |
fileUtil()
|
ClassRegistry<TType> |
getClassRegistry()
Returns the class registry that contains all loaded plugins. |
protected org.pfsw.file.Classpath |
getPluginClasspath()
Returns the classpath that is used to lookup any plug-in information files. |
ClassRegistry<TType> |
loadPlugins(java.lang.String filename)
Load the class definitions from all files with the given name that can be found in the system classpath. |
ClassRegistry<TType> |
loadPlugins(java.lang.String filename,
org.pfsw.file.Classpath classpath)
Load the class definitions from all files with the given name that can be found in the specified classpath. |
ClassRegistry<TType> |
loadPlugins(java.lang.String filename,
java.lang.String classpath)
Load the class definitions from all files with the given name that can be found in the specified classpath. |
ClassRegistry<TType> |
loadPluginsViaClassLoader(java.lang.String filename)
Load the class definitions from the file with the given name. |
ClassRegistry<TType> |
loadPluginsViaPluginRegistration()
Load the class definitions from all PluginRegistration implementing classes that can be found via Java service loader mechanism using the classloader of this class. |
ClassRegistry<TType> |
loadPluginsViaPluginRegistration(java.lang.ClassLoader classLoader)
Load the class definitions from all PluginRegistration implementing classes that can be found via Java service loader mechanism in the given classloader's hierarchy. |
protected PluginUtil |
pluginUtil()
|
protected void |
readMapping(org.pfsw.file.ClasspathElement element,
java.lang.String filename)
|
protected void |
readMapping(java.io.InputStream stream,
java.lang.String filename)
Reads all plugin definitions from the given stream into the underlying registry. |
protected void |
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 void |
readPlugins(java.lang.String filename,
java.lang.String strClasspath)
Read all classes specified in the given file, if it exists in the specified classpath element. |
protected void |
setClassRegistry(ClassRegistry<TType> newValue)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String DEBUG_PREFIX
public static boolean DEBUG
Constructor Detail |
---|
public PluginCollector()
public PluginCollector(java.lang.Class<TType> pluginType)
public PluginCollector(ClassRegistry<TType> registry)
Method Detail |
---|
public ClassRegistry<TType> getClassRegistry()
public ClassRegistry<TType> loadPluginsViaClassLoader(java.lang.String filename)
filename
- The name of the properties file that contains the class definitions
public ClassRegistry<TType> loadPlugins(java.lang.String filename)
filename
- The name of the properties file that contains the class definitions
public ClassRegistry<TType> loadPlugins(java.lang.String filename, java.lang.String classpath)
filename
- The name of the properties file that contains the class definitionsclasspath
- The classpath the specified filename to be looked up inpublic ClassRegistry<TType> loadPlugins(java.lang.String filename, org.pfsw.file.Classpath classpath)
filename
- The name of the properties file that contains the class definitionsclasspath
- The classpath on which to lookup the the specified filenamepublic ClassRegistry<TType> loadPluginsViaPluginRegistration(java.lang.ClassLoader classLoader)
classLoader
- The class loader from which to start looking for services
that implement interface PluginRegistration
.public ClassRegistry<TType> loadPluginsViaPluginRegistration()
protected void readPlugins(java.lang.String filename, java.lang.String strClasspath)
filename
- The name of the properties file that contains the class definitionsstrClasspath
- The classpath the specified filename to be looked up inprotected void 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 inprotected void readMapping(org.pfsw.file.ClasspathElement element, java.lang.String filename)
protected void readMapping(java.io.InputStream stream, java.lang.String filename)
stream
- The stream from which to read the definitions.filename
- The filename that corresponds to the stream (just for debugging).protected void addMappings(java.util.Properties properties)
protected void addMappings(java.util.Map<java.lang.String,java.lang.Class<?>> classesToRegister)
protected org.pfsw.file.Classpath getPluginClasspath()
protected void setClassRegistry(ClassRegistry<TType> newValue)
protected org.pfsw.file.FileUtil fileUtil()
protected PluginUtil pluginUtil()
protected void debug(java.lang.String text)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |