Package org.serviceconnector.cmd
Class FlyweightCommandFactory
java.lang.Object
org.serviceconnector.cmd.FlyweightCommandFactory
- Direct Known Subclasses:
ServerCommandFactory,ServiceConnectorCommandFactory
A factory for creating FlyweightCommand objects. Factory is based on the Flyweight pattern (http://www.allapplabs.com/java_design_patterns/flyweight_pattern.htm). Commands are
only instantiated one time. Factory is always returning the same instance from a map.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommand(SCMPMsgType messageType, ICommand command) Adds the command.getCommand(SCMPMsgType key) Gets the command.
-
Field Details
-
commands
The map stores base instances by a key.
-
-
Constructor Details
-
FlyweightCommandFactory
public FlyweightCommandFactory()Instantiates a new flyweight command factory.
-
-
Method Details
-
addCommand
Adds the command.- Parameters:
messageType- the message typecommand- the command
-
getCommand
Gets the command.- Parameters:
key- the key- Returns:
- the command
-