Methods Summary |
---|
public boolean | add(javax.management.ObjectName objectName, java.lang.Object mbeanImpl)Adds an Object in the repository. Neither Object nor the ObjectName
should be null. Given Object will not be added if an Object with the
same ObjectName already exists in the repository.
Hashtable domain = findRepository(objectName);
String domainName = objectName.getDomain();
boolean added = false;
boolean newDomainRequired = ( domain == null );
if (newDomainRequired)
{
domain = addNewDomain(domainName);
domain.put(objectName, mbeanImpl);
added = true;
}
else
{
boolean noMatchFound = ( domain.get(objectName) == null );
if (noMatchFound)
{
domain.put(objectName, mbeanImpl);
added = true;
}
}
return ( added );
|
private java.util.Hashtable | addNewDomain(java.lang.String domainName)
Hashtable newRepository = new Hashtable();
mDomainTable.put(domainName, newRepository);
return ( newRepository );
|
public boolean | contains(javax.management.ObjectName objectName)Tests whether an Object with given ObjectName is present in this
Repository.
return ( find(objectName) != null );
|
public java.lang.Object | find(javax.management.ObjectName objectName)Returns the Object with given ObjectName. Returns null if there
is no Object with given ObjectName. Passed ObjectName may not be null.
Object match = null;
if (objectName != null &&
! objectName.isPattern() &&
! objectName.isPropertyPattern())
{
Hashtable domain = findRepository(objectName);
if (domain != null)
{
match = domain.get(objectName);
}
}
return ( match );
|
private java.lang.Object | findInPersistentStore(javax.management.ObjectName objectName, java.lang.Object cachedObject)This is where the check into persistent
storage registry comes into picture. So first
check whether a Bean corresponding exactly to this
objectName exists in the Config API. For now, this check
is controlled by a boolean flag mDoLazyInit, which is
set to true.
All the MBeans that have corresponding config beans
will be checked here. Only ServerController and GenericConfigurator
won't be.
This method operates on the given ObjectName and finds whether
corresponding Bean exists in storage. It modifies the internal
cached registry based on its findings. Thus note that this method
indeed modifies the state of MBeanServer though it is only a finder.
//for Generic Configurator and ServerController, just return the passed
// as these will NEVER be there in persistent store.
String type = ObjectNameHelper.getType (objectName);
if (type.equals(ObjectNames.kController) ||
type.equals(ObjectNames.kGenericConfigurator))
{
return cachedObject;
}
PersistenceChecker checker = new PersistenceChecker();
Object storedObject = null;
try {
storedObject = checker.findElement(objectName);
} catch (Exception e)
{
}
Object match = null;
if (storedObject != null)
{
if (cachedObject != null)
{
//sLogger.info("*In findInPersistentStore: stored-cached nonnull");
/*
MBean is registered, cachedObject is in sync with storedObject,
no need to do anything. Most of the times, this is the case.
Hence simply return the cached object.
*/
match = cachedObject;
}
else
{
/*
We will have to construct the proper Object
and register it as MBean. Will be invoked: for the
first time any MBean is invoked.
*/
MBeanManufacturer producer = new MBeanManufacturer(objectName, storedObject);
match = producer.createMBeanInstance();
this.add(objectName, match);
//sLogger.info("*In findInPersistentStore: " +
//"stored non null-cached null - constructing a new MBean " +
//match.getClass().getName() );
}
}
else //Not found in the persistent store
{
match = null; // if not found in persistent store, just return null.
if (cachedObject != null)
{
/* This means that the cached copy is stale and out of sync, remove it */
this.remove(objectName);
//sLogger.info("*In findInPersistentStore: stored is null, "
// + "cached is non-null, removed it");
}
else
{
//sLogger.info("*In findInPersistentStore: stored is null, "
// + "cached is null, no prob");
/* do nothing, as persistent store does not
have it and the cached store also does not have it */
}
}
//Now return the stored object, be it null or non-null.
return ( match );
|
public java.lang.Object | findPersistent(javax.management.ObjectName objectName)Makes the check for the existence of corresponding element in the
persistent store. This method will also register or unregister
the MBeans as required by adding/removing them, depending on its existence
in the persistent store.
Object match = null, cachedMatch = null;
if (objectName != null &&
! objectName.isPattern() &&
! objectName.isPropertyPattern())
{
Hashtable domain = findRepository(objectName);
if (domain != null)
{
cachedMatch = domain.get(objectName);
}
}
//sLogger.info("*In find: INFO: Now testing new lazyinit stuff....b4");
boolean isMonitorMBean = ObjectNameHelper.isMonitorMBean(objectName);
if (!isMonitorMBean) //don't check for monitorMBeans
{
match = findInPersistentStore(objectName, cachedMatch);
} else {
match = cachedMatch;
}
//sLogger.info("*In find:INFO: match from store = " + match);
return ( match );
|
private java.util.Hashtable | findRepository(javax.management.ObjectName objectName)Finds the repository for the given objectName. Given objectName
may not be null. This is helper method.
String domainName = objectName.getDomain();
return ( (Hashtable) mDomainTable.get(domainName) );
|
public java.util.Set | getAllMBeans()Method to get ALL MBeans in all domains in this repository.
The returned Set contains the ObjectNames of all MBeans.
Set mbeans = new HashSet();
Iterator domainNames = mDomainTable.keySet().iterator();
while (domainNames.hasNext())
{
String domainName = (String) domainNames.next();
Hashtable aTable = (Hashtable)mDomainTable.get(domainName);
mbeans.addAll(aTable.keySet());
}
return ( mbeans );
|
public int | getCount(java.lang.String domainName)Returns the number of Objects stored in this repository for
given domain, the domain's name may not be null.
return ( ((Hashtable) mDomainTable.get(domainName)).size());
|
public int | getTotalCount()Returns the total number of MBeans stored in entire repository.
int count = 0;
Iterator domainNames = mDomainTable.keySet().iterator();
while (domainNames.hasNext())
{
String domainName = (String) domainNames.next();
Hashtable aTable = (Hashtable)mDomainTable.get(domainName);
count = count + aTable.size();
}
return ( count );
|
private boolean | matchDomain(java.lang.String domainNamePattern, java.lang.String testDomainName)
IPatternMatcher matcher = new CombinedPatternMatcher(domainNamePattern,
testDomainName);
return ( matcher.matches() );
|
private boolean | matchPropertiesWithPattern(java.util.Hashtable pattern, java.util.Hashtable sample)
boolean currentMatch = true;
Iterator keyIter = pattern.keySet().iterator();
while (currentMatch && keyIter.hasNext())
{
String key = (String) keyIter.next();
String patternVal = (String) pattern.get(key);
String sampleVal = (String) sample.get(key);
currentMatch = patternVal.equals(sampleVal);
}
return ( currentMatch );
|
public java.util.Set | query(javax.management.ObjectName objectName)Returns a Set of Objects whose ObjectNames match zero or more Objects in the
repository as per the pattern suggested by the argument. If the argument
is NOT a pattern an exact match will be performed.
Set mbeans = null;
Set allMBeans = null;
String domainNamePattern = null;
Hashtable propertyTable = null;
if (objectName != null)
{
mbeans = new HashSet();
if(!objectName.isPattern())
{
if(this.contains(objectName))
{
mbeans.add(objectName);
}
}
else
{
allMBeans = this.getAllMBeans();
domainNamePattern = objectName.getDomain();
propertyTable = objectName.getKeyPropertyList();
Iterator allMBeanIter = allMBeans.iterator();
while (allMBeanIter.hasNext())
{
ObjectName sample = (ObjectName) allMBeanIter.next();
String sampleDomainName = sample.getDomain();
boolean domainNameMatches = matchDomain(
domainNamePattern, sampleDomainName);
if (!domainNameMatches)
{
continue;
}
Hashtable samplePropertyTable = sample.getKeyPropertyList();
boolean sampleMatches = this.matchPropertiesWithPattern(propertyTable, samplePropertyTable);
if (sampleMatches)
{
mbeans.add(sample);
}
}
}
}
return ( mbeans );
|
public boolean | remove(javax.management.ObjectName objectName)Removes the Object with given ObjectName from repository. The passed
ObjectName must not be null.
Hashtable domain = findRepository(objectName);
boolean removed = false;
if (domain != null)
{
Object mappedObject = domain.remove(objectName);
if (mappedObject != null)
{
removed = true;
}
}
return removed;
|