Methods Summary |
---|
public boolean | checkConnection()Verify that the connection is still alive.
boolean connectionGood = true;
try
{
getConnection().isRegistered( JMXUtil.getMBeanServerDelegateObjectName() );
connectionGood = true;
}
catch( Exception e )
{
connectionBad();
}
return( connectionGood );
|
private void | connectionBad()The connection is bad. Tell each proxy its gone and remove it.
final Set<AMX> proxies = new HashSet<AMX>();
proxies.addAll( mProxyCache.values() );
mProxyCache.clear();
for( final AMX proxy : proxies )
{
ConverterHandlerUtil.connectionBad( proxy );
}
|
public com.sun.appserv.management.DomainRoot | createDomainRoot()
return( mDomainRoot );
|
private com.sun.appserv.management.base.AMX | createProxy(javax.management.ObjectName objectName)Create a new proxy. When a new proxy is created, its parent is
required, which could cause a chain of proxies to be created.
AMX proxy = null;
try
{
String proxyInterfaceName = null;
Class proxyInterface = null;
proxyInterfaceName = (String)
getConnection().getAttribute( objectName, AMXAttributes.ATTR_INTERFACE_NAME );
proxyInterface = ClassUtil.getClassFromName( proxyInterfaceName );
proxy = newProxyInstance( objectName, new Class[] { proxyInterface } );
}
catch( IllegalArgumentException e )
{
debug( "createProxy", e );
throw e;
}
catch( Exception e )
{
debug( "createProxy", e );
throw new RuntimeException( e );
}
return( proxy );
|
private com.sun.appserv.management.util.jmx.MBeanProxyHandler | createProxyHandler(javax.management.ObjectName objectName)
return ConverterHandlerFactory.createHandler( mConnectionSource, objectName );
|
private static void | debug(java.lang.Object args)
mDebug.println( args );
|
public static synchronized com.sun.appserv.management.client.ProxyFactory | findInstance(com.sun.appserv.management.client.ConnectionSource conn)
return( INSTANCES.get( conn ) );
|
public static synchronized com.sun.appserv.management.client.ProxyFactory | findInstance(javax.management.MBeanServerConnection conn)
ProxyFactory instance = null;
final Collection<ProxyFactory> values = INSTANCES.values();
for( final ProxyFactory factory : values )
{
if ( factory.getConnectionSource().getExistingMBeanServerConnection( ) == conn )
{
instance = factory;
break;
}
}
return( instance );
|
public static synchronized com.sun.appserv.management.client.ProxyFactory | findInstanceByID(java.lang.String mbeanServerID)
ProxyFactory instance = null;
final Collection<ProxyFactory> values = INSTANCES.values();
for( final ProxyFactory factory : values )
{
if ( factory.getMBeanServerID().equals( mbeanServerID ) )
{
instance = factory;
break;
}
}
return( instance );
|
protected javax.management.MBeanServerConnection | getConnection()
return( getConnectionSource().getMBeanServerConnection( false ) );
|
public com.sun.appserv.management.client.ConnectionSource | getConnectionSource()
return( mConnectionSource );
|
public com.sun.appserv.management.DomainRoot | getDomainRoot()Return the DomainRoot. AMX may not yet be fully
initialized; call getDomainRoot( true ) if AMX
must be initialized upon return.
return getDomainRoot( false );
|
public com.sun.appserv.management.DomainRoot | getDomainRoot(boolean waitReady)If 'waitReady' is true, then upon return AMX
is guaranteed to be fully loaded. Otherwise
AMX MBeans may continue to initialize asynchronously.
if ( waitReady )
{
mDomainRoot.waitAMXReady();
}
return( mDomainRoot );
|
public javax.management.ObjectName | getDomainRootObjectName()Return the ObjectName for the DomainMBean.
return( mDomainRootObjectName );
|
public static com.sun.appserv.management.client.ProxyFactory | getInstance(javax.management.MBeanServer server)Get an instance of the ProxyFactory for the MBeanServer. Generally
not applicable for remote clients.
return( getInstance( new MBeanServerConnectionSource( server ), true ) );
|
public static com.sun.appserv.management.client.ProxyFactory | getInstance(javax.management.MBeanServerConnection conn)Get an instance of the ProxyFactory for the MBeanServerConnection.
Creates a ConnectionSource for it and calls getInstance( connSource, true ).
return( getInstance( new MBeanServerConnectionConnectionSource( conn ), true ) );
|
public static com.sun.appserv.management.client.ProxyFactory | getInstance(com.sun.appserv.management.client.ConnectionSource conn)Calls getInstance( connSource, true ).
return( getInstance( conn, true ) );
|
public static synchronized com.sun.appserv.management.client.ProxyFactory | getInstance(com.sun.appserv.management.client.ConnectionSource connSource, boolean useMBeanServerID)Get an instance. If 'useMBeanServerID' is false, and
the ConnectionSource is not one that has been passed before, a new ProxyFactory
is instantiated which will not share its proxies with any previously-instantiated
ones. Such usage is discouraged, as it duplicates proxies. Pass 'true' unless
there is an excellent reason to pass 'false'.
ProxyFactory instance = findInstance( connSource );
if ( instance == null )
{
try
{
// match based on the MBeanServerConnection; different
// ConnectionSource instances could wrap the same connection
final MBeanServerConnection conn =
connSource.getMBeanServerConnection( false );
instance = findInstance( conn );
// if not found, match based on MBeanServerID as requested, or if this
// is an in-process MBeanServer
if ( instance == null &&
( useMBeanServerID || connSource instanceof MBeanServerConnectionSource ) )
{
final String id = JMXUtil.getMBeanServerID( conn );
instance = findInstanceByID( id );
}
if ( instance == null )
{
debug( "Creating new ProxyFactory for ConnectionSource / conn", connSource, conn );
instance = new ProxyFactory( connSource );
INSTANCES.put( conn, instance );
}
}
catch( Exception e )
{
warning( "ProxyFactory.getInstance: failure creating ProxyFactory: ", e );
throw new RuntimeException( e );
}
}
return( instance );
|
public java.lang.String | getMBeanServerID()
return( mMBeanServerID );
|
public com.sun.appserv.management.base.AMX | getProxy(javax.management.ObjectName objectName)
return getProxy( objectName, true );
|
public com.sun.appserv.management.base.AMX | getProxy(javax.management.ObjectName objectName, boolean create)Get any existing proxy, returning null if none exists and 'create' is false.
return getProxy( objectName, AMX.class, create );
|
public synchronized T | getProxy(javax.management.ObjectName objectName, java.lang.Class theInterface)The actual interface(s) that the proxy implements are predetermined.
Specifying the interface ties the return type to the interface at compile-time
but has no effect on the actual interfaces that are implemented by
the proxy.
return getProxy( objectName, theInterface, true );
|
public synchronized T | getProxy(javax.management.ObjectName objectName, java.lang.Class theClass, boolean create)Get any existing proxy, returning null if none exists and 'create' is false.
AMX proxy = mProxyCache.getCachedProxy( objectName );
if ( proxy == null && create )
{
proxy = createProxy( objectName );
}
return theClass.cast( proxy );
|
public void | handleNotification(javax.management.Notification notifIn, java.lang.Object handback)Listens for MBeanServerNotification.UNREGISTRATION_NOTIFICATION and
JMXConnectionNotification and takes appropriate action.
Used internally as callback for {@link javax.management.NotificationListener}.
DO NOT CALL THIS METHOD.
final String type = notifIn.getType();
if ( type.equals( MBeanServerNotification.UNREGISTRATION_NOTIFICATION) )
{
final MBeanServerNotification notif = (MBeanServerNotification)notifIn;
final ObjectName objectName = notif.getMBeanName();
final AMX proxy = getProxy( objectName, AMX.class, false );
mProxyCache.remove( objectName );
ConverterHandlerUtil.targetUnregistered(proxy);
//debug( "ProxyFactory.handleNotification: UNREGISTERED: ", objectName );
}
else if ( notifIn instanceof JMXConnectionNotification )
{
if ( type.equals( JMXConnectionNotification.CLOSED ) ||
type.equals( JMXConnectionNotification.FAILED ) )
{
debug( "ProxyFactory.handleNotification: connection closed or failed: ", notifIn);
connectionBad();
}
else if ( type.equals( JMXConnectionNotification.NOTIFS_LOST ) )
{
debug( "ProxyFactory.handleNotification: notifications lost: ", notifIn);
notifsLost();
}
}
else
{
debug( "ProxyFactory.handleNotification: UNKNOWN notification: ", notifIn );
}
|
public com.sun.appserv.management.DomainRoot | initDomainRoot()
final ObjectName domainRootObjectName = getDomainRootObjectName( );
final DomainRoot domainRoot = (DomainRoot)
newProxyInstance(domainRootObjectName, new Class[] { DomainRoot.class });
return( domainRoot );
|
private javax.management.ObjectName | initDomainRootObjectName()
final MBeanServerConnection conn = mConnectionSource.getMBeanServerConnection( false );
final String patternString = "*:" +
AMX.J2EE_TYPE_KEY + "=" + XTypes.DOMAIN_ROOT + ",*";
ObjectName pattern = null;
try
{
pattern = new ObjectName( patternString );
}
catch ( MalformedObjectNameException e )
{
warning( "initDomainRootObjectName: impossible failure", e );
assert( false ); // can't happen
throw new RuntimeException( e );
}
final Set<ObjectName> objectNames = JMXUtil.queryNames( conn, pattern, null );
if ( objectNames.size() != 1 )
{
warning( "Can't find DomainRoot MBean using pattern: ", pattern);
throw new IllegalArgumentException( "Can't find DomainRoot MBean using pattern " + pattern );
}
final ObjectName objectName = GSetUtil.getSingleton( objectNames );
return( objectName );
|
public com.sun.appserv.management.base.AMX | newProxyInstance(javax.management.ObjectName objectName, java.lang.Class[] interfaceClasses)Instantiates a new proxy using the default AttributeNameMangler and with any desired number
of interfaces. If you want NotificationBroadcaster as one of the interfaces, you must
supply it in the list.
Use of this routine is discouraged in favor of
{@link #getProxy}
final MBeanProxyHandler handler = createProxyHandler( objectName );
final ClassLoader classLoader = interfaceClasses[ 0 ].getClassLoader();
final AMX proxy = Util.asAMX(Proxy.newProxyInstance( classLoader, interfaceClasses, handler));
if ( proxy != null )
{
mProxyCache.remove( objectName );
mProxyCache.cacheProxy( proxy );
}
return( proxy );
|
void | notifsLost()
// should probably check each proxy for validity, but not clear if it's important...
|
public java.util.List | toProxyList(java.util.Collection objectNames)Convert a Collection of ObjectName to a List of AMX.
final List<AMX> list = new ArrayList<AMX>();
for( final ObjectName objectName : objectNames )
{
try
{
final AMX proxy = getProxy( objectName, AMX.class, true );
list.add( proxy );
}
catch( final Exception e )
{
debug( "ProxyFactory.toProxySet: exception for MBean ",
objectName, " = ", ExceptionUtil.getRootCause( e ) );
}
}
return( list );
|
public java.util.Map | toProxyMap(java.util.Map objectNameMap)Convert a Map of ObjectName, and convert it to a Map
of AMX, with the same keys.
final Map<String,AMX> resultMap = new HashMap<String,AMX>();
final Set<String> keys = objectNameMap.keySet();
for( final String key : keys )
{
final ObjectName objectName = objectNameMap.get( key );
try
{
final AMX proxy = getProxy( objectName, AMX.class, true );
resultMap.put( key, proxy );
}
catch( final Exception e )
{
debug( "ProxyFactory.toProxySet: exception for MBean ",
objectName, " = ", ExceptionUtil.getRootCause( e ) );
}
}
return( resultMap );
|
public java.util.Set | toProxySet(java.util.Set objectNames)Convert a Set of ObjectName to a Set of AMX.
final Set<AMX> s = new HashSet<AMX>();
for( final ObjectName objectName : objectNames )
{
try
{
final AMX proxy = getProxy( objectName, AMX.class, true );
assert( ! s.contains( proxy ) );
s.add( proxy );
}
catch( final Exception e )
{
debug( "ProxyFactory.toProxySet: exception for MBean ",
objectName, " = ", ExceptionUtil.getRootCause( e ) );
}
}
return( s );
|
protected static java.lang.String | toString(java.lang.Object o)
return( com.sun.appserv.management.util.stringifier.SmartStringifier.toString( o ) );
|
private static void | warning(java.lang.Object args)Because ProxyFactory is used on both client and server, emitting anything to stdout
or to the log is unacceptable in some circumstances. Warnings remain available
if the AMX-DEBUG system property allows it.
debug( args );
|