org.sadun.util.polling
Class ManagedDirectoryPoller

java.lang.Object
  extended byBaseSignalSourceThread
      extended byorg.sadun.util.polling.DirectoryPoller
          extended byorg.sadun.util.polling.ManagedDirectoryPoller
All Implemented Interfaces:
ManagedDirectoryPollerMBean

public class ManagedDirectoryPoller
extends DirectoryPoller
implements ManagedDirectoryPollerMBean

A JMX managed subclass of directory poller, exposing the ManagedDirectoryPollerMBean interface.

From v1.5, JMX notifications are also emitted together with the existing events.

One or more listeners may be registered to the Poller, allowing MBeans in

Author:
cris
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.sadun.util.polling.DirectoryPoller
DirectoryPoller.AutomoveDeleteException, DirectoryPoller.AutomoveException, DirectoryPoller.FileSizeComparator, DirectoryPoller.ModificationTimeComparator, DirectoryPoller.NullFilenameFilter
 
Field Summary
 
Fields inherited from class org.sadun.util.polling.DirectoryPoller
DEFAULT_AUTOMOVE_DIRECTORY, pollManagersList
 
Constructor Summary
ManagedDirectoryPoller()
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.File directory)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.File[] dirs)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.File[] dirs, java.io.FilenameFilter filter)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.File[] dirs, java.io.FilenameFilter filter, boolean timeBased)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.File directory, java.io.FilenameFilter filter)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.File directory, java.io.FilenameFilter filter, boolean timeBased)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.FilenameFilter filter)
          Constructor for ManagedDirectoryPoller.
ManagedDirectoryPoller(java.io.FilenameFilter filter, boolean timeBased)
          Constructor for ManagedDirectoryPoller.
 
Method Summary
 void addControlledDirectory(java.lang.String dir)
          Add one directory to the controlled set.
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback)
          Implement the NotificationBroadcaster interface, by registering the listener at the internal JMXNotificationsPollManager.
 void addNotificationListener(ObjectName listenerMBeanName)
          Register a listening MBean (found in the only existing MBean server) via its ObjectName.
 void addNotificationListener(java.lang.String mbeanServerName, ObjectName listenerMBeanName)
          Register a listening MBean via its ObjectName.
 void addPollManager(PollManager pm)
          Adds on PollManager to the poller, which will be notified on polling events.
 int countControlledDirectories()
           
 java.lang.String getAcceptedFilenamePattern()
           
 java.lang.String getAutoMoveDirectoryPath(java.lang.String directory)
           
 long getBaseTime(java.lang.String directory)
           
 java.lang.String getControlledDirectories()
           
 java.lang.String getControlledDirectory(int i)
           
 java.lang.String getEventsOrdering()
           
 java.lang.String getFilenameFilterFactory()
           
 java.lang.String getFilenameFilterFactoryClass()
           
 java.lang.String getFilesSortComparatorClass()
           
 java.lang.String getJMXSequenceNumberGeneratorClass()
           
 java.lang.String getJMXTimerObjectName()
          Returns the jMXTimerObjectName.
 MBeanNotificationInfo[] getNotificationInfo()
           
 java.lang.String getPollManagerFactory()
           
 java.lang.String getPollManagerFactoryClass()
           
 void handleNotification(Notification arg0, java.lang.Object arg1)
          Handles timer notifications, if a JMXTimer object is used
 boolean isRunning()
           
 boolean isUsingJMXTimer()
          Returns the usingJMXTimer.
 java.lang.String listControlledDirectories()
           
 java.lang.String listInstalledPollManagers()
           
 void postDeregister()
           
 void postRegister(java.lang.Boolean registrationDone)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
 void removeControlledDirectory(java.lang.String dir)
          Remove one directory from the controlled set.
 void removeNotificationListener(NotificationListener listener)
          Implement the NotificationBroadcaster interface, by removing the listener from the internal JMXNotificationsPollManager.
 void removeNotificationListener(java.lang.String mbeanServerName, ObjectName listenerMBeanName)
          Remove a listening MBean via its ObjectName.
 void setAcceptedFilenamePattern(java.lang.String filenamePattern)
           
 void setAutoMoveDirectoryPath(java.lang.String directory, java.lang.String automoveDirectory)
           
 void setBaseTime(java.lang.String directory, long time)
           
 void setControlledDirectories(java.lang.String dirList)
           
 void setEventsOrdering(java.lang.String expr)
           
 void setFilenameFilterFactoryClass(java.lang.String newFilenameFilterFactoryClsName)
           
 void setFilesSortComparatorClass(java.lang.String fileComparatorClassName)
           
 void setFilter(java.io.FilenameFilter filter)
          Set the current filter.
 void setJMXSequenceNumberGeneratorClass(java.lang.String sequenceNumberGeneratorClass)
           
 void setJMXTimerObjectName(java.lang.String jMXTimerObjectName)
          Sets the jMXTimerObjectName.
 void setPollManagerFactoryClass(java.lang.String newFactoryClsName)
           
 void setUsingJMXTimer(boolean usingJMXTimer_NewValue)
          Sets the usingJMXTimer.
 void shutDown()
           
 void startUp()
          Starts a thread for the poller
 
