J2EE1.4 SDK

com.sun.appserv.management.client
Class ProxyFactory

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

public final class ProxyFactory
extends java.lang.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
 DomainRoot createDomainRoot()
           
static ProxyFactory findInstance(ConnectionSource conn)
           
static ProxyFactory findInstance(MBeanServerConnection conn)
           
static ProxyFactory findInstanceByID(java.lang.String mbeanServerID)
           
protected  MBeanServerConnection getConnection()
           
 ConnectionSource getConnectionSource()
           
 DomainRoot getDomainRoot()
           
 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.
 java.lang.String getMBeanServerID()
           
 AMX getProxy(ObjectName objectName)
           
 AMX getProxy(ObjectName objectName, boolean create)
          Get any existing proxy, returning null if none exists and 'create' is false.
 void handleNotification(Notification notifIn, java.lang.Object handback)
          Listens for MBeanServerNotification.UNREGISTRATION_NOTIFICATION and JMXConnectionNotification and takes appropriate action.
 DomainRoot initDomainRoot()
           
 java.lang.Object newProxyInstance(ObjectName objectName, java.lang.Class[] interfaceClasses)
          Instantiates a new proxy using the default AttributeNameMangler and with any desired number of interfaces.
 java.util.Map toProxyMap(java.util.Map objectNameMap)
          Convert a Map of ObjectName, with any type of key, and convert it to a Map of AMX, with the same keys.
 java.util.Set toProxySet(java.util.Set objectNames)
          Convert a Set of ObjectName to a Set of AMX.
protected static java.lang.String toString(java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

handleNotification

public void handleNotification(Notification notifIn,
                               java.lang.Object handback)
Listens for MBeanServerNotification.UNREGISTRATION_NOTIFICATION and JMXConnectionNotification and takes appropriate action.

Specified by:
handleNotification in interface NotificationListener
Parameters:
notifIn - The notification.
handback - An opaque object which helps the listener to associate information regarding the MBean emitter. This object is passed to the MBean during the addListener call and resent, without modification, to the listener. The MBean object should not use or modify the object.

createDomainRoot

public DomainRoot createDomainRoot()
                            throws java.io.IOException
Throws:
java.io.IOException

initDomainRoot

public DomainRoot initDomainRoot()
                          throws java.io.IOException
Throws:
java.io.IOException

getDomainRoot

public DomainRoot getDomainRoot()
Returns:
the DomainRoot for this factory.

getConnectionSource

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

getMBeanServerID

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

getDomainRootObjectName

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

Throws:
java.io.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(java.lang.String mbeanServerID)
Returns:
ProxyFactory corresponding to the MBeanServerID

getProxy

public AMX getProxy(ObjectName objectName)
Returns:
an appropriate AMX interface for the ObjectName

getProxy

public AMX getProxy(ObjectName objectName,
                    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
Returns:
an appropriate AMX interface for the ObjectName

getConnection

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

newProxyInstance

public java.lang.Object newProxyInstance(ObjectName objectName,
                                         java.lang.Class[] interfaceClasses)
                                  throws java.io.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 forces a new proxy to be created which cannot make use of any internal caching already established. 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:
java.io.IOException

toString

protected static java.lang.String toString(java.lang.Object o)

toProxySet

public java.util.Set toProxySet(java.util.Set objectNames)
Convert a Set of ObjectName to a Set of AMX.

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

toProxyMap

public java.util.Map toProxyMap(java.util.Map objectNameMap)
Convert a Map of ObjectName, with any type of key, and convert it to a Map of AMX, with the same keys.

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

J2EE1.4 SDK

Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.