FileDocCategorySizeDatePackage
ConfigMBeanBase.javaAPI DocGlassfish v2 API42073Fri May 04 22:33:56 BST 2007com.sun.enterprise.admin.server.core.mbean.config

ConfigMBeanBase

public class ConfigMBeanBase extends AdminBase
This base admin Dynamic MBean class provides access to ConfigNode's elements attributes according to attribute descriptions provided by child class.

Fields Summary
public static final Logger
sLogger
private static final String
MSG_BASE_GET_ATTRIBUTE
private static final String
MSG_BASE_SET_ATTRIBUTE
private static final String
MSG_BASE_GOT_ATTRIBUTE
private static final String
MSG_BASE_GET_PROPERTY
private static final String
MSG_BASE_SET_PROPERTY
private static final String
MSG_BASE_GET_DEF_ATTR_VALUE
private static final String
MSG_GET_CONFBEANBYXPATH
private static final String
MSG_LOG_CONF_CTX
public static final char
ATTRIBUTE_CHAR
public static final char
ALLOWS_EMPTY_CHAR
public static final String
ATTRIBUTE
public static final String
E_ATTRIBUTE
public static final String
PROPERTY
public static final String
E_PROPERTY
public static final String
ELEMENT_CONTENT
public static final String
PSEUDO_ATTR_DESCRIPTION
private com.sun.enterprise.admin.AdminContext
m_AdminContext
private com.sun.enterprise.config.ConfigContext
m_configContext
private String
m_BasePath
private Hashtable
m_Attrs
private MBeanInfo
m_MBeanInfo
private String
m_ServerInstanceName
private com.sun.enterprise.admin.server.core.mbean.config.naming.ConfigMBeanNamingInfo
m_MBeanNamingInfo
private static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
Methods Summary
static java.lang.Object[]MergeAttributesWithAnotherMbean(java.lang.String[][] maplist1, java.lang.String[] attributes1, java.lang.String[][] maplist2, java.lang.String[] attributes2, java.lang.String relativeXPath2, java.lang.String attrNamesPrefix2)
This method allows to append another bean attributes (usually child ones) to base attributes; so for MBean user they all will be as base

        int size = 0;
        if(maplist1!=null)
            size += maplist1.length;
        if(maplist2!=null)
            size += maplist2.length;
        String[][] new_maplist  = new String[size][];
        String[] new_attributes = new String[size];
        String[] mapelem;
        int i = 0;
        if(maplist1!=null)
            for(i=0; i<maplist1.length; i++)
            {
                new_maplist[i] = (String[])maplist1[i].clone();
                new_attributes[i] = attributes1[i];
            }
        if(maplist2!=null)
            for(int j=0; j<maplist2.length; j++)
            {
                mapelem = (String[])maplist2[j].clone();
                new_attributes[i+j] = attributes2[j];
                if(attrNamesPrefix2!=null)
                {
                   mapelem[0] = attrNamesPrefix2 + mapelem[0];
                   new_attributes[i+j] = attrNamesPrefix2 + attributes2[j].trim();
                }
                mapelem[1] = relativeXPath2 + "/" + mapelem[1];
                new_maplist[i+j] = mapelem;
            }
        return new Object[]{new_maplist, new_attributes};
        
    
