Methods Summary |
---|
public static java.lang.Object | converConfigBeansToObjectNames(com.sun.enterprise.admin.meta.MBeanRegistry registry, javax.management.modelmbean.ModelMBeanInfo parentInfo, java.lang.Object ret)
if(ret!=null)
{
if(ret instanceof ConfigBean)
return (Object)getChildObjectName(registry, parentInfo, (ConfigBean)ret);
if(ret instanceof ConfigBean[])
return (Object)getChildObjectNames(registry, parentInfo, (ConfigBean[])ret);
}
return ret;
|
public static java.lang.String | convertTagName(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();
|
protected static void | debug(java.lang.String s)
//TODO: change this to app server logging
System.out.println(s);
|
protected static void | error(java.lang.String s)
//TODO: change this to app server logging
System.out.println(s);
|
public com.sun.enterprise.config.ConfigBean | getChildElementByName(java.lang.String methodName, java.lang.String name)Gets MBean's child element.
Class cl = m_baseConfigBean.getClass();
ConfigBean bean;
try
{
Method method = cl.getDeclaredMethod(methodName, new Class[]{Class.forName("java.lang.String")});
return (ConfigBean)method.invoke(m_baseConfigBean, new Object[]{name});
}
catch (Exception e)
{
String msg = /*localStrings.getString*/( "admin.server.core.mbean.config.getattribute.undefined_childelement_in_base_element"+ name );
throw new MBeanException(new MBeanConfigException( msg ));
}
|
public static java.lang.String[] | getChildNamesList(com.sun.enterprise.config.ConfigBean[] beans)
String[] names = new String[beans.length];
for(int i=0; i<beans.length; i++)
{
String xpath = beans[i].getAbsoluteXPath("");
names[i] = MBeanMetaHelper.getMultipleElementKeyValue(xpath);
}
return names;
|
public static javax.management.ObjectName | getChildObjectName(com.sun.enterprise.admin.meta.MBeanRegistry registry, javax.management.modelmbean.ModelMBeanInfo parentInfo, com.sun.enterprise.config.ConfigBean childBean)
Descriptor descr = parentInfo.getMBeanDescriptor();
return getConfigBeanObjectName(registry, (String)descr.getFieldValue(DOMAIN_FIELD_NAME), childBean);
|
public static javax.management.ObjectName[] | getChildObjectNames(com.sun.enterprise.admin.meta.MBeanRegistry registry, javax.management.modelmbean.ModelMBeanInfo parentInfo, com.sun.enterprise.config.ConfigBean[] children)
Descriptor descr = parentInfo.getMBeanDescriptor();
return getConfigBeansObjectNames(registry, (String)descr.getFieldValue(DOMAIN_FIELD_NAME), children);
|
public static java.lang.Class | getConfigBeanClass(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 static javax.management.ObjectName | getConfigBeanObjectName(com.sun.enterprise.admin.meta.MBeanRegistry registry, java.lang.String domainName, com.sun.enterprise.config.ConfigBean childBean)
String xpath = childBean.getAbsoluteXPath("");
MBeanRegistryEntry entry = registry.findMBeanRegistryEntryByXPath(xpath);
MBeanNamingDescriptor namingDescr = entry.getNamingDescriptor();
String[] location = namingDescr.extractParmListFromXPath(xpath);
location[0] = domainName;
return namingDescr.createObjectName((Object[])location);
|
public static javax.management.ObjectName[] | getConfigBeansObjectNames(com.sun.enterprise.admin.meta.MBeanRegistry registry, java.lang.String domainName, com.sun.enterprise.config.ConfigBean[] beans)
ObjectName[] objNames = new ObjectName[beans.length];
for(int i=0; i<beans.length; i++)
objNames[i] = getConfigBeanObjectName(registry, domainName, beans[i]);
return objNames;
|
public static javax.management.AttributeList | getDefaultAttributeValues(com.sun.enterprise.admin.meta.naming.MBeanNamingDescriptor descr, java.lang.String[] attrNames)
if(attrNames==null || attrNames.length<1)
return null;
AttributeList attrs = new AttributeList();
Class cl = getConfigBeanClass(descr.getXPathPattern());
if(cl==null)
return null;
Method method = cl.getDeclaredMethod("getDefaultAttributeValue", new Class[]{Class.forName("java.lang.String")});
for(int i=0; i<attrNames.length; i++)
{
try {
Object value = (String)method.invoke(null, new Object[]{MBeanMetaHelper.mapToConfigBeanAttributeName(attrNames[i])});
if(value!=null)
attrs.add(new Attribute(attrNames[i], value));
} catch(Exception e) {};
}
return attrs;
|
public static javax.management.ObjectName | getOwnObjectName(com.sun.enterprise.admin.meta.MBeanRegistry registry, javax.management.modelmbean.ModelMBeanInfo parentInfo)
Descriptor descr = parentInfo.getMBeanDescriptor();
String type = (String)descr.getFieldValue(NMTYPE_FIELD_NAME);
String[] location = (String[])descr.getFieldValue(NMLOCATION_FIELD_NAME);
MBeanRegistryEntry entry = registry.findMBeanRegistryEntryByType(type);
MBeanNamingDescriptor namingDescr = entry.getNamingDescriptor();
return namingDescr.createObjectName(location);
|
public java.lang.Object | getPropertyElementValue(java.lang.String propertyName)Gets MBean's property value.
Class cl = m_baseConfigBean.getClass();
ElementProperty prop;
try
{
Method method = cl.getDeclaredMethod("getElementPropertyByName", new Class[]{Class.forName("java.lang.String")});
prop = (ElementProperty)method.invoke(m_baseConfigBean, 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();
|
protected static void | info(java.lang.String s)
//TODO: change this to app server logging
System.out.println(s);
|
public void | setPropertyElementValue(javax.management.Attribute attr, boolean bAllowsEmptyValue)Sets MBean's property value.
String propertyName = attr.getName();
String value = (String)attr.getValue();
Class cl = m_baseConfigBean.getClass();
ElementProperty prop;
try
{
Method method = cl.getDeclaredMethod("getElementPropertyByName", new Class[]{Class.forName("java.lang.String")});
prop = (ElementProperty)method.invoke(m_baseConfigBean, 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(m_baseConfigBean, 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(m_baseConfigBean, 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()));
}
*/
|