FileDocCategorySizeDatePackage
RemoteMBeanServerConnection.javaAPI DocGlassfish v2 API28394Fri May 04 22:36:24 BST 2007com.sun.enterprise.admin.jmx.remote.internal

RemoteMBeanServerConnection

public class RemoteMBeanServerConnection extends Object implements MBeanServerConnection
Class that represents the proxy to the MBeanServerConnection. The actual MBeanServerConnection is available remotely. Based on Java Serialization. This is the class whose instance is used by that all the clients that wish to communicate over the HTTP channel. As of now, (PE 8.0 FCS) by default a new HTTP connection is opened for every remote MBeanServerConnection {@link MBeanServerConnection} method invocation. This can be configured later on if the server happens to provide persistent HTTP (HTTP 1.1) connections. The current state of implementation is that the server does not support the remote notifications. But the client side is not affected by that. In this implementation, if the clients attempt to add notification listeners, they would recieve an {@link UnsupportedOperationException}.
author
Kedar Mhaswade
since
S1AS8.0
version
1.0

Fields Summary
private com.sun.enterprise.admin.jmx.remote.comm.IConnection
physicalConnection
private com.sun.enterprise.admin.jmx.remote.comm.MBeanServerMessageConductor
conductor
private com.sun.enterprise.admin.jmx.remote.comm.HttpConnectorAddress
ad
private com.sun.enterprise.admin.jmx.remote.notification.ClientNotificationManager
notifMgr
private Map
env
private static com.sun.enterprise.admin.jmx.remote.protocol.Version
cv
private static final Object
EMPTY
private final Logger
logger
Constructors Summary
public RemoteMBeanServerConnection(com.sun.enterprise.admin.jmx.remote.comm.IConnection connectionToServer)

/*, 
        DefaultConfiguration.LOGGER_RESOURCE_BUNDLE_NAME );*/
	
       
        //physicalConnection	= connectionToServer;
        //conductor		= new MBeanServerMessageConductor(physicalConnection);
    
public RemoteMBeanServerConnection(com.sun.enterprise.admin.jmx.remote.comm.HttpConnectorAddress ad, Map env)
Creates a new instance of this class and connects it to the server resource identified by the argument.

/* END -- S1WS_MOD */
        this.ad = ad;
/* BEGIN -- S1WS_MOD */
        this.env = env;
/* END -- S1WS_MOD */
        connect();
/* BEGIN -- S1WS_MOD */
        Boolean enabled = (Boolean) env.get(DefaultConfiguration.NOTIF_ENABLED_PROPERTY_NAME);
        
        if (enabled != null && enabled.booleanValue() == true) {
            notifMgr = new ClientNotificationManager(ad, env);
        }
/* END -- S1WS_MOD */
        logger.finer("Connected to: Address = " + ad.getHost() + ":" + ad.getPort());
    
Methods Summary
public voidaddNotificationListener(javax.management.ObjectName objectName, javax.management.NotificationListener notificationListener, javax.management.NotificationFilter notificationFilter, java.lang.Object obj)

		try {
/* BEGIN -- S1WS_MOD */
            if (notifMgr == null)
                return; //XXX: Ideally throw an Unsupportedexception
            checkNotifInit();
            String id = notifMgr.addNotificationListener(
                                              objectName,
                                              notificationListener,
                                              notificationFilter,
                                              obj);
/* END -- S1WS_MOD */
			connect();
			final MBeanServerResponseMessage response = conductor.invoke(
			MBeanServerRequestMessage.ADD_NOTIFICATION_LISTENERS, 
/* BEGIN -- S1WS_MOD */
			toArray(objectName, notifMgr.getId(), id, null) );
//			toArray(objectName, notificationListener, notificationFilter, obj) );
/* END -- S1WS_MOD */
            MBeanServerResponseActor.voidOrThrow(response);
		}
        catch (Exception e) {
			MBeanServerConnectionExceptionThrower.addNotificationListenerObjectName(e);
        }
    
