|
ProgramixGenericLib v4.0.0 | |||||||||
| 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 CommandProcessor |
create(File file,
Class 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 CommandProcessor |
create(InputStream rawIn,
Class 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 CommandProcessor |
create(Reader rawIn,
Class 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 CommandProcessor |
create(URL propertiesURL,
Class 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 CommandProcessor |
create(ValueMap config,
Class targetType)
Constructs an instance of the CommandProcessor implementation
specified in the configuration. |
static CommandProcessor |
createFromFile(String filename,
Class 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 CommandProcessor |
createFromResource(String resourceLocation,
Class 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 CommandProcessor create(ValueMap config,
Class 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 CommandProcessor create(Reader rawIn,
Class 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 CommandProcessor create(InputStream rawIn,
Class 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 CommandProcessor create(File file,
Class 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 CommandProcessor createFromFile(String filename,
Class 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 CommandProcessor create(URL propertiesURL,
Class 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 CommandProcessor createFromResource(String resourceLocation,
Class 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 v4.0.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||