Methods Summary |
---|
private void | emitDynamicReconfigEvent(boolean bEnabled)
try
{
AdminContext adminContext = MBeanRegistryFactory.getAdminContext();
String instanceName = adminContext.getServerName();
int action = bEnabled?DynamicReconfigEvent.ACTION_ENABLED:DynamicReconfigEvent.ACTION_DISABLED;
DynamicReconfigEvent event = new DynamicReconfigEvent(instanceName, action);
String configName = (String)getAttribute(ServerTags.NAME);
event.setTargetDestination(configName);
EventContext.addEvent(event);
}
catch (Exception e)
{
e.printStackTrace();
//throw new MBeanException(e.getMessage(), e);
}
|
private com.sun.enterprise.admin.servermgmt.RuntimeStatus | getRuntimeStatus()
String serverName =
System.getProperty(SystemPropertyConstants.SERVER_NAME);
PEInstancesManager manager = new PEInstancesManager(new RepositoryConfig());
return RuntimeStatus.getRuntimeStatus(serverName, manager);
|
public void | setAttribute(javax.management.Attribute attr)Set the value of a specific attribute of this MBean.
boolean bEnabled = false;
//first analyse if dynamic-reconfiguration-enabled attribute changed
if(ServerTags.DYNAMIC_RECONFIGURATION_ENABLED.equals(attr.getName()))
{
bEnabled = validateDynamicReconfigEvent(attr.getValue());
}
//next, call super to perform operation
super.setAttribute(attr);
if(ServerTags.DYNAMIC_RECONFIGURATION_ENABLED.equals(attr.getName()))
{
emitDynamicReconfigEvent(bEnabled);
}
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList list)Hook for standard setAttributes() to detect change for
dynamic-reconfiguration-enabled attribute Sets the values of several MBean's attributes.
boolean bEnabled = false;
int reconfigIdx = -1;
if(list!=null)
for(int i=0; i<list.size(); i++)
{
Attribute attr = (Attribute)list.get(i);
if(ServerTags.DYNAMIC_RECONFIGURATION_ENABLED.equals(attr.getName()))
{
try {
bEnabled = validateDynamicReconfigEvent(attr.getValue());
} catch(Exception e) {
reconfigIdx = i;
}
}
}
if (reconfigIdx != -1) {
list.remove(reconfigIdx);
}
//then, call super to perform operation
list = super.setAttributes(list);
if (reconfigIdx != -1) {
return list;
}
//now analyse if dynamic-reconfiguration-enabled attribute changed
if(list!=null)
for(int i=0; i<list.size(); i++)
{
Attribute attr = (Attribute)list.get(i);
if(ServerTags.DYNAMIC_RECONFIGURATION_ENABLED.equals(attr.getName()))
{
emitDynamicReconfigEvent(bEnabled);
}
}
return list;
|
private boolean | validateDynamicReconfigEvent(java.lang.Object value)
boolean bEnabled = false;
if(value instanceof Boolean)
bEnabled = ((Boolean)value).booleanValue();
else
if("true".equalsIgnoreCase(value.toString()) ||
"yes".equalsIgnoreCase(value.toString()) )
bEnabled = true;
boolean restartRequired = false;
try {
restartRequired = getRuntimeStatus().isRestartNeeded();
} catch(InstanceException ie) {
throw new MBeanException(ie);
}
if((bEnabled == true) && ( restartRequired == true)) {
String msg = _strMgr.getString(
"admin.mbeans.configMBean.serverRequiresRestart");
Exception e = new Exception(msg);
throw new MBeanException(e,msg);
}
return bEnabled;
|