public static java.lang.StringconvertName(java.lang.String name)
Convert a DTD name into a bean name: Any - or _ character is removed. The letter following - and _ is changed to be upper-case. If the user mixes upper-case and lower-case, the case is not changed. If the Word is entirely in upper-case, the word is changed to lower-case (except the characters following - and _) The first letter is always upper-case.

        CharacterIterator  ci;
        StringBuffer    n = new StringBuffer();
        boolean    up = true;
        boolean    keepCase = false;
        char    c;
        
        ci = new StringCharacterIterator(name);
        c = ci.first();
        
        // If everything is uppercase, we'll lowercase the name.
        while (c != CharacterIterator.DONE)
        {
            if (Character.isLowerCase(c))
            {
                keepCase = true;
                break;
            }
            c = ci.next();
        }
        
        c = ci.first();
        while (c != CharacterIterator.DONE)
        {
            if (c == '-" || c == '_")
                up = true;
            else
            {
                if (up)
                    c = Character.toUpperCase(c);
                else
                    if (!keepCase)
                        c = Character.toLowerCase(c);
                n.append(c);
                up = false;
            }
            c = ci.next();
        }
        return n.toString();
    
private java.util.HashtablecreateAttrsDescriptors(java.lang.String[][] attrs)

        Hashtable ht = new Hashtable();
        if (attrs != null)
        {
            for(int i=0; i<attrs.length; i++)
            {
                ht.put(attrs[i][0], 
                       new AttrDescriptor(attrs[i][1]));
            }
        }
        return ht;
    
public com.sun.enterprise.admin.AdminContextgetAdminContext()

        return m_AdminContext;
    
private java.lang.String[]getAllAttributeNames()

        if(m_Attrs==null )
            return null;
        Enumeration keys = m_Attrs.keys();   
        ArrayList list = new ArrayList();
        while(keys.hasMoreElements())
        {
            list.add(keys.nextElement());
        }
        return (String[])list.toArray(new String[list.size()]);
    
private java.lang.String[]getAllPropertyNames(boolean bAddPropertyPrefix)


        ConfigBean baseBean = getBaseConfigBean();
        Class cl = baseBean.getClass();
        ElementProperty[] props;
        try
        {
           Method method = cl.getDeclaredMethod("getElementProperty", (Class[])null);
           props = (ElementProperty[])method.invoke(baseBean, (Object[])null);
           String[] names = new String[props.length];
           for(int i=0; i<props.length; i++)
           {
               if(bAddPropertyPrefix)
                   names[i] = ConfigAttributeName.PROPERTY_NAME_PREFIX+props[i].getName();
               else
                   names[i] = props[i].getName();
           }
           return names;
        }
        catch (java.lang.NoSuchMethodException nsme)
        {
            return null;
        }
        catch (java.lang.IllegalAccessException iae)
        {
            return null;
        }
        catch (java.lang.reflect.InvocationTargetException ite)
        {
            return null;
        }
    
private javax.management.MBeanAttributeInfogetAttrInfo(java.lang.String attrName)

        if(attrName==null || m_MBeanInfo==null)
            return null;
        
        MBeanAttributeInfo[] ai = m_MBeanInfo.getAttributes();
        if(ai!=null)
            for(int i=0; i<ai.length; i++)
            {
                String name = ai[i].getName();
                if(attrName.equals(ai[i].getName()))
                    return ai[i];
            }
        return null;
    
public java.lang.ObjectgetAttribute(java.lang.String externalName)
Gets MBean's attribute value.

param
externalName the MBean's attribute name.
return
The value of the attribute retrieved.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        sLogger.log(Level.FINEST, MSG_BASE_GET_ATTRIBUTE, externalName);
        MBeanAttributeInfo ai = getAttrInfo(externalName);
        boolean isProperty = externalName.startsWith(ConfigAttributeName.PROPERTY_NAME_PREFIX);


        if(ai==null && !isProperty)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.attribute_not_defined", externalName );
			throw new AttributeNotFoundException( msg );
        }
        if(ai!=null && !ai.isReadable())
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.attribute_not_readable", externalName );
			throw new AttributeNotFoundException( msg );
        }

        
        
        try
        {
        if(isProperty)
        {
            // get property value
            return getPropertyElementValue(externalName.substring(ConfigAttributeName.PROPERTY_NAME_PREFIX.length()));
        }
        else
        {
            AttrDescriptor descr = getDescriptor(externalName);
            ConfigBean  bean = getConfigBean(externalName);
            String value = null;
            if(descr.isElement())
            {
                //it looks that now we have no Elements with values
                //value = descr.getNode().getContent();
				String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute_not_implemented_for_xml" );
                throw new MBeanException(new MBeanConfigException( msg ));
            }
            else
            {
                value = bean.getRawAttributeValue(descr.getAttributeName());

                //value = descr.getNode().getRawAttributeValue(descr.getAttributeName());
            }
            sLogger.log(Level.FINEST, MSG_BASE_GOT_ATTRIBUTE, new Object[]{externalName,value, MBeanEasyConfig.convertStringValueToProperType(value, ai.getType())});
            return MBeanEasyConfig.convertStringValueToProperType(value, ai.getType());
        }
        }
        catch (MBeanConfigException e)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute_attribute_exception", externalName, e.getMessage() );
            throw new MBeanException(new MBeanConfigException( msg ));
        }

 
