Crossfire JXClient, Trunk
Classes | Public Member Functions | List of all members
com.sun.jmx.examples.scandir.ScanDirConfigMXBean Interface Reference
Inheritance diagram for com.sun.jmx.examples.scandir.ScanDirConfigMXBean:
Inheritance graph
Collaboration diagram for com.sun.jmx.examples.scandir.ScanDirConfigMXBean:
Collaboration graph

Classes

enum  SaveState
 

Public Member Functions

DirectoryScannerConfig addDirectoryScanner (String name, String dir, String filePattern, long sizeExceedsMaxBytes, long sinceLastModified) throws IOException, InstanceNotFoundException
 
String getConfigFilename () throws IOException, InstanceNotFoundException
 
ScanManagerConfig getConfiguration () throws IOException, InstanceNotFoundException
 
SaveState getSaveState () throws IOException, InstanceNotFoundException
 
void load () throws IOException, InstanceNotFoundException
 
DirectoryScannerConfig removeDirectoryScanner (String name) throws IOException, InstanceNotFoundException
 
void save () throws IOException, InstanceNotFoundException
 
void setConfiguration (ScanManagerConfig config) throws IOException, InstanceNotFoundException
 

Detailed Description

The ScanDirConfigMXBean is in charge of the scandir application configuration.

The ScanDirConfigMXBean is an MBean which 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.

Author
Sun Microsystems, 2006 - All rights reserved.

Definition at line 83 of file ScanDirConfigMXBean.java.

Member Function Documentation

◆ addDirectoryScanner()

DirectoryScannerConfig com.sun.jmx.examples.scandir.ScanDirConfigMXBean.addDirectoryScanner ( String  name,
String  dir,
String  filePattern,
long  sizeExceedsMaxBytes,
long  sinceLastModified 
) throws IOException, InstanceNotFoundException

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.

Parameters
nameA name for the new directory scanner. This is the value that will be later used in the DirectoryScannerMXBean ObjectName for the name= key.
dirThe root directory at which this scanner will start scanning.
filePatternA regular expression to match against a selected file name.
sizeExceedsMaxBytesOnly file whose size exceeds that limit will be selected. <code.0 or a negative value means no limit.
sinceLastModifiedSelect files which haven't been modified for that number of milliseconds - i.e.
sinceLastModified=3600000
will exclude files which have been modified in the last hour. The date of last modification is ignored if 0 or a negative value is provided.
See also
getSaveState()
Returns
The added DirectoryScannerConfig.
Exceptions
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

Referenced by com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener(), com.sun.jmx.examples.scandir.DirectoryScannerTest.testAddNotificationListener(), com.sun.jmx.examples.scandir.DirectoryScannerTest.testGetRootDirectory(), and com.sun.jmx.examples.scandir.DirectoryScannerTest.testScan().

Here is the caller graph for this function:

◆ getConfigFilename()

String com.sun.jmx.examples.scandir.ScanDirConfigMXBean.getConfigFilename ( ) throws IOException, InstanceNotFoundException

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.

Returns
The configuration file name for this MBean.
Exceptions
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

◆ getConfiguration()

ScanManagerConfig com.sun.jmx.examples.scandir.ScanDirConfigMXBean.getConfiguration ( ) throws IOException, InstanceNotFoundException

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.

See also
getSaveState()
Returns
The current configuration data in memory.
Exceptions
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

Referenced by com.sun.jmx.examples.scandir.ScanManager.applyConfiguration(), com.sun.jmx.examples.scandir.ScanManager.applyCurrentResultLogConfig(), com.sun.jmx.examples.scandir.ScanDirClient.main(), com.sun.jmx.examples.scandir.ScanManager.postRegister(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener(), com.sun.jmx.examples.scandir.DirectoryScannerTest.testGetRootDirectory(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testSave().

Here is the caller graph for this function:

◆ getSaveState()

SaveState com.sun.jmx.examples.scandir.ScanDirConfigMXBean.getSaveState ( ) throws IOException, InstanceNotFoundException

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.

Exceptions
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.
Returns
The save state of the
ScanDirConfigMXBean
.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

◆ load()

void com.sun.jmx.examples.scandir.ScanDirConfigMXBean.load ( ) throws IOException, InstanceNotFoundException

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.

See also
getSaveState()
Exceptions
IOExceptionThe configuration couldn't be loaded from the file, e.g. because the file doesn't exist or isn't readable.
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

Referenced by com.sun.jmx.examples.scandir.ScanManager.applyConfiguration(), com.sun.jmx.examples.scandir.ScanManager.postRegister(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener().

Here is the caller graph for this function:

◆ removeDirectoryScanner()

DirectoryScannerConfig com.sun.jmx.examples.scandir.ScanDirConfigMXBean.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.

Parameters
nameThe name of the new directory scanner. This is the value that is used in the DirectoryScannerMXBean ObjectName for the name= key.
Returns
The removed DirectoryScannerConfig.
Exceptions
IllegalArgumentExceptionif there's no directory scanner by that name in the current configuration data.
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

◆ save()

void com.sun.jmx.examples.scandir.ScanDirConfigMXBean.save ( ) throws IOException, InstanceNotFoundException

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.

See also
getSaveState()
Exceptions
IOExceptionThe configuration couldn't be saved to the file, e.g. because the file couldn't be created.
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

Referenced by com.sun.jmx.examples.scandir.ScanManager.applyCurrentResultLogConfig(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testSave().

Here is the caller graph for this function:

◆ setConfiguration()

void com.sun.jmx.examples.scandir.ScanDirConfigMXBean.setConfiguration ( ScanManagerConfig  config) throws IOException, InstanceNotFoundException

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.

Parameters
configThe new configuration data.
See also
getSaveState()
Exceptions
IOExceptionA connection problem occurred when accessing the underlying resource.
InstanceNotFoundExceptionThe underlying MBean is not registered in the MBeanServer.

Implemented in com.sun.jmx.examples.scandir.ScanDirConfig.

Referenced by com.sun.jmx.examples.scandir.ScanManager.applyCurrentResultLogConfig(), com.sun.jmx.examples.scandir.ScanDirConfigTest.testAddNotificationListener(), and com.sun.jmx.examples.scandir.ScanDirConfigTest.testSave().

Here is the caller graph for this function:

The documentation for this interface was generated from the following file: