FileDocCategorySizeDatePackage
AdminConnectorClient.javaAPI DocGlassfish v2 API13376Fri May 04 22:33:16 BST 2007com.sun.enterprise.admin.comm

AdminConnectorClient

public class AdminConnectorClient extends Object implements ConnectorClient

Fields Summary
private final HttpConnectorAddress
connectorAddress
private static final String
ADMIN_CLIENT_VERSION
Constructors Summary
public AdminConnectorClient(HttpConnectorAddress address)


      
    
        this.connectorAddress = address;
        Debug.println("AdminConnectorClient.<init> : " + 
            "host = " + address.getHost() + 
            " port = " + address.getPort() + 
            " user = " + address.getAuthenticationInfo().getUser() );
    
Methods Summary
public java.lang.ObjectgetAttribute(javax.management.ObjectName mbeanName, java.lang.String attributeName)

        Object returnValue = null;
        AdminRequest request = new AdminRequest(AdminRequestType.GET_ATTRIBUTE);
        AdminRequestConfigurator reqConfigurator = 
            new AdminRequestConfigurator(request);
        reqConfigurator.setObjectName(mbeanName);
        reqConfigurator.setAttributeName(attributeName);
        reqConfigurator.setClientVersion(ADMIN_CLIENT_VERSION);
        AdminResponse response = sendRequest(request);
        //Assert.assert(response);
        AdminResponseConfigurator resConfigurator = 
            new AdminResponseConfigurator(response);
        if (resConfigurator.hasException())
        {
            Throwable t = resConfigurator.getException();
            if (t instanceof AttributeNotFoundException)
            {
                throw (AttributeNotFoundException)t;
            }
            else if (t instanceof InstanceNotFoundException)
            {
                throw (InstanceNotFoundException)t;
            }
            else if (t instanceof MBeanException)
            {
                throw (MBeanException)t;
            }
            else if (t instanceof ReflectionException)
            {
                throw (ReflectionException)t;
            }
            else if (t instanceof RuntimeException)
            {
                throw (RuntimeException)t;
            }
            else if (t instanceof Error)
            {
                throw new RuntimeErrorException((Error)t);
            }
        }
        else
        {
            returnValue = resConfigurator.getReturnValue();
        }
        return returnValue;
    
public javax.management.AttributeListgetAttributes(javax.management.ObjectName mbeanName, java.lang.String[] attributes)

        AttributeList values = null;
        AdminRequest request = new AdminRequest(
                                    AdminRequestType.GET_ATTRIBUTES);
        AdminRequestConfigurator reqConfigurator = 
            new AdminRequestConfigurator(request);
        reqConfigurator.setObjectName(mbeanName);
        reqConfigurator.setAttributeNames(attributes);
        reqConfigurator.setClientVersion(ADMIN_CLIENT_VERSION);
        AdminResponse response = sendRequest(request);
        //Assert.assert(response);
        AdminResponseConfigurator resConfigurator = 
            new AdminResponseConfigurator(response);
        if (resConfigurator.hasException())
        {
            Throwable t = resConfigurator.getException();
            if (t instanceof InstanceNotFoundException)
            {
                throw (InstanceNotFoundException)t;
            }
            else if (t instanceof ReflectionException)
            {
                throw (ReflectionException)t;
            }
            else if (t instanceof RuntimeException)
            {
                throw (RuntimeException)t;
            }
            else if (t instanceof Error)
            {
                throw new RuntimeErrorException((Error)t);
            }
        }
        else
        {
            values = (AttributeList) resConfigurator.getReturnValue();
        }
        return values;
    
public java.lang.StringgetClientVersion()

        return ADMIN_CLIENT_VERSION;
    
public java.lang.Objectinvoke(javax.management.ObjectName mbeanName, java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)

        Object returnValue = null;
        AdminRequest request = new AdminRequest(AdminRequestType.INVOKE);
        AdminRequestConfigurator reqConfigurator = 
            new AdminRequestConfigurator(request);
        reqConfigurator.setObjectName(mbeanName);
        reqConfigurator.setOperationName(operationName);
        reqConfigurator.setOperationParams(params);
        reqConfigurator.setOperationSignature(signature);
        reqConfigurator.setClientVersion(ADMIN_CLIENT_VERSION);

        AdminResponse response = sendRequest(request);
        AdminResponseConfigurator resConfigurator = 
            new AdminResponseConfigurator(response);
        if (resConfigurator.hasException())
        {
            Throwable t = resConfigurator.getException();
            if (t instanceof InstanceNotFoundException)
            {
                throw (InstanceNotFoundException)t;
            }
            else if (t instanceof MBeanException)
            {
                throw (MBeanException)t;
            }
            else if (t instanceof ReflectionException)
            {
                throw (ReflectionException)t;
            }
            else if (t instanceof RuntimeException)
            {
                throw (RuntimeException)t;
            }
            else if (t instanceof Error)
            {
                throw new RuntimeErrorException((Error)t);
            }
        }
        else
        {
            returnValue = resConfigurator.getReturnValue();
        }
        return returnValue;
    
