Methods Summary |
---|
private boolean | checkItemsInReconfigurableSet(java.lang.String name1, java.lang.String name2)
Set set = getDynamicallyReconfigurableAttributes();
if(set==null || set.size()<1)
return false;
if(set.contains("**") ||
set.contains(name1) ||
(name2!=null && set.contains(name2)))
return true;
return false;
|
private static java.util.Set | convertDelimListToSet(java.lang.String list)
HashSet set = new HashSet();
StringTokenizer tokenizer = new StringTokenizer(list, ", ");
while(tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken();
if(token.length()>0) //?
set.add(token);
}
return set;
|
private static java.util.HashMap | convertListOfFieldsToHashMap(java.util.List fields)
Iterator iter = fields.iterator();
HashMap fldsMap = new HashMap();
while(iter.hasNext())
{
FieldInfo field = (FieldInfo)iter.next();
fldsMap.put(field.getName(), field.getValue());
}
return fldsMap;
|
public javax.management.modelmbean.ModelMBeanInfo | createMBeanInfo(com.sun.enterprise.admin.meta.naming.MBeanNamingInfo namingInfo, java.lang.String domainName)
//force managedBean to reset MBeanInfo
managedBean.setDescription(managedBean.getDescription());
ModelMBeanInfo info = managedBean.createMBeanInfo();
Descriptor descr = info.getMBeanDescriptor();
if(domainName!=null)
descr.setField(DOMAIN_FIELD_NAME, domainName);
if(namingInfo!=null)
{
descr.setField(NMTYPE_FIELD_NAME, namingInfo.getType());
descr.setField(NMLOCATION_FIELD_NAME, namingInfo.getLocationParams());
}
info.setMBeanDescriptor(descr);
return info;
|
private java.lang.String | fillStr(java.lang.String name, int minSize)
if(name.length()>=minSize)
return name;
return name+filler.substring(0, minSize-name.length());
|
private com.sun.org.apache.commons.modeler.AttributeInfo | findAttributeInfo(java.lang.String attrName)
return (AttributeInfo)findFeatureInfo(attrName, (FeatureInfo[]) managedBean.getAttributes());
|
private com.sun.org.apache.commons.modeler.FeatureInfo | findFeatureInfo(java.lang.String attrName, com.sun.org.apache.commons.modeler.FeatureInfo[] features)
if(attrName==null)
return null;
for(int i=0; i<features.length; i++)
{
if(attrName.equals(features[i].getName()))
return features[i];
}
return null;
|
private java.lang.String | formatClassName(java.lang.String className, int minSize)
if(className==null || className.length()==0)
className = "void";
else
{
int iLast = className.lastIndexOf('.");
boolean bArray = className.startsWith("[");
if(iLast>=0)
className = className.substring(iLast+1);
if(bArray)
className = className.substring(0, className.length()-1)+"[]";
}
return fillStr(className, minSize);
|
public java.lang.String[] | getAttributeNames()
AttributeInfo[] infos = managedBean.getAttributes();
if(infos==null)
return (new String[0]);
String[] names = new String[infos.length];
for(int i=0; i<infos.length; i++)
names[i] = infos[i].getName();
return names;
|
public java.util.Set | getDynamicallyReconfigurableAttributes()
return (Set)this.fields.get(DYNAMICALLY_RECONFIGURABLE_LIST_FIELD_NAME);
|
public java.lang.String | getElementChangeEventName()
return (String)this.fields.get(ELEMENTCHANGEEVENT_FIELD_NAME);
|
public java.lang.String | getElementPrintName()
return (String)fields.get(PRINTNAME_FIELD_NAME);
|
public java.lang.String | getName()
if(managedBean!=null)
return managedBean.getName();
return null;
|
public com.sun.enterprise.admin.meta.naming.MBeanNamingDescriptor | getNamingDescriptor()
return namingDescriptor;
|
public com.sun.enterprise.admin.BaseAdminMBean | instantiateMBean(javax.management.ObjectName objectName, java.lang.Object managedResource, com.sun.enterprise.config.ConfigContext ctx)
String domainName = objectName.getDomain();
return instantiateMBean(new MBeanNamingInfo(namingDescriptor, objectName), managedResource, domainName, ctx);
|
public com.sun.enterprise.admin.BaseAdminMBean | instantiateMBean(java.lang.String type, java.lang.String[] location, java.lang.Object managedResource, java.lang.String domainName, com.sun.enterprise.config.ConfigContext ctx)
return instantiateMBean(new MBeanNamingInfo(namingDescriptor, type, location), managedResource, domainName, ctx);
|
private com.sun.enterprise.admin.BaseAdminMBean | instantiateMBean(com.sun.enterprise.admin.meta.naming.MBeanNamingInfo namingInfo, java.lang.Object managedResource, java.lang.String domainName, com.sun.enterprise.config.ConfigContext ctx)
if(managedBean==null)
return null;
ModelMBeanInfo mbi = createMBeanInfo(namingInfo, domainName);
//FIXME set fields xpath&object_name here
String clazz = managedBean.getClassName();
String group = managedBean.getGroup();
Constructor constructor = Class.forName(clazz).getConstructor();
BaseAdminMBean mbean = (BaseAdminMBean)constructor.newInstance();
mbean.setModelMBeanInfo(mbi);
//BaseConfigMBean mbean = new BaseConfigMBean(mbi);
String xpath = namingInfo.getXPath();
if("config".equals(group))
{
if(xpath!=null && xpath.length()>0)
{
Object configBean = (Object)ConfigBeansFactory.getConfigBeanByXPath(ctx, xpath);
if(configBean!=null)
mbean.setManagedResource(configBean, CONFIG_BEAN_REF);
else
throw new MBeanMetaException("instantiateMBean(): config mbean does not exist for xpath - " + xpath );
}
return mbean;
}
if( "runtime".equals(group))
{
//CONFIG BEAN
if(xpath!=null && xpath.length()>0)
{
Object configBean = (Object)ConfigBeansFactory.getConfigBeanByXPath(ctx, xpath);
if(configBean!=null)
mbean.setManagedResource(configBean, CONFIG_BEAN_REF);
}
//JSR77BEAN
//construct JSR77Beanname
String beanClassName = (String)fields.get(JSR77BEAN_FIELD_NAME);
if(beanClassName==null || beanClassName.length()==0)
beanClassName = "com.sun.enterprise.management.model."+namingInfo.getType()+"Mdl";
if(managedResource==null)
{
Class cl = Class.forName(beanClassName);
if(cl!=null)
{
String[] location = namingInfo.getLocationParams();
if(location!=null)
{
Constructor ctr = cl.getConstructor(new Class[]{location.getClass()});
if(ctr!=null)
managedResource = ctr.newInstance(new Object[]{location});
}
}
}
if(managedResource!=null)
mbean.setManagedResource(managedResource, JSR77_MODEL_BEAN_REF);
return mbean;
}
return null;
|
public boolean | isAttributeDynamicReconfigNeeded(java.lang.String attrName)
AttributeInfo ai = findAttributeInfo(attrName);
if(ai==null)
throw new MBeanMetaException("Attribute info is not founmd for attribute "+attrName);
//get attribute's descriptor fields
List fields = ai.getFields();
if(fields!=null)
for(int i=0; i<fields.size(); i++) //enum fields
{
if("dynamicReconfigNeeded".equals(((FieldInfo)fields.get(i)).getName()))
{
//get "emptyValueAllowed" field value and compare it with "true"
Object value = ((FieldInfo)fields.get(i)).getValue();
if(value!=null && (value instanceof String) &&
("false".equalsIgnoreCase((String)value)|| "no".equalsIgnoreCase((String)value)))
return false;
}
}
return true;
|
public boolean | isAttributeDynamicallyReconfigurable(java.lang.String attr)
return checkItemsInReconfigurableSet(attr, "*");
|
public boolean | isAttributeEmptyValueAllowed(java.lang.String attrName)
AttributeInfo ai = findAttributeInfo(attrName);
if(ai==null)
throw new MBeanMetaException("Attribute info is not founmd for attribute "+attrName);
//get attribute's descriptor fields
List fields = ai.getFields();
if(fields!=null)
for(int i=0; i<fields.size(); i++) //enum fields
{
if(EMPTYVALUEALLOWED_FIELD_NAME.equals(((FieldInfo)fields.get(i)).getName()))
{
//get "emptyValueAllowed" field value and compare it with "true"
Object value = ((FieldInfo)fields.get(i)).getValue();
if(value!=null && (value instanceof String) &&
("true".equalsIgnoreCase((String)value)|| "yes".equalsIgnoreCase((String)value)))
return true; //empty value is allowed
}
}
return false; //empty value is not allowed
|
public boolean | isElementCreationDynamicallyReconfigurable()
return checkItemsInReconfigurableSet("+", null);
|
public boolean | isElementDeletionDynamicallyReconfigurable()
return checkItemsInReconfigurableSet("-", null);
|
public boolean | isElementDynamicallyReconfigurable()
return checkItemsInReconfigurableSet("**", null);
|
public boolean | isObjectNamePatternMatch(java.util.Hashtable ht)
if(namingDescriptor!=null)
return namingDescriptor.isObjectNamePatternMatch(ht);
return false;
|
public boolean | isObjectNamePatternMatch(javax.management.ObjectName objectName)
if(namingDescriptor!=null)
return namingDescriptor.isObjectNamePatternMatch(objectName);
return false;
|
public boolean | isPropertyDynamicallyReconfigurable(java.lang.String attr)
return checkItemsInReconfigurableSet("property."+attr, "property.*");
|
public void | mergeAttribute(java.lang.String attrName, java.lang.String attrType, java.lang.String attrGetMethod, java.lang.String attrSetMethod, boolean attrReadable, boolean attrWriteable)
AttributeInfo ai = findAttributeInfo(attrName);
if(ai==null)
{
ai = new AttributeInfo();
ai.setName(attrName);
ai.setType(attrType);
managedBean.addAttribute(ai);
}
if(ai.isReadable() && !attrReadable)
ai.setReadable(false);
if(ai.isWriteable() && !attrWriteable)
ai.setWriteable(false);
if(attrGetMethod!=null)
ai.setGetMethod(attrGetMethod);
if(attrSetMethod!=null)
ai.setSetMethod(attrSetMethod);
|
public java.lang.String | toFormatString()
String str = "\n\n*************** mbean type:"+managedBean.getName()+" ***************";
String wrk;
str += "\n--- ObjectName ="+ fields.get(OBJECTNAME_FIELD_NAME);
str += "\n--- XPath ="+ fields.get(XPATH_FIELD_NAME);
AttributeInfo[] attrs = managedBean.getAttributes();
str = str + "\n--- Attributes:";
if(attrs!=null)
for(int i=0; i<attrs.length; i++)
{
if("modelerType".equals(attrs[i].getName()))
continue;
str = str + "\n " + formatClassName(attrs[i].getType(), 12)+" "+attrs[i].getName()+",";
if(attrs[i].getDescription()!=null)
str = str + str + " // "+ attrs[i].getDescription();
}
OperationInfo[] opers = managedBean.getOperations();
if(opers!=null && opers.length>0)
{
str = str + "\n--- Operations:";
for(int i=0; i<opers.length; i++)
{
wrk = formatClassName(opers[i].getReturnType(), 14) + " " + opers[i].getName() + "(";
str = str + "\n"+wrk;
//convert wrk to indent
wrk = fillStr("\n", wrk.length()+1);
ParameterInfo[] params = opers[i].getSignature();
if(params!=null && params.length>0)
{
for(int j=0; j<params.length; j++)
{
if(j!=0)
str += wrk;
str = str + formatClassName(params[j].getType(), 0) + " " + params[j].getName();
}
// str = str + "[, Target target]";
}
// else
// str = str + "[Target target]";
str = str + ");";
if(opers[i].getDescription()!=null)
str = str + str + " // "+ opers[i].getDescription();
}
}
return str;
|
public java.lang.String | toString()
String str = "\n--- MBeanRegistryEntry:\n ";
if(managedBean!=null)
{
str = str + managedBean.toString() + "\n " +
MBeanMetaHelper.descriptorToString(managedBean.getFields());
}
AttributeInfo[] attrs = managedBean.getAttributes();
str = str + "\n\n --- Attributes:";
if(attrs!=null)
for(int i=0; i<attrs.length; i++)
{
if("modelerType".equals(attrs[i].getName()))
continue;
str = str + "\n " + attrs[i].toString();
if(attrs[i].getFields().size()>0)
str = str + "\n " + MBeanMetaHelper.descriptorToString(attrs[i].getFields());
}
OperationInfo[] opers = managedBean.getOperations();
if(opers!=null && opers.length>0)
{
str = str + "\n\n --- Operations:";
for(int i=0; i<opers.length; i++)
{
str = str + "\n " + opers[i].toString();
if(opers[i].getFields().size()>0)
str = str + "\n " + MBeanMetaHelper.descriptorToString(opers[i].getFields());
ParameterInfo[] params = opers[i].getSignature();
if(params!=null && params.length>0)
{
str = str + "\n --- Parameters:";
for(int j=0; j<params.length; j++)
{
str = str + "\n " + params[j].toString();
if(params[j].getFields().size()>0)
str = str + "\n " + MBeanMetaHelper.descriptorToString(params[j].getFields());
}
}
}
}
return str;
|