Crossfire JXClient, Trunk
|
Public Member Functions | |
DirectoryScannerConfig | addDirectoryScanner (String name, String dir, String filePattern, long sizeExceedsMaxBytes, long sinceLastModified) |
String | getConfigFilename () |
ScanManagerConfig | getConfiguration () |
SaveState | getSaveState () |
void | load () throws IOException |
void | postDeregister () |
void | postRegister (Boolean registrationDone) |
void | preDeregister () throws Exception |
ObjectName | preRegister (MBeanServer server, ObjectName name) throws Exception |
DirectoryScannerConfig | removeDirectoryScanner (String name) throws IOException, InstanceNotFoundException |
void | save () throws IOException |
ScanDirConfig (String filename) | |
ScanDirConfig (String filename, ScanManagerConfig initialConfig) | |
void | setConfiguration (ScanManagerConfig config) |
Static Public Attributes | |
static final String | NOTIFICATION_LOADED |
static final String | NOTIFICATION_MODIFIED |
static final String | NOTIFICATION_SAVED |
Static Package Functions | |
static String | guessConfigName (String configFileName, String defaultFile) |
Static Package Attributes | |
static String | DEFAULT = "DEFAULT" |
Private Member Functions | |
void | sendNotification (String type) |
Static Private Member Functions | |
static String | getBasename (String name) |
Private Attributes | |
volatile ScanManagerConfig | config |
volatile String | configname = null |
String | filename = null |
volatile MBeanServer | mbeanServer |
volatile ObjectName | objectName |
volatile SaveState | status = CREATED |
Static Private Attributes | |
static final Logger | LOG |
static MBeanNotificationInfo[] | NOTIFICATION_INFO |
static final String | NOTIFICATION_PREFIX |
The ScanDirConfig
MBean is in charge of the scandir application configuration.
The ScanDirConfig
MBean is able to load and save the scandir application configuration to and from an XML file.
It will let you also interactively modify that configuration, which you can later save to the file, by calling save, or discard, by reloading the file without saving - see load.
There can be as many ScanDirConfigMXBean
registered in the MBeanServer as you like, but only one of them will be identified as the current configuration of the ScanManagerMXBean. You can switch to another configuration by calling {ScanManagerMXBean.setConfigurationMBean}.
Once the current configuration has been loaded (by calling load) or modified (by calling one of addDirectoryScanner, removeDirectoryScanner or setConfiguration) it can be pushed to the ScanManagerMXBean by calling {ScanManagerMXBean.applyConfiguration(true)} - true
means that we apply the configuration from memory, without first reloading the file.
The ScanDirConfig
uses the XML annotated Java Beans defined in the com.sun.jmx.examples.scandir.config package.
Note: The ScanDirConfig
should probably use
and lock its configuration file so that two ScanDirConfig
object do not share the same file, but it doesn't. Feel free to improve the application in that way.
Definition at line 103 of file ScanDirConfig.java.
com.sun.jmx.examples.scandir.ScanDirConfig.ScanDirConfig | ( | String | filename | ) |
Creates a new ScanDirConfigMXBean.
can be created by the {}, or directly by a remote client, using createMBean or registerMBean .
This object is created empty, you should call load() if you want it to load its data from the configuration file.
filename | The configuration file used by this MBean. Can be null (in which case load() and save() will fail). Can point to a file that does not exists yet (in which case load() will fail if called before save(), and save() will attempt to create that file). Can point to an existing file, in which case load() will load that file and save() will save to that file. |
Definition at line 202 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.filename.
com.sun.jmx.examples.scandir.ScanDirConfig.ScanDirConfig | ( | String | filename, |
ScanManagerConfig | initialConfig | ||
) |
Create a new ScanDirConfig MBean with an initial configuration.
filename | The name of the configuration file. |
initialConfig | an initial configuration. |
Definition at line 211 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.filename, and com.sun.jmx.examples.scandir.ScanDirConfig.NOTIFICATION_INFO.
DirectoryScannerConfig com.sun.jmx.examples.scandir.ScanDirConfig.addDirectoryScanner | ( | String | name, |
String | dir, | ||
String | filePattern, | ||
long | sizeExceedsMaxBytes, | ||
long | sinceLastModified | ||
) |
Adds a new directory scanner to the current configuration data.
This method updates the configuration data in memory, adding a DirectoryScannerConfig to the {directory scanner list}. The #getSaveState state} is switched to { SaveState#MODIFIED MODIFIED}.
Calling load will reload the data from the configuration file, and all modifications will be lost. Calling save will save the modified data to the configuration file.
This action has no effect on the ScanManagerMXBean until ScanManagerMXBean points to this MBean and ScanManagerMXBean.applyConfiguration is called.
name | A name for the new directory scanner. This is the value that will be later used in the DirectoryScannerMXBean ObjectName for the name= key. |
dir | The root directory at which this scanner will start scanning. |
filePattern | A regular expression to match against a selected file name. |
sizeExceedsMaxBytes | Only file whose size exceeds that limit will be selected. <code.0 or a negative value means no limit. |
sinceLastModified | Select files which haven't been modified for that number of milliseconds - i.e. sinceLastModified=3600000
0 or a negative value is provided. |
DirectoryScannerConfig
. IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 363 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, com.sun.jmx.examples.scandir.ScanDirConfig.LOG, name(), com.sun.jmx.examples.scandir.ScanDirConfig.NOTIFICATION_MODIFIED, com.sun.jmx.examples.scandir.config.ScanManagerConfig.putScan(), com.sun.jmx.examples.scandir.ScanDirConfig.sendNotification(), com.sun.jmx.examples.scandir.config.FileMatch.setFilePattern(), com.sun.jmx.examples.scandir.config.FileMatch.setLastModifiedBefore(), com.sun.jmx.examples.scandir.config.FileMatch.setSizeExceedsMaxBytes(), and com.sun.jmx.examples.scandir.ScanDirConfig.status.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddDirectoryScanner().
|
staticprivate |
Definition at line 410 of file ScanDirConfig.java.
References name().
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.guessConfigName().
String com.sun.jmx.examples.scandir.ScanDirConfig.getConfigFilename | ( | ) |
Gets the name of the configuration file.
If the configuration file doesn't exists, load will fail and save will attempt to create the file.
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 340 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.filename.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testGetConfigFilename().
ScanManagerConfig com.sun.jmx.examples.scandir.ScanDirConfig.getConfiguration | ( | ) |
Gets the current configuration data.
This method returns the configuration data which is currently held in memory.
Call load to reload the data from the configuration file, and save to save the data to the configuration file.
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 245 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, and com.sun.jmx.examples.scandir.config.XmlConfigUtils.xmlClone().
Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testGetXmlConfigString(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testLoad().
SaveState com.sun.jmx.examples.scandir.ScanDirConfig.getSaveState | ( | ) |
Gets the save state of the current configuration data.
CREATED means that the configuration data was just created. It has not been loaded from the configuration file. Calling load will load the data from the configuration file. Calling save will write the empty data to the configuration file.
LOADED means that the configuration data was loaded from the configuration file.
MODIFIED means that the configuration data was modified since it was last loaded or saved. Calling load will reload the data from the configuration file, and all modifications will be lost. Calling save will write the modified data to the configuration file.
SAVED means that the configuration data was saved to the configuration file.
This state doesn't indicate whether this MBean configuration data was applied by the ScanManagerMXBean.
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 401 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.status.
|
staticpackage |
Definition at line 417 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.DEFAULT, com.sun.jmx.examples.scandir.ScanDirConfig.getBasename(), com.sun.jmx.examples.scandir.config.ScanManagerConfig.getName(), and com.sun.jmx.examples.scandir.config.XmlConfigUtils.read().
Referenced by com.sun.jmx.examples.scandir.ScanManager.postRegister().
void com.sun.jmx.examples.scandir.ScanDirConfig.load | ( | ) | throws IOException |
Loads the configuration from the {configuration file}. Any unsaved modification will be lost. The state is switched to LOADED.
This action has no effect on the ScanManagerMXBean until ScanManagerMXBean points to this MBean and ScanManagerMXBean.applyConfiguration is called.
IOException | The configuration couldn't be loaded from the file, e.g. because the file doesn't exist or isn't readable. |
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 219 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, com.sun.jmx.examples.scandir.ScanDirConfig.configname, com.sun.jmx.examples.scandir.config.ScanManagerConfig.copy(), com.sun.jmx.examples.scandir.ScanDirConfig.filename, com.sun.jmx.examples.scandir.config.ScanManagerConfig.getName(), com.sun.jmx.examples.scandir.ScanDirConfig.NOTIFICATION_LOADED, com.sun.jmx.examples.scandir.config.XmlConfigUtils.readFromFile(), com.sun.jmx.examples.scandir.ScanDirConfig.sendNotification(), and com.sun.jmx.examples.scandir.ScanDirConfig.status.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testLoad().
void com.sun.jmx.examples.scandir.ScanDirConfig.postDeregister | ( | ) |
Allows the MBean to perform any operations needed after having been unregistered in the MBean server.
This implementation does nothing
Definition at line 335 of file ScanDirConfig.java.
void com.sun.jmx.examples.scandir.ScanDirConfig.postRegister | ( | Boolean | registrationDone | ) |
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
This implementation does nothing
registrationDone | Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration has failed. |
Definition at line 315 of file ScanDirConfig.java.
void com.sun.jmx.examples.scandir.ScanDirConfig.preDeregister | ( | ) | throws Exception |
Allows the MBean to perform any operations it needs before being unregistered by the MBean server.
This implementation does nothing
Exception | This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException. |
Definition at line 326 of file ScanDirConfig.java.
ObjectName com.sun.jmx.examples.scandir.ScanDirConfig.preRegister | ( | MBeanServer | server, |
ObjectName | name | ||
) | throws Exception |
Allows the MBean to perform any operations it needs before being registered in the MBean server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean server.
server | The MBean server in which the MBean will be registered. |
name | The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method will try to guess its MBean name by examining its configuration data. If its configuration data is null (nothing was provided in the constructor) or doesn't contain a name, this method returns null
|
Otherwise, if
wasn't
or if a default name could be constructed, the name of the configuration will be set to the value of the ObjectName's
key, and the configuration data will always be renamed to reflect this change.
Exception | This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException. |
Definition at line 288 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, com.sun.jmx.examples.scandir.ScanDirConfig.configname, com.sun.jmx.examples.scandir.config.ScanManagerConfig.copy(), com.sun.jmx.examples.scandir.config.ScanManagerConfig.getName(), com.sun.jmx.examples.scandir.ScanDirConfig.mbeanServer, name(), com.sun.jmx.examples.scandir.ScanDirConfig.objectName, and server().
DirectoryScannerConfig com.sun.jmx.examples.scandir.ScanDirConfig.removeDirectoryScanner | ( | String | name | ) | throws IOException, InstanceNotFoundException |
Removes a directory scanner from the current configuration data.
This method updates the configuration data in memory, removing a DirectoryScannerConfig from the {directory scanner list}. The #getSaveState state} is switched to { SaveState#MODIFIED MODIFIED}.
Calling load will reload the data from the configuration file, and all modifications will be lost. Calling save will save the modified data to the configuration file.
This action has no effect on the ScanManagerMXBean until ScanManagerMXBean points to this MBean and ScanManagerMXBean.applyConfiguration is called.
name | The name of the new directory scanner. This is the value that is used in the DirectoryScannerMXBean ObjectName for the name= key. |
DirectoryScannerConfig
. IllegalArgumentException | if there's no directory scanner by that name in the current configuration data. |
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 387 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, name(), com.sun.jmx.examples.scandir.ScanDirConfig.NOTIFICATION_MODIFIED, com.sun.jmx.examples.scandir.config.ScanManagerConfig.removeScan(), com.sun.jmx.examples.scandir.ScanDirConfig.sendNotification(), and com.sun.jmx.examples.scandir.ScanDirConfig.status.
void com.sun.jmx.examples.scandir.ScanDirConfig.save | ( | ) | throws IOException |
Saves the configuration to the {configuration file}. If the configuration file doesn't exists, this method will attempt to create it. Otherwise, the existing file will be renamed by appending a '~' to its name, and a new file will be created, in which the configuration will be saved. The state is switched to SAVED.
This action has no effect on the ScanManagerMXBean.
IOException | The configuration couldn't be saved to the file, e.g. because the file couldn't be created. |
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 234 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, com.sun.jmx.examples.scandir.ScanDirConfig.filename, com.sun.jmx.examples.scandir.ScanDirConfig.NOTIFICATION_SAVED, com.sun.jmx.examples.scandir.ScanDirConfig.sendNotification(), com.sun.jmx.examples.scandir.ScanDirConfig.status, and com.sun.jmx.examples.scandir.config.XmlConfigUtils.writeToFile().
Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddDirectoryScanner().
|
private |
Definition at line 253 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.objectName.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.addDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.load(), com.sun.jmx.examples.scandir.ScanDirConfig.removeDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.save(), and com.sun.jmx.examples.scandir.ScanDirConfig.setConfiguration().
void com.sun.jmx.examples.scandir.ScanDirConfig.setConfiguration | ( | ScanManagerConfig | config | ) |
Sets the current configuration data.
This method replaces the configuration data in memory. The state is switched to {MODIFIED}.
Calling load will reload the data from the configuration file, and all modifications will be lost. Calling save will save the modified data to the configuration file.
This action has no effect on the ScanManagerMXBean until ScanManagerMXBean points to this MBean and ScanManagerMXBean.applyConfiguration is called.
config | The new configuration data. |
IOException | A connection problem occurred when accessing the underlying resource. |
InstanceNotFoundException | The underlying MBean is not registered in the MBeanServer. |
Implements com.sun.jmx.examples.scandir.ScanDirConfigMXBean.
Definition at line 345 of file ScanDirConfig.java.
References com.sun.jmx.examples.scandir.ScanDirConfig.config, com.sun.jmx.examples.scandir.ScanDirConfig.configname, com.sun.jmx.examples.scandir.config.ScanManagerConfig.copy(), com.sun.jmx.examples.scandir.config.ScanManagerConfig.getName(), com.sun.jmx.examples.scandir.ScanDirConfig.NOTIFICATION_MODIFIED, com.sun.jmx.examples.scandir.ScanDirConfig.sendNotification(), and com.sun.jmx.examples.scandir.ScanDirConfig.status.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddDirectoryScanner(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testGetXmlConfigString().
|
private |
Definition at line 164 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.addDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.getConfiguration(), com.sun.jmx.examples.scandir.ScanDirConfig.load(), com.sun.jmx.examples.scandir.ScanDirConfig.preRegister(), com.sun.jmx.examples.scandir.ScanDirConfig.removeDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.save(), and com.sun.jmx.examples.scandir.ScanDirConfig.setConfiguration().
|
private |
Definition at line 171 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.load(), com.sun.jmx.examples.scandir.ScanDirConfig.preRegister(), and com.sun.jmx.examples.scandir.ScanDirConfig.setConfiguration().
|
staticpackage |
Definition at line 408 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.guessConfigName().
|
private |
|
staticprivate |
A logger for this class.
Definition at line 109 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.addDirectoryScanner().
|
private |
Definition at line 437 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.preRegister().
|
staticprivate |
Definition at line 148 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.ScanDirConfig().
|
static |
The com.sun.jmx.examples.scandir.config.loaded notification indicates that the configuration data was loaded.
Definition at line 133 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.load(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener().
|
static |
The com.sun.jmx.examples.scandir.config.modified notification indicates that the configuration data was modified.
Definition at line 140 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.addDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.removeDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.setConfiguration(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener().
|
staticprivate |
Definition at line 120 of file ScanDirConfig.java.
|
static |
The com.sun.jmx.examples.scandir.config.saved notification indicates that the configuration data was saved.
Definition at line 127 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.save(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener().
|
private |
Definition at line 438 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.preRegister(), and com.sun.jmx.examples.scandir.ScanDirConfig.sendNotification().
|
private |
Definition at line 175 of file ScanDirConfig.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirConfig.addDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.getSaveState(), com.sun.jmx.examples.scandir.ScanDirConfig.load(), com.sun.jmx.examples.scandir.ScanDirConfig.removeDirectoryScanner(), com.sun.jmx.examples.scandir.ScanDirConfig.save(), and com.sun.jmx.examples.scandir.ScanDirConfig.setConfiguration().