private com.sun.enterprise.admin.common.AdminResponsesendRequest(com.sun.enterprise.admin.common.AdminRequest request)

        AdminResponse   response    = null;
        IConnection     connection  = null;
        try
        {
		  connection = ConnectionFactory.createConnection(connectorAddress);
            connection.send(request);
            response = (AdminResponse)connection.receive();
        }
        catch (IOException e)
        {
            Debug.printStackTrace(e);
            throw new AFConnectionException(e.getMessage());
        }
        catch (ClassNotFoundException cnfe)
        {
            throw new AFRuntimeException(cnfe.toString());
        }
        catch (Exception e)
        {
            throw new AFRuntimeException(e.getLocalizedMessage());
        }
        finally
        {
            if (connection != null)
            {
                try
                {
                    connection.close();
                }
                catch (Exception e)
                {
                    ExceptionUtil.ignoreException(e);
                }
            }
        }
        return response;
    
public voidsetAttribute(javax.management.ObjectName mbeanName, javax.management.Attribute attribute)

        AdminRequest request = new AdminRequest(AdminRequestType.SET_ATTRIBUTE);
        AdminRequestConfigurator reqConfigurator = 
            new AdminRequestConfigurator(request);
        reqConfigurator.setObjectName(mbeanName);
        reqConfigurator.setAttribute(attribute);
        reqConfigurator.setClientVersion(ADMIN_CLIENT_VERSION);
        AdminResponse response = sendRequest(request);
        //Assert.assert(response);
        AdminResponseConfigurator resConfigurator = 
            new AdminResponseConfigurator(response);
        if (resConfigurator.hasException())
        {
            Throwable t = resConfigurator.getException();
            if (t instanceof AttributeNotFoundException)
            {
                throw (AttributeNotFoundException)t;
            }
            else if (t instanceof InvalidAttributeValueException)
            {
                throw (InvalidAttributeValueException)t;
            }
            else if (t instanceof InstanceNotFoundException)
            {
                throw (InstanceNotFoundException)t;
            }
            else if (t instanceof MBeanException)
            {
                throw (MBeanException)t;
            }
            else if (t instanceof ReflectionException)
            {
                throw (ReflectionException)t;
            }
            else if (t instanceof RuntimeException)
            {
                throw (RuntimeException)t;
            }
            else if (t instanceof Error)
            {
                throw new RuntimeErrorException((Error)t);
            }
        }
    
public javax.management.AttributeListsetAttributes(javax.management.ObjectName mbeanName, javax.management.AttributeList attributes)

        AttributeList values = null;
        AdminRequest request = new AdminRequest(
                                    AdminRequestType.SET_ATTRIBUTES);
        AdminRequestConfigurator reqConfigurator = 
            new AdminRequestConfigurator(request);
        reqConfigurator.setObjectName(mbeanName);
        reqConfigurator.setAttributeList(attributes);
        reqConfigurator.setClientVersion(ADMIN_CLIENT_VERSION);
        AdminResponse response = sendRequest(request);
        //Assert.assert(response);
        AdminResponseConfigurator resConfigurator = 
            new AdminResponseConfigurator(response);
        if (resConfigurator.hasException())
        {
            Throwable t = resConfigurator.getException();
            if (t instanceof InstanceNotFoundException)
            {
                throw (InstanceNotFoundException)t;
            }
            else if (t instanceof ReflectionException)
            {
                throw (ReflectionException)t;
            }
            else if (t instanceof RuntimeException)
            {
                throw (RuntimeException)t;
            }
            else if (t instanceof Error)
            {
                throw new RuntimeErrorException((Error)t);
            }
        }
        else
        {
            values = (AttributeList) resConfigurator.getReturnValue();
        }
        return values;