|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.java.plugin.extension.InstanceFactory
public class InstanceFactory
This class creates instances from Extensions. It is based on Guice to allow dependecy injection of Objects and parameters.
Constructor Summary | |
---|---|
InstanceFactory(com.google.inject.Injector injector,
PluginController controller,
ConverterGraph converterGraph)
Creates a new InstanceFactory where the Injector is used as the main injector to create extensions (instances from extensions that provide a "class" parameter) defined in the given PluginController |
Method Summary | ||
---|---|---|
|
convert(java.lang.Object value,
java.lang.reflect.Type source,
java.lang.reflect.Type target,
java.lang.ClassLoader loader)
Helper method to access the converter facility and convert from source to target type |
|
java.lang.Object |
createFromExtension(Extension extension)
Use this to craete an instance from the given extension. |
|
|
get(java.lang.Class<? extends T> clazz)
Creates an instance of the given class using the current injector. |
|
static InstanceFactory |
getInstance()
Static access to the instance factory. |
|
java.lang.ClassLoader |
getPluginClassLoader(Extension extension)
Method to resolved plugin's classloader from a given extension |
|
void |
initiazlieFromController()
Get converter extension and add them to the converter graph |
|
boolean |
isAutoActivate()
|
|
java.lang.Class<?> |
loadClass(Extension extension)
Looks for a parameter named class and uses the plugins classloader to load that class. |
|
void |
registerTypeConverter(java.lang.reflect.Type targetType,
Converter<java.lang.String,?> converter)
Registers a new Type converter. |
|
void |
setAutoActivate(boolean autoActivate)
Use this to enable/disable automatic plugin activation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Inject public InstanceFactory(com.google.inject.Injector injector, PluginController controller, ConverterGraph converterGraph)
PluginController
injector
- the main Injectorcontroller
- the PluginManagerPluginController
,
Injector
,
Extension.createInstance()
Method Detail |
---|
public void initiazlieFromController()
public void registerTypeConverter(java.lang.reflect.Type targetType, Converter<java.lang.String,?> converter)
You can also use this to overwrite already registered converter but overriding the Guice default (such as String) does not work.
targetType
- the target typeconverter
- the converter classpublic <T> T get(java.lang.Class<? extends T> clazz)
T
- the class' typeclazz
- to create
public java.lang.Object createFromExtension(Extension extension) throws JpfException
autoActivate
is enabled, this will make sure that
the decalaring plugin of the given Extension is activated before access to
its plugin classloader.
extension
- the
java.lang.ClassNotFoundException
- if the extensions class could not be found
JpfException
public java.lang.Class<?> loadClass(Extension extension) throws java.lang.ClassNotFoundException
autoActivate
is enabled, this will make sure that
the decalaring plugin of the given Extension is activated before access to
its plugin classloader.
extension
- the extension
java.lang.ClassNotFoundException
- if the specified exception class could not be foundpublic java.lang.ClassLoader getPluginClassLoader(Extension extension)
extension
- the extension
public static InstanceFactory getInstance()
public boolean isAutoActivate()
public void setAutoActivate(boolean autoActivate)
autoActivate
- enabledloadClass(org.java.plugin.registry.Extension)
,
createFromExtension(org.java.plugin.registry.Extension)
public <T> T convert(java.lang.Object value, java.lang.reflect.Type source, java.lang.reflect.Type target, java.lang.ClassLoader loader)
T
- target typevalue
- the valuesource
- the source typetarget
- the target typeloader
- the loader
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |