FileDocCategorySizeDatePackage
OrbChangeHandler.javaAPI DocGlassfish v2 API6709Fri May 04 22:24:20 BST 2007com.sun.enterprise.admin.monitor.registry.spi.reconfig

OrbChangeHandler

public class OrbChangeHandler extends Object implements ChangeHandler
Provides for dynamic reconfiguration of ORB and related components like connection manager. This class decides the actions to take when there are changes to the monitoring level through administrative interfaces.
author
Kedar Mhaswade
since
S1AS8.0
version
$Revision: 1.4 $

Fields Summary
private final ChangeHandler
successor
private final com.sun.enterprise.admin.monitor.registry.spi.ValueListMap
listeners
private static final Logger
logger
Constructors Summary
OrbChangeHandler(ChangeHandler successor, com.sun.enterprise.admin.monitor.registry.spi.ValueListMap listeners)

	
	    
		this.successor	= successor;
		this.listeners	= listeners;
	
Methods Summary
public voidhandleChange(com.sun.enterprise.admin.monitor.registry.MonitoredObjectType t, com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

		if (isOrbType(t)) {
			handleChange(from, to);
		}
		else {
			successor.handleChange(t, from, to);
		}
	
private voidhandleChange(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

		if (off2Low(from, to) || off2High(from, to)) {
			notifyListeners(from, to);
			registerMBeans();
		}
		if (low2Off(from, to) || high2Off(from, to)) {
			unregisterMBeans();
			notifyListeners(from, to);
		}
		if (low2High(from, to) || high2Low(from, to)) {
			//currently do nothing.
		}
	
private booleanhigh2Low(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

		return ( from == MonitoringLevel.HIGH && to == MonitoringLevel.LOW );
	
private booleanhigh2Off(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

 
		return ( from == MonitoringLevel.HIGH && to == MonitoringLevel.OFF );
	
private booleanisOrbType(com.sun.enterprise.admin.monitor.registry.MonitoredObjectType t)

		return ( t == MonitoredObjectType.ORB		||
				 t == MonitoredObjectType.CONNECTION_MANAGER);
	
private booleanlow2High(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

 
		return ( from == MonitoringLevel.LOW && to == MonitoringLevel.HIGH);
	
private booleanlow2Off(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

 
		return ( from == MonitoringLevel.LOW && to == MonitoringLevel.OFF);
	
private voidnotifyListeners(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

		logger.finer("DynamicReconfigurator: Now notifying the listeners for ORB stats --- from = " + from.toString() + " to = " + to.toString());
	
private booleanoff2High(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

 
		return ( from == MonitoringLevel.OFF && to == MonitoringLevel.HIGH );
	
private booleanoff2Low(com.sun.enterprise.admin.monitor.registry.MonitoringLevel from, com.sun.enterprise.admin.monitor.registry.MonitoringLevel to)

 
		return ( from == MonitoringLevel.OFF && to == MonitoringLevel.LOW );
	
private voidregisterMBeans()

		final MonitoringRegistrationHelper registryImpl	= 
			(MonitoringRegistrationHelper) MonitoringRegistrationHelper.getInstance();
		//note that the above refers to the actual implementation rather than interface.

		//registers MBeans pertaining to all the connection managers
		final Iterator iter = registryImpl.getOrbNodes().iterator();
		while (iter.hasNext()) {
			final StatsHolder c = (StatsHolder) iter.next();
			c.registerMBean();
			logger.finer("DynamicReconfigurator: Now Registering MBean for --- " + c.getName());
		}
	
private voidunregisterMBeans()

		final MonitoringRegistrationHelper registryImpl	= 
			(MonitoringRegistrationHelper) MonitoringRegistrationHelper.getInstance();
		//note that the above refers to the actual implementation rather than interface.

		final Iterator iter = registryImpl.getOrbNodes().iterator();
		while (iter.hasNext()) {
			final StatsHolder c = (StatsHolder) iter.next();
			c.unregisterMBean();
			logger.finer("DynamicReconfigurator: Now UnRegistering MBean for --- " + c.getName());
		}