Package notification

Class CommunicationAccess

java.lang.Object
notification.CommunicationAccess

class CommunicationAccess extends Object
* This class provides centralized access to communication strategies based on different transmission modes. It ensures that only one instance of each communication mode exists at a time. The class follows the Singleton-like pattern by preventing instantiation and offering static methods to manage communication strategies.
  • Field Details

    • strategies

      static Map<String,CommunicationStrategy> strategies
      It store all the mode Object created organised by their name so it exists only one at a time
  • Constructor Details

    • CommunicationAccess

      private CommunicationAccess()
      A private no-argument constructor is used to prevent any instance creation of this class.
  • Method Details

    • setCom

      public static void setCom(String mode, CommunicationStrategy comObj)
      Allows the server to store in the Map the object responsible for communication for the desired mode. If the object does not yet exist, the pair is added; otherwise, the new pair replaces the existing one.
      Parameters:
      mode - : The mode of communication
      comObj - : The object responsible for communication
    • getCom

      public static CommunicationStrategy getCom(String mode)
      This method returns the instance that enables access according to the given mode parameter. This instance is the one stored in the Map.
      Parameters:
      mode - : The mode of communication
      Returns:
      The object in charge of communication. If no instance is present for this mode, null is returned.