public voidaddNotificationListener(javax.management.ObjectName objectName, javax.management.ObjectName objectName1, javax.management.NotificationFilter notificationFilter, java.lang.Object obj)

		try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
			connect();
            ListenerInfo info = new ListenerInfo(null, notificationFilter, obj);
			final MBeanServerResponseMessage response = conductor.invoke(
			MBeanServerRequestMessage.ADD_NOTIFICATION_LISTENER_OBJECTNAME,
			toArray(objectName, objectName1, notificationFilter, obj, info.computeId()) );
            MBeanServerResponseActor.voidOrThrow(response);
		}
		catch(Exception e) {
			MBeanServerConnectionExceptionThrower.addNotificationListeners(e);
		}
    
private voidcheckNotifInit()

        if (notifMgr == null)
            return;
        notifMgr.reinit();
    
private voidconnect()

        physicalConnection = ConnectionFactory.createConnection(ad);
        conductor = new MBeanServerMessageConductor(physicalConnection);
    
public javax.management.ObjectInstancecreateMBean(java.lang.String str, javax.management.ObjectName objectName, java.lang.Object[] params, java.lang.String[] signature)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.CREATE_MBEAN_PARAMS,
            toArray(str, objectName, params, signature) );
            //the server should return the correct object, otherwise a CCE results
            return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response));
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.createMBeanParams(e);
            return null;
        }
    
public javax.management.ObjectInstancecreateMBean(java.lang.String str, javax.management.ObjectName objectName, javax.management.ObjectName loaderName, java.lang.Object[] params, java.lang.String[] signature)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.CREATE_MBEAN_LOADER_PARAMS,
            toArray(str, objectName, loaderName, params, signature) );
            //the server should return the correct object, otherwise a CCE results
            return ( (ObjectInstance)MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.createMBeanLoaderParams(e);
            return null;
        }
    
public javax.management.ObjectInstancecreateMBean(java.lang.String str, javax.management.ObjectName objectName)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.CREATE_MBEAN, toArray(str, objectName) );
            //the server should return the correct object, otherwise a CCE results
            return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch (Exception e) {
            MBeanServerConnectionExceptionThrower.createMBean(e);
            return null;
        }
    
public javax.management.ObjectInstancecreateMBean(java.lang.String str, javax.management.ObjectName objectName, javax.management.ObjectName loaderName)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.CREATE_MBEAN_LOADER, toArray(str, objectName, loaderName) );
            //the server should return the correct object, otherwise a CCE results
            return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.createMBeanLoader(e);
            return null;
        }
    
public java.lang.ObjectgetAttribute(javax.management.ObjectName objectName, java.lang.String str)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_ATTRIBUTE, toArray(objectName, str) );
            return ( MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getAttribute(e);
            return null;
        }
    
public javax.management.AttributeListgetAttributes(javax.management.ObjectName objectName, java.lang.String[] attributes)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_ATTRIBUTES,
            toArray(objectName, attributes) );
            //the server should return the correct object, otherwise a CCE results
            return ( (AttributeList) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getAttributes(e);
            return null;
        }
    
public java.lang.StringgetDefaultDomain()

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_DEFAULT_DOMAIN, toArray(EMPTY));
            //the server should return the correct object, otherwise a CCE results
            return ( (String) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getDefaultDomain(e);
            return null;
        }
    
public java.lang.String[]getDomains()

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_DOMAINS, toArray(EMPTY));
            //the server should return the correct object, otherwise a CCE results
            return ( (String[]) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getDomains(e);
            return null;
        }
    
public java.lang.IntegergetMBeanCount()

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_MBEAN_COUNT, toArray(EMPTY));
            //the server should return the correct object, otherwise a CCE results
            return ( (Integer) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getMBeanCount(e);
            return null;
        }
    
