Class FlyweightCommandFactory

java.lang.Object
org.serviceconnector.cmd.FlyweightCommandFactory
Direct Known Subclasses:
ServerCommandFactory, ServiceConnectorCommandFactory

public abstract class FlyweightCommandFactory extends Object
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 Details

    • commands

      protected static Map<String,ICommand> commands
      The map stores base instances by a key.
  • Constructor Details

    • FlyweightCommandFactory

      public FlyweightCommandFactory()
      Instantiates a new flyweight command factory.
  • Method Details

    • addCommand

      public void addCommand(SCMPMsgType messageType, ICommand command)
      Adds the command.
      Parameters:
      messageType - the message type
      command - the command
    • getCommand

      public ICommand getCommand(SCMPMsgType key)
      Gets the command.
      Parameters:
      key - the key
      Returns:
      the command