Class ClientServerInteractionManager

  • All Implemented Interfaces:
    java.util.EventListener, net.jini.discovery.DiscoveryListener, net.jini.lookup.ServiceDiscoveryListener

    public class ClientServerInteractionManager
    extends java.lang.Object
    implements net.jini.discovery.DiscoveryListener, net.jini.lookup.ServiceDiscoveryListener
    Manager that handles and eases the discovery of services using JINI. Helps the client service discovery. It discovers the lookup service. A configuration file can be provided in the constructor to specify unicast locators, groups to join and the service to be located. After discovering a lookup service it queries for the given service and filters the dead services.
    Since:
    Ptolemy II 5.1
    Version:
    $Id$
    Author:
    Daniel Lázaro Cuadrado (kapokasa@kom.aau.dk)
    See Also:
    "Jini Documentation"
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (kapokasa)
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientServerInteractionManager​(boolean verbose)
      Construct a ClientServerInteractionManager initializing it with a given VERBOSE option.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void discarded​(net.jini.discovery.DiscoveryEvent evt)
      Required by DiscoveryListener interface.
      void discovered​(net.jini.discovery.DiscoveryEvent evt)
      Required by DiscoveryListener interface.
      java.util.LinkedList getServices()
      Returns the list of alive services.
      void init​(java.lang.String configFileName)
      Initializes the ClientServerInteractionManager.
      void serviceAdded​(net.jini.lookup.ServiceDiscoveryEvent evt)
      Required by ServiceDiscoveryListener interface.
      void serviceChanged​(net.jini.lookup.ServiceDiscoveryEvent evt)
      Required by ServiceDiscoveryListener interface.
      void serviceRemoved​(net.jini.lookup.ServiceDiscoveryEvent evt)
      Required by ServiceDiscoveryListener interface.
      void setRequiredServices​(int requiredServices)
      Specify the number of required services.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClientServerInteractionManager

        public ClientServerInteractionManager​(boolean verbose)
        Construct a ClientServerInteractionManager initializing it with a given VERBOSE option.
        Parameters:
        verbose - If true, flag messages will be printed in the standard output.
    • Method Detail

      • discarded

        public void discarded​(net.jini.discovery.DiscoveryEvent evt)
        Required by DiscoveryListener interface. Called when one or more lookup service registrars has been discarded. The method should return quickly; e.g., it should not make remote calls.
        Specified by:
        discarded in interface net.jini.discovery.DiscoveryListener
        Parameters:
        evt - The event that describes the discarded registrars
      • discovered

        public void discovered​(net.jini.discovery.DiscoveryEvent evt)
        Required by DiscoveryListener interface. Called when one or more lookup service registrars has been discovered. The method should return quickly; e.g., it should not make remote calls. It prints the locator of the found Registrars.
        Specified by:
        discovered in interface net.jini.discovery.DiscoveryListener
        Parameters:
        evt - The event that describes the discovered registrars
      • getServices

        public java.util.LinkedList getServices()
        Returns the list of alive services.
        Returns:
        LinkedList of registrars containing the alive services.
      • init

        public void init​(java.lang.String configFileName)
        Initializes the ClientServerInteractionManager. It loads the configuration file and creates a ServiceDiscoveryManager in order to help locate the service. It searches for the service specified in the configuration file and it filters the dead services.
        Parameters:
        configFileName - String containing the name and/or path of the configuration file to be loaded.
      • serviceAdded

        public void serviceAdded​(net.jini.lookup.ServiceDiscoveryEvent evt)
        Required by ServiceDiscoveryListener interface. When the cache receives from one of the managed lookup services, an event signaling the registration of a service of interest for the first time (or for the first time since the service has been discarded), the cache invokes the serviceAdded method on all instances of ServiceDiscoveryListener that are registered with the cache; doing so notifies the entity that a service of interest has been discovered. It just notifies of the event in the standard output.
        Specified by:
        serviceAdded in interface net.jini.lookup.ServiceDiscoveryListener
        Parameters:
        evt - a ServiceDiscoveryEvent object containing references to the service item corresponding to the event, including representations of the service's state both before and after the event.
      • serviceChanged

        public void serviceChanged​(net.jini.lookup.ServiceDiscoveryEvent evt)
        Required by ServiceDiscoveryListener interface. When the cache receives, from a managed lookup service, an event signaling the unique modification of the attributes of a service of interest (across the attribute sets of all references to the service), the cache invokes the serviceChanged method on all instances of ServiceDiscoveryListener that are registered with the cache; doing so notifies the entity that the state of a service of interest has changed. It just notifies of the event in the standard output.
        Specified by:
        serviceChanged in interface net.jini.lookup.ServiceDiscoveryListener
        Parameters:
        evt - a ServiceDiscoveryEvent object containing references to the service item corresponding to the event, including representations of the service's state both before and after the event.
      • serviceRemoved

        public void serviceRemoved​(net.jini.lookup.ServiceDiscoveryEvent evt)
        Required by ServiceDiscoveryListener interface. When the cache receives, from a managed lookup service, an event signaling the removal of a service of interest from the last such lookup service with which it was registered, the cache invokes the serviceRemoved method on all instances of ServiceDiscoveryListener that are registered with the cache; doing so notifies the entity that a service of interest has been discarded. It just notifies of the event in the standard output.
        Specified by:
        serviceRemoved in interface net.jini.lookup.ServiceDiscoveryListener
        Parameters:
        evt - a ServiceDiscoveryEvent object containing references to the service item corresponding to the event, including representations of the service's state both before and after the event.
      • setRequiredServices

        public void setRequiredServices​(int requiredServices)
        Specify the number of required services.
        Parameters:
        requiredServices - The number of requiredServices.