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

ConfigMBean

public class ConfigMBean extends com.sun.enterprise.admin.config.BaseConfigMBean

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
_strMgr
Constructors Summary
Methods Summary
private voidemitDynamicReconfigEvent(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.RuntimeStatusgetRuntimeStatus()

        
        String serverName = 
            System.getProperty(SystemPropertyConstants.SERVER_NAME);
        PEInstancesManager manager = new PEInstancesManager(new RepositoryConfig());
        return RuntimeStatus.getRuntimeStatus(serverName, manager);        
    
public voidsetAttribute(javax.management.Attribute attr)
Set the value of a specific attribute of this MBean.

param
attr The identification of the attribute to be set and the new value
exception
AttributeNotFoundException if this attribute is not supported by this MBean
exception
MBeanException if the initializer of an object throws an exception
exception
ReflectionException if a Java reflection exception occurs when invoking the getter

        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.AttributeListsetAttributes(javax.management.AttributeList list)
Hook for standard setAttributes() to detect change for dynamic-reconfiguration-enabled attribute Sets the values of several MBean's attributes.

param
attrList A list of attributes: The identification of the attributes to be set and the values they are to be set to.
return
The list of attributes that were set, with their new values.

            
            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 booleanvalidateDynamicReconfigEvent(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;