public javax.management.AttributeListgetAttributes(java.lang.String[] attributeNames)
Gets MBean's attribute values.

param
attributeNames A list of the attributes names to be retrieved.
return
The list of attributes retrieved.

        AttributeList attrs = new AttributeList();
        for(int i=0; i<attributeNames.length; i++)
        {
//            try
            {
                if(attributeNames[i].length()==0)
                {
                    String[] names = getAllAttributeNames();
                    if(names!=null)
                        attrs.addAll(getAttributes(names));
                }
                else
                {
                    if(attributeNames[i].equals(ConfigAttributeName.PROPERTY_NAME_PREFIX))
                    {
                        String[] names = getAllPropertyNames(true);
                        if(names!=null)
                            attrs.addAll(getAttributes(names));
                    }
                    else
                    {
                        try
                        {
                            Object value  = getAttribute(attributeNames[i]);
                            attrs.add(new Attribute(attributeNames[i], value));
                        }
                        catch (MBeanException ce)
                        {
                            attrs.add(new Attribute(attributeNames[i], null));
                        }
                        catch (AttributeNotFoundException ce)
                        {
                            attrs.add(new Attribute(attributeNames[i], null));
                        }
                        catch (NullPointerException npe) //ConfigBean returns this exception by many reasons
                        {
                            attrs.add(new Attribute(attributeNames[i], null));
                        }
                    }
                }
            }
//            catch (Throwable t)
//            {
//            }
        }
        return attrs;
    
public com.sun.enterprise.config.ConfigBeangetBaseConfigBean()
Get base node Config Bean;

return
ConfigBean related to the ConfigNode object of node which is used as base for locationg of the attributes.

        try
        {
           return getConfigBeanByXPath(m_BasePath);
        }
        catch (Exception e)
        {
           return null;
        }
    
public java.lang.StringgetBasePath()
Get path to base node; all attributes pathes are defined relatively this node.

return
XPath style path to the ConfigNode object of node which is used as base for locationg of the attributes.

        return m_BasePath;
    
public com.sun.enterprise.config.ConfigBeangetConfigBean(java.lang.String externalName)
Get ConfigBean object which contains correspondent attribute.

param
externalName external name of the attribute
return
ConfigBean object which contains correspondent attribute

        //this method can be overriten in child class (temporary until Config static method getBeanByXPath will be ready)
        AttrDescriptor descr = getDescriptor(externalName);
        try
        {
            return descr.getConfigBean();
        }
        catch (Exception e)
        {
            return null;
        }
    
public com.sun.enterprise.config.ConfigBeangetConfigBeanByXPath(java.lang.String xPath)
Get ConfigBean object which binded to ConfigNode with given XPath.

param
xPath XPath to ConfigNode
return
ConfigBean object which linked to ConfigNode with given XPath.

        sLogger.log(Level.FINEST, MSG_GET_CONFBEANBYXPATH, xPath);
        return ConfigBeansFactory.getConfigBeanByXPath(m_configContext, xPath);
    
private static java.lang.ClassgetConfigBeanClass(java.lang.String xPath)

        // get ConfigBean classname from XPath
        String beanName = ConfigBeansFactory.getConfigBeanNameByXPath(xPath);
        //getting the class object
        try
        {
            Class cl = Class.forName("com.sun.enterprise.config.serverbeans."+beanName);
            return cl;
        }
        catch(Exception e)
        {
            return null;
        }
    
public com.sun.enterprise.config.ConfigContextgetConfigContext()

        return m_configContext;
    
public com.sun.enterprise.admin.server.core.mbean.config.naming.ConfigMBeanNamingInfogetConfigMBeanNamingInfo()

        return m_MBeanNamingInfo;
    
public java.lang.ObjectgetDefaultAttributeValue(java.lang.String externalName)
Gets MBean's attribute default value or null (if def value is not defined).

param
externalName the MBean's attribute name.
return
The default value of the attribute retrieved null, if def value is not defined.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        sLogger.log(Level.FINEST, MSG_BASE_GET_DEF_ATTR_VALUE, externalName);
        MBeanAttributeInfo ai = getAttrInfo(externalName);
        if(ai==null) {
			String msg = localStrings.getString( "admin.server.core.mbean.config.getdefaultattribute_undefined_attribute", externalName );
            throw new AttributeNotFoundException( msg );
		}
