|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.programix.da.DataAccessFactory
public class DataAccessFactory
Used to construct and initialize instances of DataAccess
using reflection.
Common usage is (where CustomerDataAccess is an interface
that extends the DataAccess interface):
orValueMapconfig = //... CustomerDataAccess cda = (CustomerDataAccess) DataAccessFactory.create(config, CustomerDataAccess.class);
String filename = //...
CustomerDataAccess cda = (CustomerDataAccess)
DataAccessFactory.create(filename, CustomerDataAccess.class);
The configuration ValueMap passed in must contain the
class name of the class to be instantiated stored under the key
DATA_ACCESS_CLASSNAME_KEY. Other key/value pairs in the map
are populated with whatever the specific DataAccess
implementation needs for initialization.
| Field Summary | |
|---|---|
static String |
DATA_ACCESS_CLASSNAME_KEY
The reserved key that retrieves the fully-qualified name (as a String) of the DataAccess implementation class that will be instantiated via reflection. |
| Method Summary | ||
|---|---|---|
static
|
create(File file,
Class<T> targetType)
Create a DataAccess instance using an File whose data is in the format described by ValueMap
(nearly identical to the format for a Properties file). |
|
static
|
create(InputStream rawIn,
Class<T> targetType)
Create a DataAccess instance using an InputStream whose data is in the format described by ValueMap
(nearly identical to the format for a Properties file). |
|
static
|
create(Reader rawIn,
Class<T> targetType)
Create a DataAccess instance using a Reader whose data is in the format described by ValueMap
(nearly identical to the format for a Properties file). |
|
static
|
create(URL propertiesURL,
Class<T> targetType)
Create a DataAccess instance using the specified URL whose data is in the format described by ValueMap(nearly identical to the format for a
Properties file). |
|
static
|
create(ValueMap config,
Class<T> targetType)
Constructs an instance of the DataAccess implementation
specified in the configuration. |
|
static
|
createFromFile(String filename,
Class<T> targetType)
Create a DataAccess instance using the specified filename whose data is in the format described by ValueMap(nearly identical to the format for a
Properties file). |
|
static
|
createFromResource(String resourceLocation,
Class<T> targetType)
Create a DataAccess instance using the specified resourceLocation whose data is in the format described by ValueMap(nearly identical to the format for a
Properties file). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DATA_ACCESS_CLASSNAME_KEY
The value of this key is always:
data.access.classname
| Method Detail |
|---|
public static <T extends DataAccess> T create(ValueMap config,
Class<T> targetType)
throws DataAccessException
DataAccess implementation
specified in the configuration. One required key
that must always be present is: DATA_ACCESS_CLASSNAME_KEY
with a String value which is the full class name.
Immediately after the zero-argument constructor is invoked,
the init(ValueMap conf) of
DataAccess is invoked to initialize the configuration.
If the targetType is not null, then an additional check is done to ensure that the constructed object can be type cast into that type (failures throw a DataAccessException instead of a ClassCastException).
config - key/value mapping with everything that is needed to
initialize the instance of DataAccess.targetType - the class type that this instance is expected
to be cast into. Use null to skip this check. If not
null and the type does not match what is constructed,
then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed
and initialized.create(Reader, Class),
create(InputStream, Class),
createFromFile(String, Class),
create(File, Class),
create(URL, Class)
public static <T extends DataAccess> T create(Reader rawIn,
Class<T> targetType)
throws DataAccessException
ValueMap
(nearly identical to the format for a Properties file).
Internally, the stream will be buffered and the stream
will be closed.
rawIn - a stream whose contents can be loaded into
a ValueMap with everything that is needed to
initialize the instance of DataAccess.targetType - the class type that this instance is expected
to be cast into. Use null to skip this check. If not
null and the type does not match what is constructed,
then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed
and initialized.create(ValueMap, Class),
create(InputStream, Class),
createFromFile(String, Class),
create(File, Class),
create(URL, Class)
public static <T extends DataAccess> T create(InputStream rawIn,
Class<T> targetType)
throws DataAccessException
ValueMap
(nearly identical to the format for a Properties file).
Internally, the stream will be buffered and the stream
will be closed.
rawIn - a stream whose contents can be loaded into
a ValueMap with everything that is needed to
initialize the instance of DataAccess.targetType - the class type that this instance is expected
to be cast into. Use null to skip this check. If not
null and the type does not match what is constructed,
then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed
and initialized.create(ValueMap, Class),
create(Reader, Class),
createFromFile(String, Class),
create(File, Class),
create(URL, Class)
public static <T extends DataAccess> T create(File file,
Class<T> targetType)
throws DataAccessException
ValueMap
(nearly identical to the format for a Properties file).
file - file with key/value mapping with everything that
is needed to initialize the instance of DataAccess.targetType - the class type that this instance is expected to be
cast into. Use null to skip this check. If not
null and the type does not match what is
constructed, then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed and
initialized.create(ValueMap, Class),
create(Reader, Class),
create(InputStream, Class),
createFromFile(String, Class),
create(URL, Class)
public static <T extends DataAccess> T createFromFile(String filename,
Class<T> targetType)
throws DataAccessException
ValueMap(nearly identical to the format for a
Properties file).
filename - file with key/value mapping with everything that is
needed to initialize the instance of DataAccess.targetType - the class type that this instance is expected to be
cast into. Use null to skip this check. If not
null and the type does not match what is
constructed, then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed and
initialized.create(ValueMap, Class),
create(Reader, Class),
create(InputStream, Class),
create(File, Class),
create(URL, Class)
public static <T extends DataAccess> T create(URL propertiesURL,
Class<T> targetType)
throws DataAccessException
ValueMap(nearly identical to the format for a
Properties file).
propertiesURL - a URL whose contents can be loaded into
a ValueMap with everything that is needed to
initialize the instance of DataAccess.targetType - the class type that this instance is expected
to be cast into. Use null to skip this check. If not
null and the type does not match what is constructed,
then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed
and initialized.create(ValueMap, Class),
create(Reader, Class),
create(InputStream, Class),
createFromFile(String, Class),
create(File, Class)
public static <T extends DataAccess> T createFromResource(String resourceLocation,
Class<T> targetType)
throws DataAccessException
ValueMap(nearly identical to the format for a
Properties file).
resourceLocation - resource with key/value mapping with
everything that is
needed to initialize the instance of DataAccess.targetType - the class type that this instance is expected to be
cast into. Use null to skip this check. If not
null and the type does not match what is
constructed, then a DataAccessException is thrown.
DataAccessException - if instance can not be constructed and
initialized.create(ValueMap, Class),
create(Reader, Class),
create(InputStream, Class),
create(File, Class),
create(URL, Class)
|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||