public class Factory
extends java.lang.Object
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
Constructor and Description |
---|
Factory(java.net.URL propertiesFile)
Creates a objects factory from a properties files.
|
Factory(java.net.URL propertiesFile,
java.lang.String defaultEntry)
Creates a object factory from a properties file, sending the entry
that indicate the default entry.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
create()
Create a default object.
|
java.lang.Object |
create(java.lang.String name)
Create the indicate object.
|
public Factory(java.net.URL propertiesFile)
The entry that indicate the default entry is _defecto or _default.
Preconditions:
propertiesFile
- File URL withn pairs names/classespublic Factory(java.net.URL propertiesFile, java.lang.String defaultEntry)
Preconditions:
propertiesFile
- File URL with pairs names/classesdefaultEntry
- Indicante what entry will be used as default entry, si
if is null
_defecto/_default is used.public java.lang.Object create() throws InitException
Postcondition:
InitException
- Some problem on initpublic java.lang.Object create(java.lang.String name) throws InitException
Postcondition:
name
- Identifier name, which is registered in propertiesInitException
- Si hay algún problema el iniciar.