//        try
        {
            AttrDescriptor descr = getDescriptor(externalName);
            String value = descr.getDefaultValue();
            return MBeanEasyConfig.convertStringValueToProperType(value, ai.getType());
        }
/*        catch (ConfigException e)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.getdefaultattributevalue_exception_for_externalname_basexpath", externalName, m_BasePath, e.getMessage() );
            throw new MBeanException(new ConfigException( msg ));
        } 
*/
    
private com.sun.enterprise.admin.server.core.mbean.config.ConfigMBeanBase$AttrDescriptorgetDescriptor(java.lang.String externalName)

        return (AttrDescriptor)m_Attrs.get(externalName);
    
protected java.lang.ClassgetImplementingClass()
Abstract method that subclasses have to implement. This is the way for invoke method to work, through reflection.

        return ( this.getClass() );
    
protected java.lang.ObjectgetImplementingMBean()
Reflection requires the implementing object.

        return ( this );
    
public javax.management.MBeanInfogetMBeanInfo()
Get MBeanInfo MBean description object (required dynamic MBean method).

return
MBeanInfo description object for configurable MBean;

        return m_MBeanInfo;
    
public java.lang.ObjectgetPropertyElementValue(java.lang.String propertyName)
Gets MBean's property value.

param
externalName the MBean's property name.
return
The value of the property retrieved.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        sLogger.log(Level.FINEST, MSG_BASE_GET_PROPERTY, propertyName);

        ConfigBean baseBean = getBaseConfigBean();
        Class cl = baseBean.getClass();
        ElementProperty prop;
        try
        {
           Method method = cl.getDeclaredMethod("getElementPropertyByName", new Class[]{Class.forName("java.lang.String")});
           prop = (ElementProperty)method.invoke(baseBean, new Object[]{propertyName});
        }
        catch (Exception e)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute.undefined_properties_in_base_element", propertyName );
            throw new MBeanException(new MBeanConfigException( msg ));
        }
        if(prop==null) {
			String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute_properties_not_found_in_base_element", propertyName );
            throw new MBeanException(new MBeanConfigException( msg ));
		}
        return prop.getValue();
    
public java.lang.StringgetServerInstanceName()

        return m_ServerInstanceName;
    
public voidinitialize(com.sun.enterprise.admin.server.core.mbean.config.naming.ConfigMBeanNamingInfo namingInfo)
Binds MBean with Config Bean

param
instanceName instance name.
throws
MbeanConfigException exception if the param parsing is not successful


  
                              
         
    
        String instanceName = namingInfo.getServerInstanceName();
        ConfigContext configContext;
        if (m_AdminContext != null) {
            configContext = m_AdminContext.getAdminConfigContext();
        } else {
            try
            {
                InstanceEnvironment instanceEnvironment = new InstanceEnvironment(instanceName);
                //String fileUrl  = instanceEnvironment.getConfigFilePath();
			    /*Everything should be set in the backup file*/
			    String fileUrl  = instanceEnvironment.getConfigFilePath();
                configContext   = ConfigFactory.createConfigContext(fileUrl);
            }
            catch(ConfigException e)
            {
                //e.printStackTrace();
    			String msg = localStrings.getString( "admin.server.core.mbean.config.error_locating_server_node", e.getMessage() );
                throw new MBeanConfigException( msg );
            }
        }
        
        sLogger.log(Level.FINEST, MSG_LOG_CONF_CTX, new Object[] {
                this.getClass().getName(), new Long(configContext.hashCode())});
        m_ServerInstanceName = instanceName;
        m_configContext = configContext;
        m_MBeanNamingInfo = namingInfo;
        m_BasePath = namingInfo.getXPath();
    
public voidinitialize(java.lang.String mbeanType, java.lang.String[] locations)

        ConfigMBeanNamingInfo namingInfo;
        try
        {
            namingInfo = new ConfigMBeanNamingInfo(mbeanType, locations);
        }
        catch (MBeanConfigException mce)
        {
            throw mce;
        }
        catch (Exception e)
        {
            throw new MBeanConfigException(e.getMessage());
        }
        
        initialize(namingInfo);
    
