public class ObjectFactory
extends Object
An ObjectFactory can create objects based on the current execution context. For example there is a binding:
com.toolsverse.util.lang.ParserTypeFactory.client=com.toolsverse.ui.swing.codeeditor.RSyntaxTextAreaParserTypeFactory
com.toolsverse.util.lang.ParserTypeFactory.server=com.toolsverse.ui.wings.codeeditor.CodeMirrorParserTypeFactory
if system property app.deployment=client ObjectFactory returns RSyntaxTextAreaParserTypeFactory, if it is app.deployment=server ObjectFactory returns CodeMirrorParserTypeFactory.
ObjectFactoryModule
Modifier and Type | Field and Description |
---|---|
static String |
OBJECT_FACTORY_OBJECTS
OBJECT_FACTORY_OBJECTS.
|
Modifier and Type | Method and Description |
---|---|
Object |
get(String name)
Creates an object which either implements
name interface or is an instance of the name class. |
Object |
get(String name,
boolean singleton)
If
singleton == true creates a "singleton" instance of the object which either implements name interface
or is an instance of the name class. |
Object |
get(String name,
Class<?> classTo)
Creates an object which either implements
name interface or is an instance of the name class. |
Object |
get(String name,
Class<?> classTo,
boolean singleton)
If
singleton== true creates a "singleton" instance of the object which either implements name interface
or is an instance of the name class. |
Object |
get(String name,
String realClassName)
First tries to create an object which either implements
name interface or is an instance of the name class. |
Object |
get(String name,
String defaultName,
boolean singleton)
If
singleton == true first tries to create a "singleton" instance of the object which either implements name
interface or is an instance of the name class. |
Object |
get(String name,
String defaultName,
Class<?> classTo,
boolean singleton)
If
singleton == true first tries to create a "singleton" instance of the object which either implements name
interface or is an instance of the name class. |
Object |
get(String name,
String defaultName,
String realClassName)
First tries to create an object which either implements
name interface or is an instance of the name class. |
Object |
get(String name,
String defaultName,
String realClassName,
Class<?> classTo)
First tries to create an object which either implements
name interface or is an instance of the name class. |
Object |
get(String name,
String defaultName,
String realClassName,
Class<?> classTo,
boolean singleton,
boolean checkLicense)
First tries to create an object which either implements
name interface or is an instance of the name class. |
static ObjectFactory |
instance()
Instance.
|
void |
register(ObjectFactoryModule module)
Registers ObjectFactoryModule.
|
void |
unRegister(ObjectFactoryModule module)
Unregisters ObjectFactoryModule.
|
public static final String OBJECT_FACTORY_OBJECTS
public static ObjectFactory instance()
public Object get(String name)
name
interface or is an instance of the name
class.
If object can not be created returns null.name
- the name of the classpublic Object get(String name, boolean singleton)
singleton == true
creates a "singleton" instance of the object which either implements name
interface
or is an instance of the name
class. Otherwise just creates an object.
If object can not be created returns null.name
- the name of the classsingleton
- if true the singleton object will be createdpublic Object get(String name, Class<?> classTo)
name
interface or is an instance of the name
class.
If object can not be created or can not be cast to classTo
returns null.name
- the name of the classclassTo
- the class to cast topublic Object get(String name, Class<?> classTo, boolean singleton)
singleton== true
creates a "singleton" instance of the object which either implements name
interface
or is an instance of the name
class. Otherwise just creates an object.
If object can not be created or can not be cast to classTo
returns null.name
- the name of the classclassTo
- the class to cast tosingleton
- if true the singleton object will be createdpublic Object get(String name, String realClassName)
name
interface or is an instance of the name
class.
If it fails uses realClassName
. If it also fails returns null.name
- the name of the classrealClassName
- the alternative name of the classpublic Object get(String name, String defaultName, boolean singleton)
singleton == true
first tries to create a "singleton" instance of the object which either implements name
interface or is an instance of the name
class.
If it fails uses defaultName
. If it also fails returns null.name
- the name of the classdefaultName
- the alternative name of the classsingleton
- if true the singleton object will be createdpublic Object get(String name, String defaultName, Class<?> classTo, boolean singleton)
singleton == true
first tries to create a "singleton" instance of the object which either implements name
interface or is an instance of the name
class.
If it fails uses defaultName
. If it also fails or object can not be cast to classTo
returns null.name
- the name of the classdefaultName
- the alternative name of the classclassTo
- the class to cast tosingleton
- if true the singleton object will be createdpublic Object get(String name, String defaultName, String realClassName)
name
interface or is an instance of the name
class.
If it fails uses realClassName
. If it fails uses defaultName
as a last resort. If it also fails returns null.name
- the name of the classdefaultName
- the "last resort" name of class if both name and realClassName didn't workrealClassName
- the alternative name of the classpublic Object get(String name, String defaultName, String realClassName, Class<?> classTo)
name
interface or is an instance of the name
class.
If it fails uses realClassName
. If it fails uses defaultName
as a last resort.
If it also fails or object can not be cast to classTo
returns null.name
- the name of the classdefaultName
- the "last resort" name of class if both name and realClassName didn't workrealClassName
- the alternative name of the classclassTo
- the class to cast topublic Object get(String name, String defaultName, String realClassName, Class<?> classTo, boolean singleton, boolean checkLicense)
name
interface or is an instance of the name
class.
If it fails uses realClassName
. If it fails uses defaultName
as a last resort.
If it also fails or object can not be cast to classTo
returns null.
If singleton == true
the object will be created as "singleton".name
- the name of the classdefaultName
- the "last resort" name of class if both name and realClassName didn't workrealClassName
- the alternative name of the classclassTo
- the class to cast tosingleton
- if true the singleton object will be createdcheckLicense
- the check license flag. If true object factory checks licensepublic void register(ObjectFactoryModule module)
module
- the ObjectFactoryModulepublic void unRegister(ObjectFactoryModule module)
module
- the ObjectFactoryModuleCopyright © 2010-2020 Toolsverse. All Rights Reserved.