public javax.management.MBeanInfogetMBeanInfo(javax.management.ObjectName objectName)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_MBEAN_INFO, toArray(objectName));
            //the server should return the correct object, otherwise a CCE results
            return ( (MBeanInfo) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getMBeanInfo(e);
            return null;
        }
    
public com.sun.enterprise.admin.jmx.remote.notification.ClientNotificationManagergetNotificationManager()

        return notifMgr;
    
public javax.management.ObjectInstancegetObjectInstance(javax.management.ObjectName objectName)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.GET_OBJECT_INSTANCE, toArray(objectName));
            //the server should return the correct object, otherwise a CCE results
            return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.getObjectInstance(e);
            return null;
        }
    
public java.lang.Objectinvoke(javax.management.ObjectName objectName, java.lang.String methodName, java.lang.Object[] params, java.lang.String[] signature)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.INVOKE,
            toArray(objectName, methodName, params, signature));
            return ( MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.invoke(e);
            return null;
        }
    
public booleanisInstanceOf(javax.management.ObjectName objectName, java.lang.String className)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.IS_INSTANCE_OF,
            toArray(objectName, className));
            //the server should return the correct object, otherwise a CCE results
            return ( ((Boolean) MBeanServerResponseActor.returnOrThrow(response)).booleanValue() );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.isInstanceOf(e);
            return false;
        }
    
public booleanisRegistered(javax.management.ObjectName objectName)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.IS_REGISTERED,
            toArray(objectName));
            //the server should return the correct object, otherwise a CCE results
            return ( ((Boolean) MBeanServerResponseActor.returnOrThrow(response)).booleanValue() );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.isRegistered(e);
            return false;
        }
    
public java.util.SetqueryMBeans(javax.management.ObjectName objectName, javax.management.QueryExp queryExp)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.QUERY_MBEANS, toArray(objectName, queryExp));
            //the server should return the correct object, otherwise a CCE results
            return ( (Set) MBeanServerResponseActor.returnOrThrow(response));
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.queryMBeans(e);
            return null;
        }
    
public java.util.SetqueryNames(javax.management.ObjectName objectName, javax.management.QueryExp queryExp)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.QUERY_NAMES, toArray(objectName, queryExp));
            //the server should return the correct object, otherwise a CCE results
            return ( (Set) MBeanServerResponseActor.returnOrThrow(response));
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.queryNames(e);
            return null;
        }
    
public voidremoveNotificationListener(javax.management.ObjectName objectName, javax.management.NotificationListener notificationListener)

/* BEGIN -- S1WS_MOD */
        if (notifMgr == null)
            return; // XXX: Ideally throw an UnsupportedException
/* END -- S1WS_MOD */
        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
            String[] ids = notifMgr.removeNotificationListener(
                                                    objectName,
                                                    notificationListener);
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
/* BEGIN -- S1WS_MOD */
            toArray(objectName, notifMgr.getId(), ids) );
//            toArray(objectName, notificationListener, null) );
/* END -- S1WS_MOD */
            MBeanServerResponseActor.voidOrThrow(response);
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.removeNotificationListener(e);
        }
    
public voidremoveNotificationListener(javax.management.ObjectName objectName, javax.management.ObjectName objectName1)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
/* BEGIN -- S1WS_MOD */
//            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER_OBJECTNAME,
/* END -- S1WS_MOD */
            toArray(objectName, objectName1) );
            MBeanServerResponseActor.voidOrThrow(response);
        }
        catch(Exception e) {
			MBeanServerConnectionExceptionThrower.removeNotificationListenerObjectName(e);
        }
    
public voidremoveNotificationListener(javax.management.ObjectName objectName, javax.management.ObjectName objectName1, javax.management.NotificationFilter notificationFilter, java.lang.Object obj)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            ListenerInfo info = new ListenerInfo(null, notificationFilter, obj);
            final MBeanServerResponseMessage response = conductor.invoke(
/* BEGIN -- S1WS_MOD */
/*
            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
            toArray(objectName, objectName1, notificationFilter, obj) );
*/
            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK,
            toArray(objectName, objectName1, null, null, info.computeId()));
