Methods Summary |
---|
protected final java.util.Map | candidatesToMap(java.util.Set candidates, java.lang.String key)Create a Map of Set keyed by the ObjectName key value specified.
Each Set contains all the ObjectNames with that key.
final Map<String,Set<ObjectName>> setMap = new HashMap<String,Set<ObjectName>>();
for( final ObjectName candidate : candidates )
{
final String keyValue = candidate.getKeyProperty( key );
Set<ObjectName> typeSet = setMap.get( keyValue );
if ( typeSet == null )
{
typeSet = new HashSet<ObjectName>();
setMap.put( keyValue, typeSet );
}
typeSet.add( candidate );
}
return( setMap );
|
protected final void | debug(java.lang.Object o)
mDebug.println( o.toString() );
|
private final javax.management.ObjectName | ensureNew(javax.management.ObjectName newObjectName, javax.management.ObjectName oldObjectName)
// don't assume this ObjectName is the entire name; query for it
final ObjectName pattern = Util.newObjectNamePattern( newObjectName );
// don't assume this ObjectName is the entire name; query for it
final Set<ObjectName> objectNames = JMXUtil.queryNames( getMBeanServer(), pattern, null );
final ObjectName existingObjectName = findExisting( objectNames, oldObjectName );
ObjectName resultName = null;
if ( existingObjectName == null )
{
// not yet registered, create it
final Object impl = newImpl( newObjectName, oldObjectName );
resultName = registerNew( impl, newObjectName, oldObjectName );
}
else
{
resultName = existingObjectName;
}
assert( resultName != null );
return( resultName );
|
public final java.util.List | findAllOld()Create a list of all old MBeans and return a list in the order in which
they must be registered.
final Set<ObjectName> all = findAllOldCandidates();
final Set<ObjectName> results = new HashSet<ObjectName>();
for( final ObjectName objectName : all)
{
if ( shouldSync( objectName ) )
{
results.add( objectName );
}
}
return( ListUtil.newListFromCollection( results ) );
|
protected abstract java.util.Set | findAllOldCandidates()
|
private java.lang.reflect.Constructor | findConstructor(java.lang.reflect.Constructor[] constructors, java.lang.Class[] sig)
Constructor constructor = null;
for( int i = 0; i < constructors.length; ++i )
{
final Class<?>[] csig = constructors[ i ].getParameterTypes();
if ( csig.length == sig.length )
{
constructor = constructors[ i ];
for( int c = 0; c < sig.length; ++c )
{
if ( ! csig[ i ].isAssignableFrom( sig[ i ] ) )
{
constructor = null;
break;
}
}
if ( constructor != null )
{
break;
}
}
}
return( constructor );
|
protected javax.management.ObjectName | findExisting(java.util.Set newObjectNames, javax.management.ObjectName oldObjectName)
ObjectName resultName = null;
if ( newObjectNames.size() == 1 )
{
// already registered
resultName = GSetUtil.getSingleton( newObjectNames );
}
return( resultName );
|
public java.lang.String | getAMXJMXDomainName()
return( mLoader.getAMXJMXDomainName() );
|
private java.lang.reflect.Constructor | getDelegateConstructor(java.lang.reflect.Constructor[] constructors)
return( findConstructor( constructors, DELEGATE_SIG ) );
|
protected com.sun.appserv.management.DomainRoot | getDomainRoot()
return( mLoader.getDomainRoot() );
|
private java.lang.reflect.Constructor | getEmptyConstructor(java.lang.reflect.Constructor[] constructors)
return( findConstructor( constructors, EMPTY_SIG ) );
|
protected abstract java.util.Set | getIgnoreTypes()
|
protected java.lang.Class | getImplClass(javax.management.ObjectName newObjectName, javax.management.ObjectName oldObjectName)
final String newType = Util.getJ2EEType( newObjectName );
final TypeInfo info = TypeInfos.getInstance().getInfo( newType );
assert( info != null );
final Class implClass = info.getImplClass();
return( implClass );
|
protected java.util.logging.Logger | getLogger()
return( mLoader.getMBeanLogger() );
|
public javax.management.MBeanServer | getMBeanServer()
return( mLoader.getMBeanServer() );
|
protected abstract java.util.Set | getNeedsSupport()
|
protected boolean | isDefectiveIgnore(javax.management.ObjectName objectName)Is the com.sun.appserv MBean defective in some way such that it
cannot be properly represented in AMX?
return false;
|
protected abstract boolean | isOldMBean(javax.management.ObjectName objectName)
|
protected java.lang.Object | newImpl(javax.management.ObjectName newObjectName, javax.management.ObjectName oldObjectName)
Object impl = null;
final Class implClass = getImplClass( newObjectName, oldObjectName );
try
{
final Constructor[] constructors = implClass.getConstructors();
Constructor constructor = null;
if ( (constructor = getDelegateConstructor( constructors )) != null )
{
final DelegateToMBeanDelegate delegate =
new DelegateToMBeanDelegate( mLoader.getMBeanServer(), oldObjectName );
assert( delegate != null );
debug( "created Delegate with target of " + oldObjectName +
" for " + newObjectName );
impl = constructor.newInstance( new Object[] { delegate } );
}
else if ( getEmptyConstructor( constructors ) != null )
{
impl = implClass.newInstance();
}
else
{
assert( false );
throw new Error( "Delegate has no constructor" );
}
}
catch( Exception e )
{
final Throwable rootCause = ExceptionUtil.getRootCause( e );
debug( "Loader.newImpl: exception creating new impl: " + e + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw e;
}
return( impl );
|
protected abstract javax.management.ObjectName | oldToNewObjectName(javax.management.ObjectName o)
|
protected final javax.management.ObjectName | registerNew(java.lang.Object impl, javax.management.ObjectName implObjectName, javax.management.ObjectName oldObjectName)
if ( impl == null )
{
final String msg = "unable to create new impl for old: " + oldObjectName;
debug( msg );
throw new IllegalArgumentException( msg );
}
return( mLoader.registerNew( impl, implObjectName, oldObjectName ) );
|
public final boolean | shouldSync(javax.management.ObjectName o)
boolean shouldSync = isOldMBean( o );
if ( shouldSync )
{
final String type = o.getKeyProperty( "type" );
if ( getNeedsSupport().contains( type ) )
{
shouldSync = false;
getLogger().warning(
"com.sun.appserv MBean not yet supported: " +
StringUtil.quote(o) );
}
else if ( isDefectiveIgnore( o ) )
{
shouldSync = false;
debug(
"com.sun.appserv MBean was last determined to be defective " +
"and will not be represented in AMX: " +
StringUtil.quote(o) );
}
}
return( shouldSync );
|
protected javax.management.ObjectName | syncWithOld(javax.management.ObjectName oldObjectName)
final ObjectName newObjectName = oldToNewObjectName( oldObjectName );
debug( "\nsyncWithOld: " + JMXUtil.toString(oldObjectName) + "=> " + JMXUtil.toString(newObjectName) + "\n" );
final ObjectName resultName = ensureNew( newObjectName, oldObjectName );
return( resultName );
|
protected java.lang.String | toString(java.lang.Object o)
return( com.sun.appserv.management.util.stringifier.SmartStringifier.toString( o ) );
|
protected final void | trace(java.lang.Object o)
debug( o );
|