Methods inherited from class org.sadun.util.polling.DirectoryPoller
addDirectory, checkIfManaged, getAutoMove, getAutoMoveDirectory, getBaseTime, getDirectories, getFilesSortComparator, getFilter, getPollInterval, isBypassLockedFiles, isDebugExceptions, isPollingTimeBased, isSendSingleFileEvent, isShuttingDown, isSleeping, isStartBySleeping, isTimeBased, isVerbose, removeDirectory, run, setAutoMove, setAutoMoveDirectory, setBaseTime, setBaseTime, setBypassLockedFiles, setDebugExceptions, setDirectories, setFilesSortComparator, setPollingTimeBased, setPollInterval, setSendSingleFileEvent, setStartBySleeping, setTimeBased, setVerbose, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sadun.util.polling.ManagedDirectoryPollerMBean
getAutoMove, getFilter, getPollInterval, isBypassLockedFiles, isDebugExceptions, isPollingTimeBased, isSendSingleFileEvent, isStartBySleeping, isTimeBased, isVerbose, removeNotificationListener, setAutoMove, setBypassLockedFiles, setDebugExceptions, setPollingTimeBased, setPollInterval, setSendSingleFileEvent, setStartBySleeping, setTimeBased, setVerbose
 

Constructor Detail

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.File[] dirs,
                              java.io.FilenameFilter filter)
Constructor for ManagedDirectoryPoller.

Parameters:
dirs -
filter -

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.File[] dirs)
Constructor for ManagedDirectoryPoller.

Parameters:
dirs -

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.File directory,
                              java.io.FilenameFilter filter)
Constructor for ManagedDirectoryPoller.

Parameters:
directory -
filter -

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.File directory)
Constructor for ManagedDirectoryPoller.

Parameters:
directory -

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.FilenameFilter filter)
Constructor for ManagedDirectoryPoller.

Parameters:
filter -

ManagedDirectoryPoller

public ManagedDirectoryPoller()
Constructor for ManagedDirectoryPoller.


ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.File[] dirs,
                              java.io.FilenameFilter filter,
                              boolean timeBased)
Constructor for ManagedDirectoryPoller.

Parameters:
dirs -
filter -
timeBased -

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.File directory,
                              java.io.FilenameFilter filter,
                              boolean timeBased)
Constructor for ManagedDirectoryPoller.

Parameters:
directory -
filter -
timeBased -

ManagedDirectoryPoller

public ManagedDirectoryPoller(java.io.FilenameFilter filter,
                              boolean timeBased)
Constructor for ManagedDirectoryPoller.

Parameters:
filter -
timeBased -
Method Detail

postDeregister

public void postDeregister()
See Also:
javax.management.MBeanRegistration#postDeregister()

postRegister

public void postRegister(java.lang.Boolean registrationDone)
See Also:
javax.management.MBeanRegistration#postRegister(java.lang.Boolean)

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
javax.management.MBeanRegistration#preDeregister()

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer, javax.management.ObjectName)

startUp

public void startUp()
Starts a thread for the poller

Specified by:
startUp in interface ManagedDirectoryPollerMBean
See Also:
Runnable.run()

shutDown

public void shutDown()
Specified by:
shutDown in interface ManagedDirectoryPollerMBean

getAutoMoveDirectoryPath

public java.lang.String getAutoMoveDirectoryPath(java.lang.String directory)
Specified by:
getAutoMoveDirectoryPath in interface ManagedDirectoryPollerMBean

removeControlledDirectory

public void removeControlledDirectory(java.lang.String dir)
Remove one directory from the controlled set. It can be called only if the poller thread hasn't started yet.

Specified by:
removeControlledDirectory in interface ManagedDirectoryPollerMBean
Parameters:
dir - the directory to remove
Throws:
java.lang.IllegalStateException - if the poller has already started.
java.lang.IllegalArgumentException - if the directory is not among the controlled ones

addControlledDirectory

