Java EE 5 SDK

com.sun.appserv.management.client
Class ProxyFactory

java.lang.Object
  extended by com.sun.appserv.management.client.ProxyFactory
All Implemented Interfaces:
EventListener, NotificationListener

public final class ProxyFactory
extends Object
implements NotificationListener

Factory for AMX proxies. Usually proxies are obtained by starting with the DomainRoot obtained via AppserverConnectionSource.getDomainRoot().

See Also:
AppserverConnectionSource

Method Summary
 boolean checkConnection()
          Verify that the connection is still alive.
 DomainRoot createDomainRoot()
           
static ProxyFactory findInstance(ConnectionSource conn)
           
static ProxyFactory findInstance(MBeanServerConnection conn)
           
static ProxyFactory findInstanceByID(String mbeanServerID)
           
protected  MBeanServerConnection getConnection()
           
 ConnectionSource getConnectionSource()
           
 DomainRoot getDomainRoot()
          Return the DomainRoot.
 DomainRoot getDomainRoot(boolean waitReady)
          If 'waitReady' is true, then upon return AMX is guaranteed to be fully loaded.
 ObjectName getDomainRootObjectName()
          Return the ObjectName for the DomainMBean.
static ProxyFactory getInstance(ConnectionSource conn)
          Calls getInstance( connSource, true ).
static ProxyFactory getInstance(ConnectionSource connSource, boolean useMBeanServerID)
          Get an instance.
static ProxyFactory getInstance(MBeanServer server)
          Get an instance of the ProxyFactory for the MBeanServer.
static ProxyFactory getInstance(MBeanServerConnection conn)
          Get an instance of the ProxyFactory for the MBeanServerConnection.
 String getMBeanServerID()
           
 AMX getProxy(ObjectName objectName)
          Deprecated. use versions that take a class as a parameter
 AMX getProxy(ObjectName objectName, boolean create)
          Deprecated. use versions that take a class as a parameter
<T extends AMX>
T
getProxy(ObjectName objectName, Class<T> theInterface)
          The actual interface(s) that the proxy implements are predetermined.
<T extends AMX>
T
getProxy(ObjectName objectName, Class<T> theClass, boolean create)
          Get any existing proxy, returning null if none exists and 'create' is false.
 void handleNotification(Notification notifIn, Object handback)
          Listens for MBeanServerNotification.UNREGISTRATION_NOTIFICATION and JMXConnectionNotification and takes appropriate action.
 DomainRoot initDomainRoot()
           
 AMX newProxyInstance(ObjectName objectName, Class<?>[] interfaceClasses)
          Instantiates a new proxy using the default AttributeNameMangler and with any desired number of interfaces.
 List<AMX> toProxyList(Collection<ObjectName> objectNames)
          Convert a Collection of ObjectName to a List of AMX.
 Map<String,AMX> toProxyMap(Map<String,ObjectName> objectNameMap)
          Convert a Map of ObjectName, and convert it to a Map of AMX, with the same keys.
 Set<AMX> toProxySet(Set<ObjectName> objectNames)
          Convert a Set of ObjectName to a Set of AMX.
