Methods Summary |
---|
public javax.management.ObjectName | buildContaineeObjectName(javax.management.ObjectName parentObjectName, java.lang.String parentFullType, java.lang.String childJ2EEType, java.lang.String childName)Build an ObjectName for an MBean logically contained within the parent MBean.
The child may be a true child (a subtype), or simply logically contained
within the parent.
final String domain = parentObjectName.getDomain();
String props = "";
final TypeInfo info = TypeInfos.getInstance().getInfo( childJ2EEType );
if ( info.isSubType() )
{
// extract j2eeType and name
final String parentProp = Util.getSelfProp( parentObjectName );
// extract the remaining ancestors
final String[] parentFullTypes = Util.getTypeArray( parentFullType );
final Set<String> ancestorKeys = GSetUtil.newSet( parentFullTypes, 0, parentFullTypes.length - 1 );
final String ancestorProps = JMXUtil.getProps( parentObjectName, ancestorKeys, true );
props = Util.concatenateProps( parentProp, ancestorProps );
}
else
{
// it's logically contained within the parent, nothing more to do
}
final String requiredProps = Util.makeRequiredProps( childJ2EEType, childName );
final String allProps = Util.concatenateProps( requiredProps, props );
return( Util.newObjectName( domain, allProps ) );
|
public javax.management.ObjectName | buildContaineeObjectName(javax.management.ObjectName parentObjectName, java.lang.String parentFullType, java.lang.String childJ2EEType)
final String name = getSingletonName( childJ2EEType );
return( buildContaineeObjectName( parentObjectName, parentFullType, childJ2EEType, name ) );
|
private void | debug(java.lang.Object o)
AMXDebug.getInstance().getOutput(
"com.sun.enterprise.management.support.ObjectNames" ).println( o );
|
public javax.management.ObjectName | getContainerObjectName(javax.management.MBeanServer server, javax.management.ObjectName containedObjectName)Get the ObjectName of the MBean logically containing the specified MBean.
debug( "getContainerObjectName: containedObjectName = " + containedObjectName );
final String containedFullType = getFullType( server, containedObjectName );
debug( "getContainerObjectName: containedFullType = " + containedFullType );
ObjectName parentPattern = getContainerObjectNamePattern( containedObjectName, containedFullType );
ObjectName containingObjectName = null;
if ( parentPattern != null )
{
debug( "getContainerObjectName: parentPattern = " + parentPattern );
final Set<ObjectName> names = JMXUtil.queryNames( server, parentPattern, null );
if ( names.size() == 0 )
{
throw new InstanceNotFoundException( parentPattern.toString() );
}
containingObjectName = (ObjectName)GSetUtil.getSingleton( names );
}
else
{
final String j2eeType = Util.getJ2EEType( containedObjectName );
if ( ! j2eeType.equals( XTypes.DOMAIN_ROOT ) )
{
throw new IllegalArgumentException( containedObjectName.toString() );
}
}
return( containingObjectName );
|
public javax.management.ObjectName | getContainerObjectNamePattern(javax.management.ObjectName childObjectName, java.lang.String childFullType)Get a parent ObjectName pattern using a child's ObjectName. The "parent" in
this context means the MBean that logically contains the child. The caller
must query for the actual ObjectName.
ObjectName parentPattern = null;
final String domain = childObjectName.getDomain();
final String[] fullType = Util.getTypeArray( childFullType );
assert( fullType.length >= 1 );
final String childType = fullType[ fullType.length - 1 ];
if ( fullType.length == 1 )
{
final TypeInfo info = TypeInfos.getInstance().getInfo( childType );
final String containedByJ2EEType = info.getContainedByJ2EEType();
if ( containedByJ2EEType != null )
{
String parentProps = "";
// special case--DomainRoot and J2EEDomain must have a name
// equal to the domain name
if ( containedByJ2EEType.equals( XTypes.DOMAIN_ROOT ) ||
containedByJ2EEType.equals( J2EETypes.J2EE_DOMAIN ) )
{
parentProps = Util.makeRequiredProps( containedByJ2EEType, domain );
}
else
{
parentProps = Util.makeRequiredProps( containedByJ2EEType,
getSingletonName( containedByJ2EEType ) );
}
parentPattern = Util.newObjectNamePattern( domain, parentProps );
}
else
{
parentPattern = null; // no parent
}
}
else
{
/*
It's a subType. A subtype may have one or more "missing" ancestors. For example,
the FullType of EJBModule is J2EEServer.J2EEApplication.EJBModule. Since an EJBModule
may be standalone, the J2EEApplication may not actually exist. We need to account for
this, and we do so by using the convention that a name of "null" indicates such a missing
ancestor.
The parent is handled differently than the other properties because we have to extract
j2eeType=<type>,name=<name> whereas the other properties are of the form
<type>=<name>. So first, we must find the first real parent.
*/
String parentJ2EEType = null;
String parentName = null;
Set<String> remainingKeys = Collections.emptySet();
for( int i = fullType.length - 2; i >= 0; --i )
{
final String tempType = fullType[ i ];
final String tempName = childObjectName.getKeyProperty( tempType );
assert( tempName != null ) : "missing ObjectName property: " + tempType;
if ( ! MISSING_PARENT_NAME.equals( tempName ) )
{
parentJ2EEType = tempType;
parentName = tempName;
final int numItems = i;
remainingKeys = GSetUtil.newSet( fullType, 0, numItems );
break;
}
}
/*
trace( "\n---------------------- getContainerObjectNamePattern ---------------------------" );
trace( childFullType + " = " + childObjectName );
trace( "parentJ2EEType = " + parentJ2EEType );
trace( "parentName = " + parentName );
trace( "remainingKeys = " + toString( remainingKeys ) );
trace( "-------------------------------------------------" );
*/
final String parentProps = Util.makeRequiredProps( parentJ2EEType, parentName );
final String ancestorProps = JMXUtil.getProps( childObjectName, remainingKeys );
final String props = Util.concatenateProps( parentProps, ancestorProps );
parentPattern = Util.newObjectNamePattern( domain, props );
}
return( parentPattern );
|
public javax.management.ObjectName | getDomainRootObjectName()
return( newObjectName( Util.makeRequiredProps( XTypes.DOMAIN_ROOT, getJMXDomain() ) ) );
|
private static java.lang.String | getFullType(javax.management.MBeanServer server, javax.management.ObjectName objectName)
try
{
final String fullType = (String)
server.getAttribute( objectName, AMXAttributes.ATTR_FULL_TYPE );
return( fullType );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
|
public static com.sun.enterprise.management.support.ObjectNames | getInstance(java.lang.String jmxDomain)
return( new ObjectNames( jmxDomain ) );
|
public static java.lang.String | getJ2EEType(java.lang.Class theInterface)
return( (String)ClassUtil.getFieldValue( theInterface, "J2EE_TYPE" ) );
|
public java.lang.String | getJMXDomain()
return( mJMXDomain );
|
public static java.lang.String | getSingletonName(java.lang.String j2eeType)In the ObjectName, what should the "name" property contain if the object
is a singleton or otherwise not named? The name property is always required.
Possible choices include:
- "none" (or similar idea)
- the same as its j2eeType"
- empty
- random
if ( TypeInfos.getInstance().getInfo( j2eeType ) == null )
{
throw new IllegalArgumentException( j2eeType );
}
assert( ! AMX.NO_NAME.equals( MISSING_PARENT_NAME ) );
return( AMX.NO_NAME );
|
public javax.management.ObjectName | getSingletonObjectName(java.lang.String j2eeType)Get the ObjectName for a singleton object.
final TypeInfo info = TypeInfos.getInstance().getInfo( j2eeType );
if ( info.isSubType() )
{
throw new IllegalArgumentException( "singletons may not be sub-types: " + j2eeType );
}
final String props = Util.makeRequiredProps( j2eeType, getSingletonName( j2eeType ) );
return( newObjectName( props ) );
|
public static java.lang.String | makeWild(java.lang.String props)
return( Util.concatenateProps( props, JMXUtil.WILD_PROP ) );
|
private javax.management.ObjectName | newObjectName(java.lang.String props)Append the formatted props to the JMX domain and return the ObjectName
return( Util.newObjectName( getJMXDomain(), props ) );
|
private static java.lang.String | toString(java.lang.Object o)
return( SmartStringifier.toString( o ) );
|