com.tivoli.jmx.jar
Class JarInstaller

com.tivoli.jmx.jar.JarInstaller

public class JarInstaller
implements JarInstallerMBean

This MBean works as a deployer of all the jar management system. Its constructor receives in input an array of directories to be monitored and optionally a domain. It can be further configured through two attributes: the granularity period to specify the observation time interval and the purge attribute.

At registration time this MBean instatiates, through the MBeanServer, a javax.management.timer.Timer a com.tivoli.jmx.jar.DirectoryObserver for each directory specified, and an com.tivoli.jmx.jar.MLetManager.

All the DirectoryObservers are added as listeners to the javax.management.timer.Timer while the com.tivoli.jmx.jar.MLetManager is added as listener in all the DirectoryObservers. When the "enable" method is invoked, the javax.management.timer.Timer is started.

Periodically the javax.management.timer.Timer sends a Notification to all the DirectoryObservers in order to perform the directory check to verify, for instance, if a new jar has been added. In turn., if a change is observed, the com.tivoli.jmx.jar.MLetManager might receive a notification to register or unregister an javax.management.loading.MLet.

This process can be stopped through the "disable" method since it stops the javax.management.timer.Timer.

At deregistration time the javax.management.timer.Timer, the com.tivoli.jmx.jar.MLetManager and all the DirectoryObservers are deregistered according to the "purge" attribute value. In case the "purge" attribute is set to true, the com.tivoli.jmx.jar.MLetManager provides, in turn, to deregister all the MLets.

Version:
1.3
Author:
Max Parlione

Constructor Summary
JarInstaller(java.io.File directory)
          Creates an instance configured with the specified directory and the default domain
JarInstaller(java.io.File[] directories)
          Creates an instance configured with the specified directories and the default domain
JarInstaller(java.io.File[] directories, java.lang.String domain)
          Creates an instance configured with the specified directories and domain
JarInstaller(java.io.File directory, java.lang.String domain)
          Creates an instance configured with the specified directory and the domain.
 
Method Summary
 void disable()
          Disables the polling activity
 void enable()
          The directories start to be monitored.
 java.io.File[] getDirectories()
          Returns the observed directories
 long getGranularityPeriod()
          Gets the polling time.
 boolean getPurge()
          Returns the purge flag.
 void initializeObservers()
          Initializes the observers by invoking their
 boolean isActive()
          Returns the status.
 void postDeregister()
          Invoked after the deregistration
 void postRegister(java.lang.Boolean registrationDone)
          Invoked after the deregistration.
 void preDeregister()
          Removes the framework used before deregistration.
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
          Creates the framework before registration
 void setGranularityPeriod(long granularityPeriod)
          Sets the polling time.
 void setPurge(boolean purge)
          Sets the purge flag.
 

Constructor Detail

JarInstaller

public JarInstaller(java.io.File directory)
Creates an instance configured with the specified directory and the default domain
Parameters:
directories - the directories to be observed

JarInstaller

public JarInstaller(java.io.File directory,
                    java.lang.String domain)
Creates an instance configured with the specified directory and the domain.
Parameters:
directories - the directories to be observed
domain - the domain to be used

JarInstaller

public JarInstaller(java.io.File[] directories)
Creates an instance configured with the specified directories and the default domain
Parameters:
directories - the directories to be observed

JarInstaller

public JarInstaller(java.io.File[] directories,
                    java.lang.String domain)
Creates an instance configured with the specified directories and domain
Parameters:
directories - the directories to be observed
domain - the domain to be used
Method Detail

getDirectories

public java.io.File[] getDirectories()
Returns the observed directories
Specified by:
getDirectories in interface JarInstallerMBean
Returns:
the directories observed

setGranularityPeriod

public void setGranularityPeriod(long granularityPeriod)
Sets the polling time. Note that this will be effective only first to invoke enable
Specified by:
setGranularityPeriod in interface JarInstallerMBean
Parameters:
granularityPeriod - the granularity period to poll the directories

getGranularityPeriod

public long getGranularityPeriod()
Gets the polling time.
Specified by:
getGranularityPeriod in interface JarInstallerMBean
Returns:
The granularity period to poll the directories

setPurge

public void setPurge(boolean purge)
Sets the purge flag.
Specified by:
setPurge in interface JarInstallerMBean
Parameters:
purge - True enables the deregistration of all the MLet registered by the JarInstaller MBean

getPurge

public boolean getPurge()
Returns the purge flag.
Specified by:
getPurge in interface JarInstallerMBean
Returns:
purge True enables the deregistration of all the MLet registered by the JarInstaller MBean

enable

public void enable()
The directories start to be monitored.
Specified by:
enable in interface JarInstallerMBean
Throws:
java.lang.IllegalStateException - If the JarInstaller has not been registered in the MBean Server

disable

public void disable()
Disables the polling activity
Specified by:
disable in interface JarInstallerMBean
Throws:
java.lang.IllegalStateException - If the JarInstaller has not been registered in the MBean Server

isActive

public boolean isActive()
Returns the status.
Specified by:
isActive in interface JarInstallerMBean
Parameters:
the - current status
Throws:
java.lang.IllegalStateException - If the JarInstaller has not been registered in the MBean Server

postDeregister

public void postDeregister()
Invoked after the deregistration

preDeregister

public void preDeregister()
Removes the framework used before deregistration.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Invoked after the deregistration.
Parameters:
registrationDone -  

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Creates the framework before registration
Parameters:
server - the mBeanServer
name - the ObjectName to be used

initializeObservers

public void initializeObservers()
Initializes the observers by invoking their