protected static String toString(Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkConnection

public boolean checkConnection()
Verify that the connection is still alive.


handleNotification

public void handleNotification(Notification notifIn,
                               Object handback)
Listens for MBeanServerNotification.UNREGISTRATION_NOTIFICATION and JMXConnectionNotification and takes appropriate action.
Used internally as callback for NotificationListener. DO NOT CALL THIS METHOD.

Specified by:
handleNotification in interface NotificationListener

createDomainRoot

public DomainRoot createDomainRoot()
                            throws IOException
Throws:
IOException

initDomainRoot

public DomainRoot initDomainRoot()
                          throws IOException
Throws:
IOException

getDomainRoot

public DomainRoot getDomainRoot()
Return the DomainRoot. AMX may not yet be fully initialized; call getDomainRoot( true ) if AMX must be initialized upon return.

Returns:
the DomainRoot for this factory.

getDomainRoot

public 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.

Parameters:
waitReady -
Returns:
the DomainRoot for this factory.

getConnectionSource

public ConnectionSource getConnectionSource()
Returns:
the ConnectionSource used by this factory

getMBeanServerID

public String getMBeanServerID()
Returns:
the JMX MBeanServerID for the MBeanServer in which MBeans reside.

getDomainRootObjectName

public ObjectName getDomainRootObjectName()
                                   throws IOException
Return the ObjectName for the DomainMBean.

Throws:
IOException

getInstance

public static ProxyFactory getInstance(MBeanServer server)
Get an instance of the ProxyFactory for the MBeanServer. Generally not applicable for remote clients.

Parameters:
server -

getInstance

public static ProxyFactory getInstance(MBeanServerConnection conn)
Get an instance of the ProxyFactory for the MBeanServerConnection. Creates a ConnectionSource for it and calls getInstance( connSource, true ).


getInstance

public static ProxyFactory getInstance(ConnectionSource conn)
Calls getInstance( connSource, true ).


getInstance

public static ProxyFactory getInstance(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'.

Parameters:
connSource - the ConnectionSource
useMBeanServerID - use the MBeanServerID to determine if it's the same server

findInstance

public static ProxyFactory findInstance(ConnectionSource conn)
Returns:
ProxyFactory corresponding to the ConnectionSource

findInstance

public static ProxyFactory findInstance(MBeanServerConnection conn)
Returns:
ProxyFactory corresponding to the MBeanServerConnection

findInstanceByID

public static ProxyFactory findInstanceByID(String mbeanServerID)
Returns:
ProxyFactory corresponding to the MBeanServerID

getProxy

public AMX getProxy(ObjectName objectName)
Deprecated. use versions that take a class as a parameter

Returns:
an appropriate AMX interface for the ObjectName

getProxy

public AMX getProxy(ObjectName objectName,
                    boolean create)
Deprecated. use versions that take a class as a parameter

Get any existing proxy, returning null if none exists and 'create' is false.

Parameters:
objectName - ObjectName for which a proxy should be created
create - true to create the proxy, false to return existing value
Returns:
an appropriate AMX interface for the ObjectName

getProxy

public <T extends AMX> T getProxy(ObjectName objectName,
                                  Class<T> 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.

Returns:
an appropriate AMX interface for the ObjectName

getProxy

public <T extends AMX> T getProxy(ObjectName objectName,
                                  Class<T> theClass,
                                  boolean create)
Get any existing proxy, returning null if none exists and 'create' is false.

Parameters:
objectName - ObjectName for which a proxy should be created
create - true to create the proxy, false to return existing value
theClass - class of returned proxy, avoids casts and compiler warnings
Returns:
an appropriate AMX interface for the ObjectName

getConnection

protected MBeanServerConnection getConnection()
                                       throws IOException
Returns:
MBeanServerConnection used by this factory
Throws:
IOException

newProxyInstance

public AMX newProxyInstance(ObjectName objectName,
                            Class<?>[] interfaceClasses)
                     throws IOException
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 getProxy(javax.management.ObjectName)

Parameters:
objectName - the target MBean which will be invoked by the proxy
interfaceClasses - all interfaces the proxy should implement
Returns:
the new Proxy implementing the specified interface
Throws:
IOException

toString

protected static String toString(Object o)

toProxySet

public Set<AMX> toProxySet(Set<ObjectName> objectNames)
Convert a Set of ObjectName to a Set of AMX.

Returns:
a Set of AMX from a Set of ObjectName.

toProxyList

public List<AMX> toProxyList(Collection<ObjectName> objectNames)
Convert a Collection of ObjectName to a List of AMX.

Returns:
a List of AMX from a List of ObjectName.

toProxyMap

public Map<String,AMX> toProxyMap(Map<String,ObjectName> objectNameMap)
Convert a Map of ObjectName, and convert it to a Map of AMX, with the same keys.

Returns:
a Map of AMX from a Map of ObjectName.

Java EE 5 SDK

Submit a bug or feature

Copyright 2006 Sun Microsystems, Inc. All rights reserved.