Class FileWatcherDiscoveryAgent

  • All Implemented Interfaces:
    DiscoveryAgent

    public class FileWatcherDiscoveryAgent
    extends java.lang.Object
    implements DiscoveryAgent
    Discovery agent that watches a file and periodically reads in remote URIs from that file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Stops the agent after which no new remote peers will be found.
      DiscoveryListener getDiscoveryListener()  
      java.net.URI getDiscvoeryURI()  
      int getUpdateInterval()  
      boolean isSchedulerRequired()
      Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.
      void resume()
      Resumes discovery by this agent if it was previously suspended.
      void setDiscoveryListener​(DiscoveryListener listener)
      Sets the discovery listener
      void setScheduler​(java.util.concurrent.ScheduledExecutorService scheduler)
      Provider a ScheduledExecutorService to the DiscoveryAgent that requires a scheduler to perform its discovery work.
      void setUpdateInterval​(int updateInterval)  
      void start()
      Starts the agent after which new remote peers can start to be found.
      void suspend()
      Suspends the Agent which suppresses any new attempts to discover remote peers until the agent is resumed.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • FileWatcherDiscoveryAgent

        public FileWatcherDiscoveryAgent​(java.net.URI discoveryURI)
                                  throws java.net.URISyntaxException
        Throws:
        java.net.URISyntaxException
    • Method Detail

      • isSchedulerRequired

        public boolean isSchedulerRequired()
        Description copied from interface: DiscoveryAgent
        Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.
        Specified by:
        isSchedulerRequired in interface DiscoveryAgent
        Returns:
        true if the agent requires that its parent provide it with a scheduler.
      • setScheduler

        public void setScheduler​(java.util.concurrent.ScheduledExecutorService scheduler)
        Description copied from interface: DiscoveryAgent
        Provider a ScheduledExecutorService to the DiscoveryAgent that requires a scheduler to perform its discovery work. If the agent performs long polling style operations such as a socket read then it should not use the provided scheduler as that could block other agents from performing their own work.
        Specified by:
        setScheduler in interface DiscoveryAgent
        Parameters:
        scheduler - An initialized Scheduler service that this agent can use for its work.
      • start

        public void start()
                   throws org.apache.qpid.jms.provider.ProviderException,
                          java.lang.IllegalStateException
        Description copied from interface: DiscoveryAgent
        Starts the agent after which new remote peers can start to be found.
        Specified by:
        start in interface DiscoveryAgent
        Throws:
        org.apache.qpid.jms.provider.ProviderException - if an IO error occurs while starting the agent.
        java.lang.IllegalStateException - if the agent is not properly configured.
      • close

        public void close()
        Description copied from interface: DiscoveryAgent
        Stops the agent after which no new remote peers will be found. This method should attempt to close any agent resources and if an error occurs it should handle it and not re-throw to the calling entity.
        Specified by:
        close in interface DiscoveryAgent
      • suspend

        public void suspend()
        Description copied from interface: DiscoveryAgent
        Suspends the Agent which suppresses any new attempts to discover remote peers until the agent is resumed. If the service is not able to be suspended then this method should not throw an Exception, simply return as if successful.
        Specified by:
        suspend in interface DiscoveryAgent
      • resume

        public void resume()
        Description copied from interface: DiscoveryAgent
        Resumes discovery by this agent if it was previously suspended. If the agent does not support being suspended or is closed this method should simply return without throwing any exceptions.
        Specified by:
        resume in interface DiscoveryAgent
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getDiscvoeryURI

        public java.net.URI getDiscvoeryURI()
        Returns:
        the original URI used to create the Discovery Agent.
      • getUpdateInterval

        public int getUpdateInterval()
        Returns:
        the configured resource update interval.
      • setUpdateInterval

        public void setUpdateInterval​(int updateInterval)
        Parameters:
        updateInterval - the update interval to use for watching resources for changes.