|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.programix.command.CommandProcessorFactory
public class CommandProcessorFactory
Used to construct and initialize instances of CommandProcessor using
reflection.
Common usage is (where CustomerCommandProcessor is an
interface that extends the CommandProcessor interface):
orValueMapconfig = //... CustomerCommandProcessor ccp = (CustomerCommandProcessor) CommandProcessorFactory.create(config, CustomerCommandProcessor.class);
String filename = //...
CustomerCommandProcessor cda = (CustomerCommandProcessor)
CommandProcessorFactory.create(filename, CustomerCommandProcessor.class);
The configuration ValueMap passed in must contain the class name of
the class to be instantiated stored under the key
COMMAND_PROCESSOR_CLASSNAME_KEY. Other key/value pairs in the map
are populated with whatever the specific CommandProcessor
implementation needs for initialization.
| Field Summary | |
|---|---|
static String |
COMMAND_PROCESSOR_CLASSNAME_KEY
The reserved key that retrieves the fully-qualified name (as a String) of the CommandProcessor implementation class that will be instantiated via reflection. |
| Method Summary | ||
|---|---|---|
static
|
create(File file,
Class<T> targetType)
Create a CommandProcessor 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 CommandProcessor 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 CommandProcessor 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 CommandProcessor 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 CommandProcessor implementation
specified in the configuration. |
|
static
|
createFromFile(String filename,
Class<T> targetType)
Create a CommandProcessor 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 CommandProcessor 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 COMMAND_PROCESSOR_CLASSNAME_KEY
The value of this key is always:
command.processor.classname
| Method Detail |
|---|
public static <T extends CommandProcessor> T create(ValueMap config,
Class<T> targetType)
throws CommandException
CommandProcessor implementation
specified in the configuration. One required key
that must always be present is: COMMAND_PROCESSOR_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
CommandProcessor 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 CommandException instead of a ClassCastException).
config - key/value mapping with everything that is needed to
initialize the instance of CommandProcessor.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 CommandException is thrown.
CommandException - 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 CommandProcessor> T create(Reader rawIn,
Class<T> targetType)
throws CommandException
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 CommandProcessor.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 CommandException is thrown.
CommandException - 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 CommandProcessor> T create(InputStream rawIn,
Class<T> targetType)
throws CommandException
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 CommandProcessor.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 CommandException is thrown.
CommandException - 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 CommandProcessor> T create(File file,
Class<T> targetType)
throws CommandException
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 CommandProcessor.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 CommandException is thrown.
CommandException - 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 CommandProcessor> T createFromFile(String filename,
Class<T> targetType)
throws CommandException
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 CommandProcessor.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 CommandException is thrown.
CommandException - 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 CommandProcessor> T create(URL propertiesURL,
Class<T> targetType)
throws CommandException
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 CommandProcessor.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 CommandException is thrown.
CommandException - if instance can not be constructed
and initialized.create(ValueMap, Class),
create(Reader, Class),
create(InputStream, Class),
createFromFile(String, Class),
create(File, Class),
createFromResource(String, Class)
public static <T extends CommandProcessor> T createFromResource(String resourceLocation,
Class<T> targetType)
throws CommandException
ValueMap(nearly identical to the format for a
Properties file).
resourceLocation - file with key/value mapping with everything
that is needed to initialize the instance of
CommandProcessor.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 CommandException is thrown.
CommandException - if instance can not be constructed
and initialized.create(ValueMap, Class),
create(Reader, Class),
create(InputStream, Class),
create(File, Class),
createFromFile(String, Class),
create(URL, Class)
|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||