public void addControlledDirectory(java.lang.String dir)
Add one directory to the controlled set. It can be called only if the poller thread hasn't started yet.

Specified by:
addControlledDirectory in interface ManagedDirectoryPollerMBean
Parameters:
dir - the directory to add
Throws:
java.lang.IllegalStateException - if the poller has already started.
java.lang.IllegalArgumentException - if String does not contain a directory path

countControlledDirectories

public int countControlledDirectories()
Specified by:
countControlledDirectories in interface ManagedDirectoryPollerMBean
See Also:
ManagedDirectoryPollerMBean.countControlledDirectories()

isRunning

public boolean isRunning()
Specified by:
isRunning in interface ManagedDirectoryPollerMBean

getControlledDirectory

public java.lang.String getControlledDirectory(int i)
Specified by:
getControlledDirectory in interface ManagedDirectoryPollerMBean
See Also:
ManagedDirectoryPollerMBean.getControlledDirectory(int)

setBaseTime

public void setBaseTime(java.lang.String directory,
                        long time)
Specified by:
setBaseTime in interface ManagedDirectoryPollerMBean

getBaseTime

public long getBaseTime(java.lang.String directory)
Specified by:
getBaseTime in interface ManagedDirectoryPollerMBean

listControlledDirectories

public java.lang.String listControlledDirectories()
Specified by:
listControlledDirectories in interface ManagedDirectoryPollerMBean

getControlledDirectories

public java.lang.String getControlledDirectories()
Specified by:
getControlledDirectories in interface ManagedDirectoryPollerMBean

setControlledDirectories

public void setControlledDirectories(java.lang.String dirList)
Specified by:
setControlledDirectories in interface ManagedDirectoryPollerMBean

listInstalledPollManagers

public java.lang.String listInstalledPollManagers()
Specified by:
listInstalledPollManagers in interface ManagedDirectoryPollerMBean

addPollManager

public void addPollManager(PollManager pm)
Description copied from class: DirectoryPoller
Adds on PollManager to the poller, which will be notified on polling events.

You may add many poll managers, but there is no support for inter-poll manager coordination, so if a PollManager deletes/moves a polled file, the others will still receive the associated event, but may not be able to perform proper processing.

Overrides:
addPollManager in class DirectoryPoller

getPollManagerFactoryClass

public java.lang.String getPollManagerFactoryClass()
Specified by:
getPollManagerFactoryClass in interface ManagedDirectoryPollerMBean
See Also:
ManagedDirectoryPollerMBean.getPollManagerFactory()

setPollManagerFactoryClass

public void setPollManagerFactoryClass(java.lang.String newFactoryClsName)
                                throws java.lang.InstantiationException,
                                       java.lang.IllegalAccessException,
                                       java.lang.ClassNotFoundException
Specified by:
setPollManagerFactoryClass in interface ManagedDirectoryPollerMBean
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
See Also:
ManagedDirectoryPollerMBean.setPollManagerFactoryClass(java.lang.String)

getPollManagerFactory

public java.lang.String getPollManagerFactory()
Specified by:
getPollManagerFactory in interface ManagedDirectoryPollerMBean
See Also:
ManagedDirectoryPollerMBean.getPollManagerFactory()

isUsingJMXTimer

public boolean isUsingJMXTimer()
Returns the usingJMXTimer.

Specified by:
isUsingJMXTimer in interface ManagedDirectoryPollerMBean
Returns:
boolean

setUsingJMXTimer

public void setUsingJMXTimer(boolean usingJMXTimer_NewValue)
Sets the usingJMXTimer.

Specified by:
setUsingJMXTimer in interface ManagedDirectoryPollerMBean

getJMXTimerObjectName

public java.lang.String getJMXTimerObjectName()
Returns the jMXTimerObjectName.

Specified by:
getJMXTimerObjectName in interface ManagedDirectoryPollerMBean
Returns:
String

setJMXTimerObjectName

public void setJMXTimerObjectName(java.lang.String jMXTimerObjectName)
Sets the jMXTimerObjectName.

Specified by:
setJMXTimerObjectName in interface ManagedDirectoryPollerMBean
Parameters:
jMXTimerObjectName - The jMXTimerObjectName to set

handleNotification

public void handleNotification(Notification arg0,
                               java.lang.Object arg1)
Handles timer notifications, if a JMXTimer object is used

See Also:
javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object)

setFilenameFilterFactoryClass

public void setFilenameFilterFactoryClass(java.lang.String newFilenameFilterFactoryClsName)
                                   throws java.lang.InstantiationException,
                                          java.lang.IllegalAccessException,
                                          java.lang.ClassNotFoundException
