FileDocCategorySizeDatePackage
DomainStatus.javaAPI DocGlassfish v2 API5722Fri May 04 22:24:08 BST 2007com.sun.enterprise.admin.mbeans

DomainStatus

public class DomainStatus extends NotificationBroadcasterSupport implements DomainStatusMBean
Provides for determining the state of servers within the scope of this domain
author
Sreenivas Munnangi

Fields Summary
private static final Logger
sLogger
variables
private static final com.sun.enterprise.util.i18n.StringManager
localStrings
private Map
m
Constructors Summary
public DomainStatus()
default constructor


           
      
	m = Collections.synchronizedMap(new HashMap());
    
Methods Summary
public javax.management.MBeanServerConnectiongetServerMBeanServerConnection(java.lang.String serverName)
get the mBean server connection for the given server


	sLogger.log(Level.FINE, 
		"DomainStatus.getServerMBeanServerConnection for " + serverName);
	// vars
	ConfigContext configContext = 
		AdminService.getAdminService().getAdminContext().getAdminConfigContext();
	MBeanServerConnection mbsc = null;

	// check if DAS
	if (ServerHelper.isDAS(configContext, serverName)) {
		mbsc = MBeanServerFactory.getMBeanServer();
	} else {
		mbsc = ServerHelper.connect(configContext, serverName);
	}

	return mbsc;
    
public intgetstate(java.lang.String serverName)
get the current state of the given server

return
int the current value of the state

	sLogger.log(Level.FINE, "DomainStatus.getstate for " + serverName);
	// check for server name and return the value
	if ((serverName != null) && (serverName.length() > 0)) {
		if (m.containsKey(serverName)) {
			return ((Integer) m.get(serverName)).intValue();
		} else {
			throw new Exception(
				localStrings.getString(
				"admin.mbeans.domainStatus.serverNotFound",
				serverName));
		}
	}
	return StateManageable.STATE_FAILED;
    
private voidsendServerStatusChangedNotification(java.lang.String serverName)
send status change notification


	sLogger.log(Level.FINE, 
	"DomainStatus.sendServerStatusChangedNotification for " + serverName);

	Map m = Collections.synchronizedMap(new HashMap());
	m.put(DomainStatusMBean.SERVER_NAME_KEY, serverName);
	Notification notification = new Notification(
			  DomainStatusMBean.SERVER_STATUS_NOTIFICATION_TYPE,
			  this,
			  0,
			  serverName);
	notification.setUserData(m);
	sendNotification(notification);
    
public voidsetstate(java.lang.String serverName, java.lang.Integer state)
set the current state of the given server

	sLogger.log(Level.FINE, "DomainStatus.setstate for " + serverName);
	// check for server name and set the value
	if ((serverName != null) && (serverName.length() > 0)) {
		m.put(serverName, state);
		// send notification
		sendServerStatusChangedNotification(serverName);
	} else {
		throw new Exception(
				localStrings.getString(
				"admin.mbeans.domainStatus.serverNotFound",
				serverName));
	}