public voidinitialize(java.lang.String dottedName)

        ConfigMBeanNamingInfo namingInfo;
        try
        {
            namingInfo = new ConfigMBeanNamingInfo(dottedName);
        }
        catch (MBeanConfigException mce)
        {
            throw mce;
        }
        catch (Exception e)
        {
            throw new MBeanConfigException(e.getMessage());
        }
        
        initialize(namingInfo);
    
public voidinitialize(javax.management.ObjectName objectName)

        ConfigMBeanNamingInfo namingInfo;
        try
        {
            namingInfo = new ConfigMBeanNamingInfo(objectName);
        }
        catch (MBeanConfigException mce)
        {
            throw mce;
        }
        catch (Exception e)
        {
            throw new MBeanConfigException(e.getMessage());
        }
        
        initialize(namingInfo);
    
public java.lang.Objectinvoke(java.lang.String methodName, java.lang.Object[] methodParams, java.lang.String[] methodSignature)
Every resource MBean should override this method to execute specific operations on the MBean.

        //return null;
        /*
         * New for 8.0
        */
        return ( super.invoke(methodName, methodParams, methodSignature) );
    
public voidsetAdminContext(com.sun.enterprise.admin.AdminContext adminContext)

        m_AdminContext = adminContext;
    
public voidsetAttribute(javax.management.Attribute attr)
Sets MBean's attribute value.

param
attr The identification of the attribute to be set and the value it is to be set to.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        String externalName = attr.getName();
        Object value = attr.getValue();
        sLogger.log(Level.FINEST, MSG_BASE_SET_ATTRIBUTE, new Object[]{externalName, value});
        MBeanAttributeInfo ai = getAttrInfo(externalName);
        boolean isProperty = externalName.startsWith(ConfigAttributeName.PROPERTY_NAME_PREFIX);
        if(ai==null && !isProperty)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.setattribute_undefined_attribute", externalName );
            throw new AttributeNotFoundException( msg );
        }
        if(ai!=null && !ai.isWritable())
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.setattribute_attribute_not_writable", externalName );
            throw new MBeanException(new MBeanConfigException( msg ));
        }
        
        try
        {
            if(isProperty)
            {
                boolean bAllowsEmptyValue = true;
                if(ai!=null)
                {
                    AttrDescriptor descr = getDescriptor(externalName);
                    if(descr!=null)
                    {
                       bAllowsEmptyValue = descr.isEmptyValueAllowed();
                    }
                }
                // set property value
                setPropertyElementValue(new Attribute(externalName.substring(ConfigAttributeName.PROPERTY_NAME_PREFIX.length()), value), bAllowsEmptyValue);
                return;
            }
            else
            { //normal attribute
                // check type (now only for exception)
// left check for Verifyer now (bug #4725686) 
//                MBeanEasyConfig.convertStringValueToProperType(value.toString(), ai.getType());

                AttrDescriptor descr = getDescriptor(externalName);
                ConfigBean  bean = getConfigBean(externalName);
                if(descr.isElement())
                {
                    //it looks that now we have no Elements with values
                    //bean.set???Value(descr.getAttributeName(), value.toString());
					String msg = localStrings.getString( "admin.server.core.mbean.config.getattribute_not_implemented_for_xml" );
                    throw new MBeanException(new MBeanConfigException( msg ));

    //                descr.getNode().setContent(value.toString());
    //                m_configContext.flush();
                }
                else
                {

                    //descr.getNode().setAttribute(descr.getAttributeName(), value.toString());
                    if(value==null || (value.equals("") && !descr.isEmptyValueAllowed()) )
                       bean.setAttributeValue(descr.getAttributeName(), null);
                    else
                       bean.setAttributeValue(descr.getAttributeName(), value.toString());
                    m_configContext.flush();
                }
            }
            
        }
//        catch (MBeanConfigException mce)
//        {
//			String msg = localStrings.getString( "admin.server.core.mbean.config.setattribute_attribute_exception",  externalName, mce.getMessage() );
//            throw new MBeanException(new MBeanConfigException( msg ));
//        }
        catch (ConfigException e)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.setAttribute_exception_for_externalname_basexpath", externalName, m_BasePath, e.getMessage() );
            throw new MBeanException(new MBeanConfigException( msg ));
        }
    