/* END -- S1WS_MOD */
            MBeanServerResponseActor.voidOrThrow(response);
        }
        catch(Exception e) {
			MBeanServerConnectionExceptionThrower.removeNotificationListenerObjectNameFilterHandback(e);
        }
    
public voidremoveNotificationListener(javax.management.ObjectName objectName, javax.management.NotificationListener notificationListener, javax.management.NotificationFilter notificationFilter, java.lang.Object obj)

/* BEGIN -- S1WS_MOD */
        if (notifMgr == null)
            return; //XXX: Ideally throw an UnsupportedException
/* END -- S1WS_MOD */
        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
            String[] ids = notifMgr.removeNotificationListener(
                                                 objectName,
                                                 notificationListener,
                                                 notificationFilter,
                                                 obj);
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
/* BEGIN -- S1WS_MOD */
//            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
            MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER_FILTER_HANDBACK,
            toArray(objectName, notifMgr.getId(), ids.length > 0 ? ids[0] : null, null) );
//            toArray(objectName, notificationListener, notificationFilter, obj) );
/* END -- S1WS_MOD */
            MBeanServerResponseActor.voidOrThrow(response);
        }
        catch(Exception e) {
			MBeanServerConnectionExceptionThrower.removeNotificationListenerFilterHandback(e);
        }
    
public voidsetAttribute(javax.management.ObjectName objectName, javax.management.Attribute attribute)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.SET_ATTRIBUTE, toArray(objectName, attribute));
            //return ( (ObjectInstance) response.getResult() );
            MBeanServerResponseActor.voidOrThrow(response);
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.setAttribute(e);
        }
    
public javax.management.AttributeListsetAttributes(javax.management.ObjectName objectName, javax.management.AttributeList list)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.SET_ATTRIBUTES, toArray(objectName, list));
            //the server should return the correct object, otherwise a CCE results
            return ( (AttributeList) MBeanServerResponseActor.returnOrThrow(response) );
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.setAttributes(e);
            return null;
        }
    
private java.lang.Object[]toArray(java.lang.Object param1)

		final Shifter s = new Shifter (new Object[]{param1});
		s.shiftRight(cv);
        return ( s.state() );
    
private java.lang.Object[]toArray(java.lang.Object param1, java.lang.Object param2)

		final Shifter s = new Shifter (new Object[]{param1, param2});
		s.shiftRight(cv);
        return ( s.state() );
    
private java.lang.Object[]toArray(java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)

		final Shifter s = new Shifter (new Object[]{param1, param2, param3});
		s.shiftRight(cv);
        return ( s.state() );
    
private java.lang.Object[]toArray(java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4)

		final Shifter s = new Shifter (new Object[]{param1, param2, param3, param4});
		s.shiftRight(cv);
        return ( s.state() );
    
private java.lang.Object[]toArray(java.lang.Object param1, java.lang.Object param2, java.lang.Object param3, java.lang.Object param4, java.lang.Object param5)

		final Shifter s = new Shifter (new Object[]{param1, param2, param3, param4, param5});
		s.shiftRight(cv);
        return ( s.state() );
    
public voidunregisterMBean(javax.management.ObjectName objectName)

        try {
/* BEGIN -- S1WS_MOD */
            checkNotifInit();
/* END -- S1WS_MOD */
            connect();
            final MBeanServerResponseMessage response = conductor.invoke(
            MBeanServerRequestMessage.UNREGISTER_MBEAN, toArray(objectName));
            //return ( (ObjectInstance) response.getResult() );
            MBeanServerResponseActor.voidOrThrow(response);
        }
        catch(Exception e) {
            MBeanServerConnectionExceptionThrower.unregisterMBean(e);
        }