Methods Summary |
---|
protected synchronized void | cacheMBeanInfo(boolean cacheIt)
mCacheMBeanInfo = cacheIt;
mMBeanInfoIsInvariant = cacheIt;
if ( ! cacheIt )
{
mCachedMBeanInfo = null;
}
|
public final boolean | checkValid()
if ( mTargetValid )
{
try
{
mTargetValid = getConnection().isRegistered( getTargetObjectName() );
}
catch( Exception e )
{
debug( "checkValid: connection failed" );
mTargetValid = false;
}
}
return( mTargetValid );
|
public final void | connectionBad()
debugMethod( "connectionBad" );
mTargetValid = false;
assert( ! targetIsValid() );
|
com.sun.appserv.management.util.jmx.AttributeNameMapper | createMapper(javax.management.MBeanAttributeInfo[] attributeInfos, com.sun.appserv.management.util.jmx.AttributeNameMangler mangler)Create a mapper based on the supplied attributeInfos
return( new AttributeNameMapperImpl( getAllAttributeNames( attributeInfos ), mangler ) );
|
protected void | debug(java.lang.Object args)
if ( getDebug() )
{
mDebug.println( StringUtil.toString( "", args) );
}
|
protected void | debug(java.lang.Object o)
mDebug.println( o );
|
protected void | debugMethod(java.lang.String methodName, java.lang.Object args)
if ( getDebug() )
{
mDebug.println( AMXDebug.methodString( methodName, args ) );
}
|
protected void | debugMethod(java.lang.String msg, java.lang.String methodName, java.lang.Object args)
if ( getDebug() )
{
mDebug.println( AMXDebug.methodString( methodName, args ) + ": " + msg );
}
|
public boolean | equals(java.lang.Object rhs)
if ( rhs == this )
{
return true;
}
final MBeanProxyHandler other = (MBeanProxyHandler)rhs;
boolean equals = mTargetObjectName.equals( other.getTargetObjectName() );
if ( equals )
{
try
{
equals = getConnection() == other.getConnection();
}
catch( Exception e )
{
equals = false;
}
}
return equals;
|
protected java.lang.String | extractAttributeNameFromMethod(java.lang.String methodName)
assert( methodName.startsWith( GET ) ||
methodName.startsWith( SET ) ||
methodName.startsWith( IS ) );
final int startIndex = methodName.startsWith( GET ) || methodName.startsWith( SET ) ?
GET_PREFIX_LENGTH : IS_PREFIX_LENGTH;
return( methodName.substring( startIndex, methodName.length() ) );
|
public static java.lang.String[] | getAllAttributeNames(javax.management.MBeanAttributeInfo[] infos)
return( JMXUtil.getAttributeNames( infos ) );
|
public java.lang.Object | getAttribute(java.lang.String attributeName)Same as XAttributesAccess.getAttribute, but with exceptions
final Object result =
getConnection().getAttribute( getTargetObjectName(), attributeName );
postGetAttributeHook( attributeName, result );
return( result );
|
public javax.management.AttributeList | getAttributes(java.lang.String[] attrNames)Same as XAttributesAccess.getAttributes, but with exceptions
final AttributeList results =
getConnection().getAttributes( getTargetObjectName(), attrNames );
postGetAttributesHook( attrNames, results );
return( results );
|
protected final boolean | getCacheMBeanInfo()
return( mCacheMBeanInfo );
|
protected final javax.management.MBeanServerConnection | getConnection()
return( mConnectionSource.getMBeanServerConnection( false ) );
|
public final com.sun.appserv.management.client.ConnectionSource | getConnectionSource()
return( mConnectionSource );
|
protected boolean | getDebug()
return AMXDebug.getInstance().getDebug( getDebugID() );
|
protected java.lang.String | getDebugID()
return DEBUG_ID;
|
protected javax.management.MBeanInfo | getMBeanInfo(boolean refresh)Same as XAttributesAccess.getAttributes, but with exceptions
if ( refresh ||
(! mCacheMBeanInfo) ||
mCachedMBeanInfo == null )
{
synchronized( this )
{
mCachedMBeanInfo = getConnection().getMBeanInfo( getTargetObjectName() );
}
}
return( mCachedMBeanInfo );
|
public final boolean | getMBeanInfoIsInvariant()
return( mMBeanInfoIsInvariant );
|
public synchronized java.util.logging.Logger | getProxyLogger()
if ( mLogger == null )
{
mLogger = Logger.getLogger( this.getClass().getName() );
}
return( mLogger );
|
protected final javax.management.ObjectName | getTargetObjectName()
return( mTargetObjectName );
|
public int | hashCode()
return ObjectUtil.hashCode( mTargetObjectName,
mConnectionSource, mLogger, mMangler, mMapper, mCachedMBeanInfo, mDebug) ^
ObjectUtil.hashCode( mCacheMBeanInfo ) ^
ObjectUtil.hashCode( mMBeanInfoIsInvariant ) ^
ObjectUtil.hashCode( mTargetValid );
|
protected void | initMapper()Initialize a mapper based on the supplied attributeInfos. Does nothing if already
initialized.
// lazy initialization here
if ( mMapper == null && mMangler != null)
{
final MBeanInfo mbeanInfo = getMBeanInfo( true );
synchronized( this )
{
if ( mMapper == null )
{
mMapper = createMapper( mbeanInfo.getAttributes(), mMangler);
}
}
}
|
public java.lang.Object | invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)Invoke the specified method. This implementation supports additional functionality
over the JMX MBeanServerInvocationHandler:
(1) It supports mapped Attribute names (ones that are not legal Java names)
(2) it supports XAttributesAccess, which otherwise does not work correctly
For anything else, the behavior of MBeanServerInvocationHandler is used.
final String methodName = method.getName();
final int numArgs = args == null ? 0 : args.length;
debugMethod( method.getName(), args );
Object result = null;
final boolean isGetter = JMXUtil.isIsOrGetter( method );
final boolean isSetter = isGetter ? false : JMXUtil.isSetter( method );
boolean handled = false;
if ( methodName.equals( "getTargetObjectName" ) )
{
handled = true;
result = getTargetObjectName();
}
else if ( methodName.equals( "getMBeanInfo" ) && numArgs <= 1)
{
handled = true;
if ( numArgs == 1 )
{
result = getMBeanInfo( ((Boolean)args[ 0 ] ).booleanValue() );
}
else if ( numArgs == 0 )
{
result = getMBeanInfo( mCacheMBeanInfo );
}
else
{
handled = false;
}
}
else if ( methodName.equals( "getProxyLogger" ) && numArgs == 0 )
{
handled = true;
result = getProxyLogger();
}
else if ( methodName.equals( "setProxyLogger" ) &&
numArgs == 1 &&
method.getParameterTypes()[ 0 ] == Logger.class )
{
handled = true;
setProxyLogger( (Logger)args[ 0 ] );
}
else if ( (isGetter || isSetter) )
{
handled = true;
// it's a plain getFoo(), setFoo( f ) call
initMapper( );
final String javaName = extractAttributeNameFromMethod( methodName );
String attributeName = javaName;
if ( isMappedAttributeMethod( javaName ) )
{
attributeName = mMapper.derivedToOriginal( javaName );
}
//trace( "MBeanProxyHandler.invoke: mapped attribute: " + javaName + " => " + attributeName );
if ( isGetter )
{
result = getAttribute( attributeName );
}
else
{
final Attribute attr = new Attribute( attributeName, args[ 0 ] );
setAttribute( attr );
}
}
else if ( methodName.indexOf( "etAttribute" ) == 1 )
{
handled = true;
// likely one of getAttribute(), getAttributes(), setAttribute(), setAttributes()
//p( "MBeanProxyHandler.invoke: " + method.getName() + " " + numArgs + " args." );
if ( JMXUtil.isGetAttribute( method ) )
{
final String attrName = (String)args[ 0 ];
result = getAttribute( attrName );
}
else if ( JMXUtil.isGetAttributes( method ) )
{
final String[] attrNames = (String[])args[ 0 ];
result = (AttributeList)getAttributes( attrNames );
}
else if ( JMXUtil.isSetAttribute( method ) )
{
final Attribute attr = (Attribute)args[ 0 ];
setAttribute( attr );
}
else if ( JMXUtil.isSetAttributes( method ) )
{
final AttributeList requested = (AttributeList)args[ 0 ];
result = (AttributeList)setAttributes( requested );
}
else
{
handled = false;
}
}
else if ( methodName.equals( "hashCode" ) )
{
/*
java.lang.reflect.Proxy will route all calls through invoke(),
even hashCode(). To avoid newing up an Integer every time,
just return a stored version. hashCode() is called frequently
when proxies are inserted into Sets or Maps. toString() and
equals() don't seem to get called however.
*/
result = mHashCode;
handled = true;
}
else if ( methodName.equals( "toString" ) )
{
result = "proxy to " + JMXUtil.toString( getTargetObjectName() );
handled = true;
}
else if ( methodName.equals( "equals" ) && numArgs == 1)
{
result = this.equals( args[ 0 ] );
handled = true;
}
if ( ! handled )
{
debugMethod( getTargetObjectName().toString(), "super.invoke",
method.getName(), args );
result = super.invoke( proxy, method, args );
}
return( result );
|
protected boolean | isMappedAttributeMethod(java.lang.String attributeName)
boolean isMapped = false;
if ( mMapper != null )
{
final String originalName = mMapper.derivedToOriginal( attributeName );
isMapped = ! attributeName.equals( originalName );
}
return( isMapped );
|
protected void | postGetAttributeHook(java.lang.String name, java.lang.Object value)
|
protected void | postGetAttributesHook(java.lang.String[] requested, javax.management.AttributeList actual)
|
protected void | postSetAttributeHook(javax.management.Attribute attr)
|
protected void | postSetAttributesHook(javax.management.AttributeList requested, javax.management.AttributeList actual)
|
public void | setAttribute(javax.management.Attribute attr)Same as XAttributesAccess.setAttribute, but with exceptions
getConnection().setAttribute( getTargetObjectName(), attr );
postSetAttributeHook( attr );
|
public javax.management.AttributeList | setAttributes(javax.management.AttributeList requested)Same as XAttributesAccess.setAttributes, but with exceptions
final AttributeList results = getConnection().setAttributes( getTargetObjectName(), requested );
postSetAttributesHook( requested, results );
return( results );
|
protected final void | setMBeanInfoIsInvariant(boolean isInvariant)
mMBeanInfoIsInvariant = isInvariant;
|
public synchronized void | setProxyLogger(java.util.logging.Logger logger)
mLogger = logger;
|
protected final boolean | targetIsValid()
return( mTargetValid );
|
public final void | targetUnregistered()
debugMethod( mTargetObjectName.toString(), "targetUnregistered" );
mTargetValid = false;
assert( ! targetIsValid() );
|