Specified by:
setFilenameFilterFactoryClass in interface ManagedDirectoryPollerMBean
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException

getFilenameFilterFactory

public java.lang.String getFilenameFilterFactory()
Specified by:
getFilenameFilterFactory in interface ManagedDirectoryPollerMBean

getFilenameFilterFactoryClass

public java.lang.String getFilenameFilterFactoryClass()
Specified by:
getFilenameFilterFactoryClass in interface ManagedDirectoryPollerMBean

setAcceptedFilenamePattern

public void setAcceptedFilenamePattern(java.lang.String filenamePattern)
Specified by:
setAcceptedFilenamePattern in interface ManagedDirectoryPollerMBean

setFilter

public void setFilter(java.io.FilenameFilter filter)
Description copied from class: DirectoryPoller
Set the current filter. This can be invoked only when the poller is not running.

Overrides:
setFilter in class DirectoryPoller
Parameters:
filter - the new filename filter to use.

getAcceptedFilenamePattern

public java.lang.String getAcceptedFilenamePattern()
Specified by:
getAcceptedFilenamePattern in interface ManagedDirectoryPollerMBean

setAutoMoveDirectoryPath

public void setAutoMoveDirectoryPath(java.lang.String directory,
                                     java.lang.String automoveDirectory)
Specified by:
setAutoMoveDirectoryPath in interface ManagedDirectoryPollerMBean

getFilesSortComparatorClass

public java.lang.String getFilesSortComparatorClass()
Specified by:
getFilesSortComparatorClass in interface ManagedDirectoryPollerMBean

setFilesSortComparatorClass

public void setFilesSortComparatorClass(java.lang.String fileComparatorClassName)
                                 throws java.lang.InstantiationException,
                                        java.lang.IllegalAccessException,
                                        java.lang.ClassNotFoundException
Specified by:
setFilesSortComparatorClass in interface ManagedDirectoryPollerMBean
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException

setEventsOrdering

public void setEventsOrdering(java.lang.String expr)
Specified by:
setEventsOrdering in interface ManagedDirectoryPollerMBean

getEventsOrdering

public java.lang.String getEventsOrdering()
Specified by:
getEventsOrdering in interface ManagedDirectoryPollerMBean

getJMXSequenceNumberGeneratorClass

public java.lang.String getJMXSequenceNumberGeneratorClass()
Specified by:
getJMXSequenceNumberGeneratorClass in interface ManagedDirectoryPollerMBean

setJMXSequenceNumberGeneratorClass

public void setJMXSequenceNumberGeneratorClass(java.lang.String sequenceNumberGeneratorClass)
                                        throws MBeanException
Specified by:
setJMXSequenceNumberGeneratorClass in interface ManagedDirectoryPollerMBean
Throws:
MBeanException

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    java.lang.Object handback)
                             throws java.lang.IllegalArgumentException
Implement the NotificationBroadcaster interface, by registering the listener at the internal JMXNotificationsPollManager.

Throws:
java.lang.IllegalArgumentException

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
Implement the NotificationBroadcaster interface, by removing the listener from the internal JMXNotificationsPollManager.

Throws:
ListenerNotFoundException

addNotificationListener

public void addNotificationListener(ObjectName listenerMBeanName)
                             throws InstanceNotFoundException
Register a listening MBean (found in the only existing MBean server) via its ObjectName. Only one MBean server must be present.

Specified by:
addNotificationListener in interface ManagedDirectoryPollerMBean
Parameters:
listenerMBeanName - the object name of the mbean which listens to to the poller's JMX notifications
Throws:
InstanceNotFoundException

addNotificationListener

public void addNotificationListener(java.lang.String mbeanServerName,
                                    ObjectName listenerMBeanName)
                             throws InstanceNotFoundException
Register a listening MBean via its ObjectName.

Specified by:
addNotificationListener in interface ManagedDirectoryPollerMBean
Parameters:
listenerMBeanName - the object name of the mbean which listens to to the poller's JMX notifications
Throws:
InstanceNotFoundException

removeNotificationListener

public void removeNotificationListener(java.lang.String mbeanServerName,
                                       ObjectName listenerMBeanName)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Remove a listening MBean via its ObjectName.

Specified by:
removeNotificationListener in interface ManagedDirectoryPollerMBean
Parameters:
listenerMBeanName - the object name of the mbean which is not to listen anymore to the poller's JMX notifications
Throws:
InstanceNotFoundException
ListenerNotFoundException


Copyright © 1999, 2000 Cristiano Sadun. This software is released under GPL.