public javax.management.AttributeListsetAttributes(javax.management.AttributeList attrList)
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.

        AttributeList attrs = new AttributeList();
        Iterator it = attrList.iterator();
        while (it.hasNext())
        {
            try
            {
                Attribute attribute = (Attribute) it.next();
                setAttribute(attribute);
                attrs.add(attribute);
            }
            catch (MBeanException mbe)
            {
            }
            catch (AttributeNotFoundException anfe)
            {
            }
            catch (NullPointerException npe)
            {
            }
        }
        return attrs;
    
public voidsetDescriptions(java.lang.String[][] attrsMapList, java.lang.String[] attrDescriptions, java.lang.String[] operDescriptions)
Sets Config MBean description data (this method usually is calling from the child class constructor)

param
attrsMapList array of attribute mapping descriptions, each subarray represents one attribute by string pairs:
{ <external name>, <path to value> } for each attribute, where
    <external name> defines name identifying value in getAttribute()/SetAttribute() methods;
    <path to value> is relative path to value from the base node in XPath notation;
Example (attribute value):
ORBListener port attribute in orblistener node can be described as
    { "port", "@port" }
If entire description for attribute is missing, then getAttribute()/SetAttribute() treats this situation the same way as it was described as {"@<attrName>]","<attrName>"}. Examples (element value):
    { "about", "description[@type='thisInstance')]" } //this example for value of element with tag 'description' ans attribute 'type' equales to 'myInstance'
    { "about", "description" } //this example for value of unique element with tag 'description'
param
attrDescriptions String array of MBean attribute descriptions in MBeanEasyConfig format.
param
operDescriptions String array of MBean operations descriptions in MBeanEasyConfig format.
throws
MBeanConfigException exception if the param parsing is not successful

        m_Attrs = createAttrsDescriptors(attrsMapList);
        MBeanEasyConfig easyConfig = new MBeanEasyConfig(getClass(), attrDescriptions, operDescriptions, null);
        m_MBeanInfo = easyConfig.getMBeanInfo();
    
public voidsetPropertyElementValue(javax.management.Attribute attr, boolean bAllowsEmptyValue)
Sets MBean's property value.

param
attr The identification of the property to be set and the value it is to be set to.
throws
MBeanException exception
throws
AttributeNotFoundException exception

        String propertyName = attr.getName();
        String value = (String)attr.getValue();
        sLogger.log(Level.FINEST, MSG_BASE_SET_PROPERTY, new Object[]{propertyName, value});
        
        ConfigBean baseBean = getBaseConfigBean();

        Class cl = baseBean.getClass();
        ElementProperty prop;
        try
        {
           Method method = cl.getDeclaredMethod("getElementPropertyByName", new Class[]{Class.forName("java.lang.String")});
           prop = (ElementProperty)method.invoke(baseBean, new Object[]{propertyName});
        }
        catch (Exception e)
        {
			String msg = localStrings.getString( "admin.server.core.mbean.config.setattribute_undefined_properties_in_base_element", propertyName );
            throw new MBeanException(new MBeanConfigException( msg ));
        }
        if(prop==null && value!=null && (bAllowsEmptyValue || !value.equals("")))
        {
            prop = new ElementProperty();
            prop.setName(propertyName);
            prop.setValue(value);
            try
            {
                Method method = cl.getDeclaredMethod("addElementProperty", new Class[]{prop.getClass()});
                method.invoke(baseBean, new Object[]{prop});
            }
            catch (Exception e)
            {
				String msg = localStrings.getString( "admin.server.core.mbean.config.setproperty_invoke_error", propertyName );
                throw new MBeanException(new MBeanConfigException( msg ));
            }
        }
        else
        {
            if(value==null || (!bAllowsEmptyValue && value.equals("")))
            {
                try
                {
                    Method method = cl.getDeclaredMethod("removeElementProperty", new Class[]{prop.getClass()});
                    method.invoke(baseBean, new Object[]{prop});
                }
                catch (Exception e)
                {
					String msg = localStrings.getString( "admin.server.core.mbean.config.setproperty_could_not_remove_propery", propertyName );
                    throw new MBeanException(new MBeanConfigException( msg ));
                }
            }
            else
                prop.setValue(value);
        }
        
        try
        {
            m_configContext.flush();
        }
        catch (ConfigException e)
        {
            throw new MBeanException(new MBeanConfigException(e.getMessage()));
        }