Package org.openxava.util
Class Factory
java.lang.Object
org.openxava.util.Factory
Generic class to implement object factories.
The classes are in a properties file with name=class formate. Where nombre is a identifier and class the class of object to create, which must to have a default constructor.
If the class implements IInit then the method IInit.init(java.lang.String) is
called after creation.
Exists a entry that is assumed as default entry. This entry is used
when you call to create() without arguments.
The default entry can be defined on create the factory or
if not the entry _default/_defecto is assumed.
A example of properties file is:
_defecto=rapido rapido=miempresa.miapp.paquete1.MiClaseRapida lento=miempresa.miapp.paquete1.MiClaseLentaOr in english _default=fast fast=mycorp.myapp.package1.MyFastClass slow=mycorp.myapp.package1.MySlowClass
- Author:
- Javier Paniza
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Factory
Creates a objects factory from a properties files.The entry that indicate the default entry is _defecto or _default.
Preconditions:- propertiesFile != null
- Parameters:
propertiesFile- File URL withn pairs names/classes
-
Factory
Creates a object factory from a properties file, sending the entry that indicate the default entry.Preconditions:
- propertiesFile != null
- Parameters:
propertiesFile- File URL with pairs names/classesdefaultEntry- Indicante what entry will be used as default entry, si if isnull_defecto/_default is used.
-
-
Method Details
-
create
Create a default object.Postcondition:
- return != null
- Throws:
InitException- Some problem on init
-
create
Create the indicate object.Postcondition:
- return != null
- Parameters:
name- Identifier name, which is registered in properties- Throws:
InitException- Si hay algĂșn problema el iniciar.
-