Methods Summary |
---|
protected static java.lang.String | convertWildcardStringToJavaFormat(java.lang.String wildcardString)
/*
We support only '*" and '?'-- the '.' is a literal character
*/
final int length = wildcardString.length();
final StringBuffer buf = new StringBuffer();
for( int i = 0; i < length; ++i )
{
final char theChar = wildcardString.charAt( i );
if ( theChar == '." )
{
buf.append( "[.]" );
}
else if ( theChar == '*" )
{
buf.append( ".*" );
}
else if ( theChar == BACKSLASH )
{
buf.append( "" + BACKSLASH + BACKSLASH );
}
else
{
buf.append( theChar );
}
}
return( buf.toString() );
|
abstract DottedNameQuery | createQuery()
|
public void | doGet(java.util.Set dottedNames, javax.management.AttributeList attrsOut)
final Iterator iter = dottedNames.iterator();
while ( iter.hasNext() )
{
try
{
doGet( (String)iter.next(), attrsOut );
}
catch( Exception e )
{
// propogate up up if it's a single item
if ( dottedNames.size() == 1 )
{
throw e;
}
else
{
// do not log the exception if the attribute wasn't found;
// this is very common with wildcards
if ( ! (e instanceof AttributeNotFoundException) )
{
logException( e );
}
}
}
}
|
protected void | doGet(java.lang.String dottedNameString, javax.management.AttributeList attrsOut)
// NOTE: this name includes the value-name
final DottedName dn = getDottedName( dottedNameString );
final DottedNameForValue dnv = new DottedNameForValue( dn );
final ObjectName target = getTarget( dnv, getResolver( ) );
final String valueName = dnv.getValueName();
final Attribute attr = mValueAccessor.getValue( target, valueName);
if ( attr != null )
{
// emit the name in its full form
attrsOut.add( formAttribute( dnv.getPrefix(), valueName, attr.getValue() ) );
}
|
protected java.util.Set | doList(java.lang.String[] namePrefixes)
final Set all = new HashSet();
for( int i = 0; i < namePrefixes.length; ++i )
{
final String dottedNamePrefix = namePrefixes[ i ];
Set resolved = null;
if ( DottedName.isWildcardName( dottedNamePrefix ) )
{
resolved = resolveWildcardPrefix( dottedNamePrefix );
}
else
{
// no wildcard means to list all immediate children of the prefix
resolved = getAllImmediateChildren( dottedNamePrefix );
}
all.addAll( resolved );
}
return( all );
|
java.lang.Object[] | dottedNameGet(java.lang.String[] names)
final Object [] results = new Object[ names.length ];
for( int i = 0; i < names.length; ++i )
{
results[ i ] = dottedNameGet( names[ i ] );
}
return( results );
|
java.lang.Object | dottedNameGet(java.lang.String name)
Object result = null;
try
{
final Set all = resolveInputNames( new String [] { name } );
final AttributeList attrs = new AttributeList();
doGet( all, attrs );
if ( ! DottedName.isWildcardName( name ) )
{
// return an Attribute if the input was a single dotted-name
assert( attrs.size() == 1 );
result = (Attribute)attrs.get( 0 );
}
else
{
result = sortAttributeList( attrs );
}
}
catch( Exception e )
{
logException( e );
// the result will be the exception itself
result = e;
}
assert( result != null );
return( result );
|
public java.lang.String[] | dottedNameList(java.lang.String[] namePrefixes)
Set all = Collections.EMPTY_SET;
try
{
// if nothing specified, get top-level names
all = (namePrefixes.length == 0) ?
getAllTopLevelNames() : doList( namePrefixes );
}
catch( Exception e )
{
logException( e );
}
final String [] allArray = new String [ all.size() ];
all.toArray( allArray );
Arrays.sort( allArray );
return( allArray );
|
javax.management.Attribute | formAttribute(DottedName prefix, java.lang.String valueName, java.lang.Object value)
return( new Attribute( prefix + "." + valueName, value ) );
|
protected static java.util.Set | generateDottedNamesForValues(java.util.Set valueNames, java.lang.String prefix, java.lang.String suffix)
final Iterator iter = valueNames.iterator();
final Set allDottedNameStrings = new HashSet();
final Pattern pattern = Pattern.compile( convertWildcardStringToJavaFormat( suffix ) );
while ( iter.hasNext() )
{
final String valueName = (String)iter.next();
if ( pattern.matcher( valueName ).matches() )
{
allDottedNameStrings.add( prefix + "." + valueName );
}
}
return( allDottedNameStrings );
|
protected java.util.Set | getAllDescendants(java.lang.String namePrefix)
final Set searchSet = getSearchSet( namePrefix );
// a child must be prefix.xxx
final String searchPrefix = namePrefix + ".";
final Set resultSet = new HashSet();
final Iterator iter = searchSet.iterator();
while ( iter.hasNext() )
{
final String candidateString = (String)iter.next();
if ( candidateString.startsWith( searchPrefix ) )
{
resultSet.add( candidateString );
}
}
return( resultSet );
|
protected java.util.Set | getAllImmediateChildren(java.lang.String namePrefix)
final Set allChildren = getAllDescendants( namePrefix );
final int numParentParts = getDottedName( namePrefix ).getParts().size();
final Iterator iter = allChildren.iterator();
final Set resultSet = new HashSet();
while ( iter.hasNext() )
{
final String descendant = (String)iter.next();
if ( getDottedName( descendant ).getParts().size() == numParentParts + 1 )
{
resultSet.add( descendant );
}
}
return( resultSet );
|
protected static java.util.Set | getAllPropertyNames(PropertyValueAccessorBase accessor, javax.management.ObjectName objectName)
final Set allNames = new HashSet();
// add the property names
final String [] propNames = accessor.getAllPropertyNames( objectName, true );
for( int i = 0; i < propNames.length; ++i )
{
// prepend the "properties." prefix
allNames.add( propNames[ i ] );
}
return( allNames );
|
protected java.util.Set | getAllTopLevelNames()
final Set all = new HashSet();
final Set searchSet = createQuery().allDottedNameStrings();
// a child must be prefix.xxx
final Iterator iter = searchSet.iterator();
while ( iter.hasNext() )
{
final String candidateString = (String)iter.next();
final DottedName dn = getDottedName( candidateString );
if ( dn.getParts().size() == 0 )
{
all.add( candidateString );
}
}
return( all );
|
protected static java.util.Set | getAllValueNames(javax.management.MBeanServerConnection conn, javax.management.ObjectName objectName)
final Set allNames = new HashSet();
allNames.addAll(getAllPropertyNames( new PropertyValueAccessor(conn), objectName ));
allNames.addAll(getAllPropertyNames( new SystemPropertyValueAccessor(conn), objectName ));
allNames.addAll( AttributeValueAccessor.getAllAttributeNames( conn, objectName ) );
return( allNames );
|
protected DottedName | getDottedName(java.lang.String s)
return( DottedNameFactory.getInstance().get( s ) );
|
protected javax.management.MBeanServerConnection | getMBS()
return( mConn );
|
protected DottedNameRegistry | getRegistry()
return( mRegistry );
|
abstract DottedNameResolver | getResolver()
|
protected java.util.Set | getSearchSet(java.lang.String dottedNameExpr)
final DottedName dn = getDottedName( dottedNameExpr );
final String scope = dn.getScope();
Set s = null;
// consider it to be a domain if it starts with "domain"
final boolean isDomain = scope.startsWith( DottedNameAliasSupport.DOMAIN_SCOPE );
// consider it to be a config if it starts with a config name
boolean isConfig = startsWithConfigName( dottedNameExpr );
if ( isDomain || isConfig )
{
s = getRegistry().allDottedNameStrings();
}
else
{
// this will create a search set consisting of everything "server."
s = createQuery().allDottedNameStrings();
}
return( s );
|
protected DottedNameServerInfo | getServerInfo()
return( mServerInfo );
|
protected static javax.management.ObjectName | getTarget(DottedNameForValue dottedName, DottedNameResolver resolver)
final DottedName prefixDN = dottedName.getPrefix();
final ObjectName theObject = resolver.resolveDottedName( prefixDN.toString() );
if ( theObject == null )
{
final String msg = DottedNameStrings.getString(
DottedNameStrings.OBJECT_INSTANCE_NOT_FOUND_KEY, dottedName.toString() );
throw new InstanceNotFoundException( msg );
}
return( theObject );
|
protected static void | logException(java.lang.Exception e)
DottedNameLogger.logException( e );
|
java.lang.String | normalizeWildcardName(java.lang.String name)
String normalizedName = name;
if ( name.equals( "*" ) )
{
normalizedName = "*.*";
}
return( normalizedName );
|
protected java.util.Set | prefixToValueDottedNamesWild(DottedNameResolver resolver, java.lang.String prefix, java.lang.String suffix)
final Set all = new HashSet();
try
{
final ObjectName objectName = resolver.resolveDottedName( prefix );
if ( objectName != null )
{
Set allValueNames = null;
PropertyValueAccessorBase prop_accessor = null;
// wildcarded properties must not wildcard the "property" part
// eg "property.<regex>"
if ( suffix.equals( "*" ) )
{
// all attributes *and* all properties
allValueNames = getAllPropertyNames( new PropertyValueAccessor(getMBS()), objectName );
allValueNames.addAll(getAllPropertyNames( new SystemPropertyValueAccessor(getMBS()), objectName ));
allValueNames.addAll( getAllValueNames( getMBS(), objectName ) );
}
else if ((prop_accessor=(new PrefixedValueSupport(getMBS()).getPrefixedValueAccessor(suffix)))!=null)
{
allValueNames = getAllPropertyNames( prop_accessor, objectName );
}
else
{
// any other expression should match just attributes
allValueNames = getAllValueNames( getMBS(), objectName );
}
final Set valuesDottedNames = generateDottedNamesForValues( allValueNames, prefix, suffix );
all.addAll( valuesDottedNames );
}
}
catch( Exception e )
{
logException( e );
}
return( all );
|
java.util.Set | prefixesToValueDottedNames(DottedNameResolver resolver, java.util.Set prefixes, java.lang.String suffix)
final Set all = new HashSet();
final Iterator iter = prefixes.iterator();
while ( iter.hasNext() )
{
final String prefix = (String)iter.next();
if ( DottedName.isWildcardName( suffix ) )
{
all.addAll( prefixToValueDottedNamesWild( resolver, prefix, suffix ) );
}
else
{
// a fixed non-wildcard value-name--just append it
final String dottedName = prefix + "." + suffix;
all.add( dottedName );
}
}
return( all );
|
protected java.util.Set | resolveInputNames(java.lang.String[] names)
final Set all = new HashSet();
for( int i = 0; i < names.length; ++i )
{
String name = names[ i ];
if ( DottedName.isWildcardName( name ) )
{
name = normalizeWildcardName( name );
final DottedName dn = getDottedName( name );
final DottedNameForValue dnv = new DottedNameForValue( dn );
final String prefix = dnv.getPrefix().toString();
final String valueName = dnv.getValueName();
final Set resolvedPrefixes = resolveWildcardPrefix( prefix );
final Set newDottedNames = prefixesToValueDottedNames( getResolver( ),
resolvedPrefixes, valueName );
all.addAll( newDottedNames );
}
else
{
all.add( name );
}
}
return( all );
|
protected java.util.Set | resolveWildcardPrefix(java.lang.String dottedNamePrefix)
Set resolvedSet = Collections.EMPTY_SET;
if ( DottedName.isWildcardName( dottedNamePrefix ) )
{
if ( dottedNamePrefix.equals( "*" ) ) // optimization
{
resolvedSet = createQuery().allDottedNameStrings();
}
else
{
final Set searchSet = getSearchSet( dottedNamePrefix );
final String regex = convertWildcardStringToJavaFormat( dottedNamePrefix );
final DottedNameWildcardMatcher matcher =
new DottedNameWildcardMatcherImpl( searchSet );
resolvedSet = matcher.matchDottedNames( regex );
}
}
else
{
resolvedSet = Collections.singleton( dottedNamePrefix );
}
return( resolvedSet );
|
java.lang.String | setToString(java.util.Set s)
final Iterator iter = s.iterator();
final StringBuffer buf = new StringBuffer();
while ( iter.hasNext() )
{
buf.append( (String)iter.next() + "\n" );
}
return( buf.toString() );
|
protected javax.management.Attribute[] | sortAttributeList(javax.management.AttributeList attrsIn)
final Attribute [] attrs = new Attribute[ attrsIn.size() ];
attrsIn.toArray( attrs );
Arrays.sort( attrs, new AttributeComparator() );
return( attrs );
|
protected boolean | startsWithConfigName(java.lang.String dottedNameExpr)
boolean startsWithConfig = false;
try
{
final Iterator iter = mServerInfo.getConfigNames().iterator();
while ( iter.hasNext() )
{
final String configName = (String)iter.next();
if ( dottedNameExpr.startsWith( configName ) )
{
startsWithConfig = true;
break;
}
}
}
catch( DottedNameServerInfo.UnavailableException e )
{
logException( e );
}
return( startsWithConfig );
|
private boolean | startsWithDomain(java.lang.String dottedNameExpr)
return( dottedNameExpr.startsWith( DottedNameAliasSupport.DOMAIN_SCOPE ) );
|