Class FileWatcherDiscoveryAgent
- java.lang.Object
-
- org.apache.qpid.jms.provider.discovery.file.FileWatcherDiscoveryAgent
-
- All Implemented Interfaces:
DiscoveryAgent
public class FileWatcherDiscoveryAgent extends Object implements DiscoveryAgent
Discovery agent that watches a file and periodically reads in remote URIs from that file.
-
-
Constructor Summary
Constructors Constructor Description FileWatcherDiscoveryAgent(URI discoveryURI)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Stops the agent after which no new remote peers will be found.DiscoveryListenergetDiscoveryListener()URIgetDiscvoeryURI()intgetUpdateInterval()booleanisSchedulerRequired()Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.voidresume()Resumes discovery by this agent if it was previously suspended.voidsetDiscoveryListener(DiscoveryListener listener)Sets the discovery listenervoidsetScheduler(ScheduledExecutorService scheduler)Provider a ScheduledExecutorService to the DiscoveryAgent that requires a scheduler to perform its discovery work.voidsetUpdateInterval(int updateInterval)voidstart()Starts the agent after which new remote peers can start to be found.voidsuspend()Suspends the Agent which suppresses any new attempts to discover remote peers until the agent is resumed.StringtoString()
-
-
-
Constructor Detail
-
FileWatcherDiscoveryAgent
public FileWatcherDiscoveryAgent(URI discoveryURI) throws URISyntaxException
- Throws:
URISyntaxException
-
-
Method Detail
-
setDiscoveryListener
public void setDiscoveryListener(DiscoveryListener listener)
Description copied from interface:DiscoveryAgentSets the discovery listener- Specified by:
setDiscoveryListenerin interfaceDiscoveryAgent- Parameters:
listener- the listener to notify on discovery events, or null to clear.
-
getDiscoveryListener
public DiscoveryListener getDiscoveryListener()
-
isSchedulerRequired
public boolean isSchedulerRequired()
Description copied from interface:DiscoveryAgentIndicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.- Specified by:
isSchedulerRequiredin interfaceDiscoveryAgent- Returns:
- true if the agent requires that its parent provide it with a scheduler.
-
setScheduler
public void setScheduler(ScheduledExecutorService scheduler)
Description copied from interface:DiscoveryAgentProvider 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:
setSchedulerin interfaceDiscoveryAgent- Parameters:
scheduler- An initialized Scheduler service that this agent can use for its work.
-
start
public void start() throws ProviderException, IllegalStateExceptionDescription copied from interface:DiscoveryAgentStarts the agent after which new remote peers can start to be found.- Specified by:
startin interfaceDiscoveryAgent- Throws:
ProviderException- if an IO error occurs while starting the agent.IllegalStateException- if the agent is not properly configured.
-
close
public void close()
Description copied from interface:DiscoveryAgentStops 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:
closein interfaceDiscoveryAgent
-
suspend
public void suspend()
Description copied from interface:DiscoveryAgentSuspends 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:
suspendin interfaceDiscoveryAgent
-
resume
public void resume()
Description copied from interface:DiscoveryAgentResumes 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:
resumein interfaceDiscoveryAgent
-
getDiscvoeryURI
public 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.
-
-