Methods Summary |
---|
public javax.management.AttributeList | addSubvaluesToArrayAttribute(java.lang.String dottedName, java.lang.String[] addValues)
String[] splitted = DottedNameHelper.splitAttributeNameFromDottedName(dottedName);
ManagedConfigBean mb = getManagedConfigBean(splitted[0]);
MBeanAttributeInfo attrInfo = mb.getAttributeInfo(splitted[1]);
if(attrInfo==null ||
!attrInfo.getType().startsWith("[")) //array?
{
throw new MBeanConfigException("add subelement: attribute type is not array");
}
AttributeList list = getAttributes(dottedName);
ArrayList values = new ArrayList();
if(list.size()!=0)
{
DottedNameHelper.addArrayToList(values, (Object[])((Attribute)list.get(0)).getValue());
}
DottedNameHelper.addArrayToList(values, addValues);
return setAttribute(dottedName, values.toArray(new String[]{}));
|
private MBeanRegistryEntry | findRegistryEntry(java.lang.String dottedName, int nameTarget)
MBeanRegistryEntry[] entries = _registry.findMBeanRegistryEntriesByDottedName(dottedName);
if(entries==null || entries.length==0)
return null;
if(entries.length==1)
return entries[0];
for(int i=0; i<entries.length; i++)
{
int entryTarget = getRegistryEntryTargetType(entries[i]);
if(nameTarget==entryTarget)
return entries[i];
if ((nameTarget==TARGET_TYPE_SERVER || nameTarget==TARGET_TYPE_CLUSTER) &&
( entryTarget==TARGET_TYPE_CONFIG ||
entryTarget==TARGET_TYPE_APPLICATION ||
entryTarget==TARGET_TYPE_RESOURCE ) )
return entries[i];
if ( nameTarget==TARGET_TYPE_DOMAIN &&
entryTarget!=TARGET_TYPE_CONFIG &&
entryTarget!=TARGET_TYPE_SERVER &&
entryTarget!=TARGET_TYPE_CLUSTER )
return entries[i];
}
return null;
|
public javax.management.AttributeList | getAttributes(java.lang.String dottedName)
String[] splitted = DottedNameHelper.splitAttributeNameFromDottedName(dottedName);
ManagedConfigBean mb = getManagedConfigBean(splitted[0]);
AttributeList attrs = mb.getAttributes(new String[]{splitted[1]});
return DottedNameHelper.addDottedPrefix(attrs, splitted[0]);
|
public java.util.ArrayList | getListDottedNames(java.lang.String mask)
synchronized(this) {
if(_allDottedNames==null) {
_allDottedNames = new ArrayList();
DottedNameHelper.collectConfigMBeansDottedNames(_registry, _ctx.getRootConfigBean(), _allDottedNames);
}
}
ArrayList list = DottedNameHelper.filterStringValues(_allDottedNames, mask);
return DottedNameHelper.sortDottedNames(_ctx, list);
|
private ManagedConfigBean | getManagedConfigBean(java.lang.String dottedName)
int cmdTargetType = DottedNameHelper.getDottedNameTargetType(
_ctx, dottedName);
MBeanRegistryEntry entry = findRegistryEntry(dottedName, cmdTargetType);
ManagedConfigBean mbc = null;
if(entry!=null)
{
int elementTargetType = getRegistryEntryTargetType(entry);
String resolvedName = DottedNameHelper.resolveDottedNameToTarget(
_ctx, dottedName, cmdTargetType, elementTargetType);
if(resolvedName!=null)
{
try {
MBeanNamingInfo namingInfo =
new MBeanNamingInfo(entry.getNamingDescriptor(), resolvedName);
String xpath = namingInfo.getXPath();
ConfigBean configBean =
(ConfigBean)ConfigBeansFactory.getConfigBeanByXPath(_ctx, xpath);
if(configBean!=null)
{
ModelMBeanInfo mbi = entry.createMBeanInfo(namingInfo, "offline");
mbc = new ManagedConfigBean((MBeanInfo)mbi, configBean, _registry);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
if(mbc==null)
throw new MBeanConfigException("config element is not found");
return mbc;
|
private int | getRegistryEntryTargetType(MBeanRegistryEntry entry)
MBeanNamingDescriptor descr = entry.getNamingDescriptor();
return DottedNameHelper.getTargetTypeForXPath(descr.getXPathPattern());
|
public javax.management.AttributeList | removeSubvaluesFromArrayAttribute(java.lang.String dottedName, java.lang.String[] removeValues)
String[] splitted = DottedNameHelper.splitAttributeNameFromDottedName(dottedName);
ManagedConfigBean mb = getManagedConfigBean(splitted[0]);
MBeanAttributeInfo attrInfo = mb.getAttributeInfo(splitted[1]);
if(attrInfo==null ||
!attrInfo.getType().startsWith("[")) //array?
{
throw new MBeanConfigException("add subelement: attribute type is not array");
}
AttributeList list = getAttributes(dottedName);
ArrayList values = new ArrayList();
if(list.size()!=0)
{
DottedNameHelper.addArrayToList(values, (Object[])((Attribute)list.get(0)).getValue());
for(int i=0; i<removeValues.length; i++)
{
for(int j=0; j<values.size(); j++)
{
if(removeValues[i].equals(values.get(j)))
{
values.remove(j);
break; // only first occasion will be removed
}
}
}
}
return setAttribute(dottedName, values.toArray(new String[]{}));
|
public void | resetDottedNames()
synchronized(this) {
_allDottedNames = null;
}
|
public javax.management.AttributeList | setAttribute(java.lang.String dottedName, java.lang.Object value)
String[] splitted = DottedNameHelper.splitAttributeNameFromDottedName(dottedName);
ManagedConfigBean mb = getManagedConfigBean(splitted[0]);
AttributeList attrsIn = new AttributeList();
attrsIn.add(new Attribute(splitted[1], value));
AttributeList attrsOut = mb.setAttributes(attrsIn);
_ctx.flush();
return DottedNameHelper.addDottedPrefix(attrsOut, splitted[0]);
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList attrsIn)
AttributeList attrsOut = new AttributeList();
for(int i=0; i< attrsIn.size(); i++)
{
Attribute attr = (Attribute)attrsIn.get(i);
try {
AttributeList attrs = setAttribute(attr.getName(), attr.getValue());
if(attrs.size()>0)
attrsOut.addAll(attrs);
} catch (Exception e) {}
}
return attrsOut;
|