public class DefaultCommandFactory extends Object implements NamedCommandFactory
CommandFactory
interface.
The factory read the class information for the command from the property file. Commands are Singletons and held in a cache by keys.
CommandFactory
Modifier and Type | Field and Description |
---|---|
protected String |
factoryName
Name of this command factory, usually its properties file name.
|
protected List<BasicCommandFactory> |
linkedCommandFactories |
Modifier and Type | Method and Description |
---|---|
static void |
addCommandCreationListener(CommandCreationListener listener)
Adds a command creation listener to receive informations or failure messages of command
creation process.
|
void |
addLinkedCommandFactory(BasicCommandFactory commandFactory)
Adds a command factory as linked factory to this factory.
|
Command |
getCommand(String key)
Default constructor using the settings of the commands.properties file.
|
static CommandCreationListener[] |
getCommandCreationListeners()
Returns an array of currently registered creation listeners
|
String |
getFactoryName()
Returns the name of this factory, usually its properties resource name.
|
static DefaultCommandFactory |
getInstance(String propertiesFileName)
Create instance for the factory.
|
NamedCommandFactory[] |
getLinkedCommandFactories()
Returns an array of linked command factories
|
String |
getLinkedFactoryDescription()
Returns a description of linked factories.
|
String |
getLookupProperty(String key)
Allows an application to request lookup properties programmatically.
|
void |
insertLinkedCommandFactory(int index,
BasicCommandFactory commandFactory)
Inserts a command factory at index position of linked factories.
|
void |
putLookupProperty(String key,
String value)
Deprecated.
use
setLookupProperty(String, String) instead |
static void |
removeCommandCreationListener(CommandCreationListener listener)
Removes a command creation listener.
|
void |
removeLinkedCommandFactory(BasicCommandFactory commandFactory)
Removes a command factory of linked factories.
|
void |
reset()
Clears and resets this factory instance.
|
void |
setLookupProperty(String key,
String value)
Allows an application to overwrite or set lookup properties programmatically.
|
protected String factoryName
protected List<BasicCommandFactory> linkedCommandFactories
public static void addCommandCreationListener(CommandCreationListener listener)
listener
- the listener instance to addpublic static void removeCommandCreationListener(CommandCreationListener listener)
listener
- the listener instance to removepublic static CommandCreationListener[] getCommandCreationListeners()
public static DefaultCommandFactory getInstance(String propertiesFileName)
CommandFactory
but just
one instance.
The default properties File doesn't have to be used. It can be used the custom property File. If the custom property file is null then will be the default property file used.
propertiesFileName
- custom properties file nameCommandFactory
.public Command getCommand(String key)
CommandFactory
Algorithm of the command creating:
first:
lookup, if the command is already in the cache
second:
create command, if not already in the cache otherwise next point.
third:
return the created command.
getCommand
in interface CommandFactory
key
- of the command (ID)CommandFactory.getCommand(java.lang.String)
public String getFactoryName()
NamedCommandFactory
getFactoryName
in interface NamedCommandFactory
NamedCommandFactory.getFactoryName()
public String getLinkedFactoryDescription()
@Deprecated public void putLookupProperty(String key, String value)
setLookupProperty(String, String)
insteadkey
- value
- The value of the given key, null
if the key is not mapped to any
value.NullPointerException
- if the key or value is null
.public void setLookupProperty(String key, String value)
key
- value
- The value of the given key, null
if the key is not mapped to any
value.NullPointerException
- if the key or value is null
.public void reset()
public String getLookupProperty(String key)
key
- A key to look upnull
if the key is not mapped to any
value.NullPointerException
- if the key is null.public NamedCommandFactory[] getLinkedCommandFactories()
public void addLinkedCommandFactory(BasicCommandFactory commandFactory)
commandFactory
- factory to addpublic void removeLinkedCommandFactory(BasicCommandFactory commandFactory)
commandFactory
- factory to removepublic void insertLinkedCommandFactory(int index, BasicCommandFactory commandFactory)
index
- index of factorycommandFactory
- factory to insertCopyright © 2024 levigo holding gmbh. All rights reserved.