mx4j/src/tools/mx4j/tools/remote/soap SOAPClientInvoker.java,NONE,1.1 SOAPService.java,NONE,1.1 ClientExceptionCatcher.java,1.2,1.3 ConnectionIDRequestHandler.java,1.2,1.3 SOAPConnector.java,1.16,1.17 SOAPConnectorServer.java,1.14,1.15 ClientInvoker.java,1.6,NONE ClientSOAPConnection.java,1.6,NONE SOAPConnection.java,1.4,NONE SOAPConnectionManager.java,1.4,NONE SOAPConnectionPivot.java,1.6,NONE SOAPConnectionProxy.java,1.1,NONE SOAPHeartBeat.java,1.1,NONE SOAPRemoteNotificationClientHandler.java,1.1,NONE ServerInvoker.java,1.6,NONE ServerSOAPConnection.java,1.5,NONE

Simone Bordet <[email protected]>
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26871/src/tools/mx4j/tools/remote/soap

Modified Files:
	ClientExceptionCatcher.java ConnectionIDRequestHandler.java 
	SOAPConnector.java SOAPConnectorServer.java 
Added Files:
	SOAPClientInvoker.java SOAPService.java 
Removed Files:
	ClientInvoker.java ClientSOAPConnection.java 
	SOAPConnection.java SOAPConnectionManager.java 
	SOAPConnectionPivot.java SOAPConnectionProxy.java 
	SOAPHeartBeat.java SOAPRemoteNotificationClientHandler.java 
	ServerInvoker.java ServerSOAPConnection.java 
Log Message:
Refactoring of JSR 160 SOAPConnector and SOAPConnectorServer, moving most functionality to package http, to share with other connectors that use HTTP as transport

--- ServerSOAPConnection.java DELETED ---

--- SOAPHeartBeat.java DELETED ---

--- SOAPConnectionManager.java DELETED ---

Index: SOAPConnectorServer.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap/SOAPConnectorServer.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** SOAPConnectorServer.java	22 Jul 2004 17:21:05 -0000	1.14
--- SOAPConnectorServer.java	10 Aug 2004 08:52:36 -0000	1.15
***************
*** 9,24 ****
  package mx4j.tools.remote.soap;
  
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.util.HashMap;
  import java.util.Map;
  import javax.management.MBeanServer;
  import javax.management.remote.JMXServiceURL;
  
- import mx4j.log.Log;
- import mx4j.log.Logger;
- import mx4j.remote.ConnectionResolver;
  import mx4j.tools.remote.AbstractJMXConnectorServer;
! import mx4j.tools.remote.soap.web.WebContainer;
  
  /**
--- 9,20 ----
  package mx4j.tools.remote.soap;
  
  import java.util.Map;
  import javax.management.MBeanServer;
  import javax.management.remote.JMXServiceURL;
  
  import mx4j.tools.remote.AbstractJMXConnectorServer;
! import mx4j.tools.remote.ConnectionManager;
! import mx4j.tools.remote.http.HTTPConnectionManager;
! import mx4j.tools.remote.http.HTTPConnectorServer;
  
  /**
***************
*** 26,50 ****
   * @version $Revision$
   */
! public class SOAPConnectorServer extends AbstractJMXConnectorServer
  {
-    public static final String USE_EXTERNAL_WEB_CONTAINER = "jmx.remote.x.soap.use.external.web.container";
-    public static final String EMBEDDED_WEB_CONTAINER_CLASS = "jmx.remote.x.soap.embedded.web.container.class";
-    private static Map instances = new HashMap();
- 
-    public static SOAPConnectionManager find(JMXServiceURL address)
-    {
-       synchronized (SOAPConnectorServer.class)
-       {
-          SOAPConnectionManager manager = (SOAPConnectionManager)instances.get(address);
-          if (manager != null) return manager;
-          Logger logger = Log.getLogger(SOAPConnectorServer.class.getName());
-          if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Known SOAPConnectorServers bound at " + instances.keySet());
-          return null;
-       }
-    }
- 
-    private WebContainer webContainer;
-    private SOAPConnectionManager connectionManager;
- 
     public SOAPConnectorServer(JMXServiceURL url, Map environment, MBeanServer server)
     {
--- 22,27 ----
   * @version $Revision$
   */
! public class SOAPConnectorServer extends HTTPConnectorServer
  {
     public SOAPConnectorServer(JMXServiceURL url, Map environment, MBeanServer server)
     {
***************
*** 52,112 ****
     }
  
!    protected void doStart() throws IOException, IllegalStateException
!    {
!       JMXServiceURL address = getAddress();
!       String protocol = address.getProtocol();
!       Map environment = getEnvironment();
!       ConnectionResolver resolver = ConnectionResolver.newConnectionResolver(protocol, environment);
!       if (resolver == null) throw new MalformedURLException("Unsupported protocol: " + protocol);
! 
!       MBeanServer server = getMBeanServer();
!       if (server == null) throw new IllegalStateException("This SOAPConnectorServer is not attached to an MBeanServer");
! 
!       webContainer = (WebContainer)resolver.createServer(address, environment);
! 
!       connectionManager = new SOAPConnectionManager(this, environment);
! 
!       setAddress(resolver.bindServer(webContainer, address, environment));
! 
!       // Here is where we give to clients the possibility to access us
!       register(getAddress(), connectionManager);
!    }
! 
!    private void register(JMXServiceURL url, SOAPConnectionManager manager) throws IOException
!    {
!       synchronized (SOAPConnectorServer.class)
!       {
!          if (instances.get(url) != null) throw new IOException("A SOAPConnectorServer is already serving at address " + url);
!          instances.put(url, manager);
!       }
!    }
! 
!    protected void doStop() throws IOException
!    {
!       if (connectionManager != null)
!       {
!          connectionManager.close();
!          connectionManager = null;
!       }
! 
!       JMXServiceURL address = getAddress();
! 
!       unregister(address);
! 
!       String protocol = address.getProtocol();
!       Map environment = getEnvironment();
!       ConnectionResolver resolver = ConnectionResolver.newConnectionResolver(protocol, environment);
!       if (resolver == null) throw new MalformedURLException("Unsupported protocol: " + protocol);
!       resolver.unbindServer(webContainer, address, environment);
!       resolver.destroyServer(webContainer, address, environment);
!    }
! 
!    private void unregister(JMXServiceURL url) throws IOException
     {
!       synchronized (SOAPConnectorServer.class)
!       {
!          Object removed = instances.remove(url);
!          if (removed == null) throw new IOException("No SOAPConnectorServer is present for address " + url);
!       }
     }
  }
--- 29,35 ----
     }
  
!    protected ConnectionManager createConnectionManager(AbstractJMXConnectorServer server, Map environment)
     {
!       return new HTTPConnectionManager(server, "soap", environment);
     }
  }

Index: ClientExceptionCatcher.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap/ClientExceptionCatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ClientExceptionCatcher.java	25 Dec 2003 22:44:07 -0000	1.2
--- ClientExceptionCatcher.java	10 Aug 2004 08:52:36 -0000	1.3
***************
*** 11,17 ****
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  import java.lang.reflect.Proxy;
- 
  import javax.management.MBeanException;
  import javax.management.RuntimeMBeanException;
--- 11,18 ----
  import java.io.IOException;
  import java.lang.reflect.Constructor;
+ import java.lang.reflect.InvocationHandler;
+ import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.lang.reflect.Proxy;
  import javax.management.MBeanException;
  import javax.management.RuntimeMBeanException;
***************
*** 19,39 ****
  import mx4j.log.Log;
  import mx4j.log.Logger;
  import org.apache.axis.AxisFault;
  
  /**
   * @author <a href="mailto:[email protected]">Simone Bordet</a>
   * @version $Revision$
   */
! class ClientExceptionCatcher extends SOAPConnectionProxy
  {
!    public static SOAPConnection newInstance(SOAPConnection target)
     {
        ClientExceptionCatcher handler = new ClientExceptionCatcher(target);
!       return (SOAPConnection)Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class[] {SOAPConnection.class}, handler);
     }
  
!    private ClientExceptionCatcher(SOAPConnection target)
     {
!       super(target);
     }
  
--- 20,48 ----
  import mx4j.log.Log;
  import mx4j.log.Logger;
+ import mx4j.tools.remote.http.HTTPConnection;
  import org.apache.axis.AxisFault;
  
  /**
+  * Handles exceptions thrown on server-side by rethrowing them on client side.
+  * Axis, as of version 1.1, is not able to do this transparently, so we have to
+  * manually do it here, by parsing the class name and message that are encoded
+  * by Axis in the response.
+  *
   * @author <a href="mailto:[email protected]">Simone Bordet</a>
   * @version $Revision$
   */
! class ClientExceptionCatcher implements InvocationHandler
  {
!    public static HTTPConnection newInstance(HTTPConnection target)
     {
        ClientExceptionCatcher handler = new ClientExceptionCatcher(target);
!       return (HTTPConnection)Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class[]{HTTPConnection.class}, handler);
     }
  
!    private final HTTPConnection target;
! 
!    private ClientExceptionCatcher(HTTPConnection target)
     {
!       this.target = target;
     }
  
***************
*** 42,46 ****
        try
        {
!          return super.invoke(proxy, method, args);
        }
        catch (Throwable x)
--- 51,62 ----
        try
        {
!          try
!          {
!             return method.invoke(target, args);
!          }
!          catch (InvocationTargetException x)
!          {
!             throw x.getTargetException();
!          }
        }
        catch (Throwable x)
***************
*** 91,95 ****
           {
              // Try to find the suitable constructor
!             Constructor ctor = cls.getConstructor(new Class[] {String.class});
              exception = ctor.newInstance(new Object[]{message});
           }
--- 107,111 ----
           {
              // Try to find the suitable constructor
!             Constructor ctor = cls.getConstructor(new Class[]{String.class});
              exception = ctor.newInstance(new Object[]{message});
           }

--- NEW FILE: SOAPClientInvoker.java ---
/*
 * Copyright (C) MX4J.
 * All rights reserved.
 *
 * This software is distributed under the terms of the MX4J License version 1.0.
 * See the terms of the MX4J License in the documentation provided with this software.
 */

package mx4j.tools.remote.soap;

import java.io.IOException;
import java.util.Set;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanRegistrationException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.management.remote.NotificationResult;
import javax.security.auth.Subject;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

import mx4j.tools.remote.http.HTTPConnection;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.message.SOAPHeaderElement;

/**
 * @author <a href="mailto:[email protected]">Simone Bordet</a>
 * @version $Revision: 1.1 $
 */
public class SOAPClientInvoker implements HTTPConnection
{
   private static final QName qObjectName = new QName(SOAPConstants.NAMESPACE_URI, "ObjectName");
   private static final QName qObjectInstance = new QName(SOAPConstants.NAMESPACE_URI, "ObjectInstance");
   private static final QName qSubject = new QName(SOAPConstants.NAMESPACE_URI, "Subject");

   private final String endpoint;
   private final Service service;
   private String connectionId;

   public SOAPClientInvoker(String endpoint, Service service)
   {
      this.endpoint = endpoint;
      this.service = service;
   }

   public String connect(Object credentials) throws IOException, SecurityException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "connect"));
      call.addParameter("credentials", XMLType.XSD_ANY, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_STRING);
//      call.addFault(new QName(SOAPConstants.NAMESPACE_URI, "SecurityException"), SecurityException.class, XMLType.XSD_ANY, true);

      connectionId = (String)call.invoke(new Object[]{credentials});
      return connectionId;
   }

   public void close() throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "close"));
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[0]);
   }

   public String getConnectionId() throws IOException
   {
      return connectionId;
   }

   public Integer addNotificationListener(ObjectName name, Object filter, Subject delegate) throws InstanceNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "addNotificationListener"));
      call.addParameter("observed", qObjectName, ParameterMode.IN);
      call.addParameter("filter", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_INT);

      return (Integer)call.invoke(new Object[]{name, filter, delegate});
   }

   public void removeNotificationListeners(ObjectName observed, Integer[] ids, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "removeNotificationListeners"));
      call.addParameter("observed", qObjectName, ParameterMode.IN);
      call.addParameter("ids", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[]{observed, ids, delegate});
   }

   public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "fetchNotifications"));
      call.addParameter("sequence", XMLType.XSD_LONG, ParameterMode.IN);
      call.addParameter("maxNumber", XMLType.XSD_INT, ParameterMode.IN);
      call.addParameter("timeout", XMLType.XSD_LONG, ParameterMode.IN);
      call.setReturnType(new QName(SOAPConstants.NAMESPACE_URI, "NotificationResult"));

      NotificationResult result = (NotificationResult)call.invoke(new Object[]{new Long(clientSequenceNumber), new Integer(maxNotifications), new Long(timeout)});
      return result;
   }

   public void addNotificationListener(ObjectName name, ObjectName listener, Object filter, Object handback, Subject delegate)
           throws InstanceNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "addNotificationListener"));
      call.addParameter("observed", qObjectName, ParameterMode.IN);
      call.addParameter("listener", qObjectName, ParameterMode.IN);
      call.addParameter("filter", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("handback", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[]{name, listener, filter, handback, delegate});
   }

   public void removeNotificationListener(ObjectName name, ObjectName listener, Subject delegate)
           throws InstanceNotFoundException, ListenerNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "removeNotificationListener"));
      call.addParameter("observed", qObjectName, ParameterMode.IN);
      call.addParameter("listener", qObjectName, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[]{name, listener, delegate});
   }

   public void removeNotificationListener(ObjectName name, ObjectName listener, Object filter, Object handback, Subject delegate)
           throws InstanceNotFoundException, ListenerNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "removeNotificationListener"));
      call.addParameter("observed", qObjectName, ParameterMode.IN);
      call.addParameter("listener", qObjectName, ParameterMode.IN);
      call.addParameter("filter", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("handback", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[]{name, listener, filter, handback, delegate});
   }

   public MBeanInfo getMBeanInfo(ObjectName objectName, Subject delegate) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getMBeanInfo"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(new QName(SOAPConstants.NAMESPACE_URI, "MBeanInfo"));

      MBeanInfo info = (MBeanInfo)call.invoke(new Object[]{objectName, delegate});
      return info;
   }

   public boolean isInstanceOf(ObjectName objectName, String className, Subject delegate) throws InstanceNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "isInstanceOf"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("className", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_BOOLEAN);

      Boolean isinstanceof = (Boolean)call.invoke(new Object[]{objectName, className, delegate});
      return isinstanceof.booleanValue();
   }

   public String[] getDomains(Subject delegate) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getDomains"));
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.SOAP_ARRAY);

      String[] domains = (String[])call.invoke(new Object[]{delegate});
      return domains;
   }

   public String getDefaultDomain(Subject delegate) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getDefaultDomain"));
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_STRING);

      String domain = (String)call.invoke(new Object[]{delegate});
      return domain;
   }

   public ObjectInstance createMBean(String className, ObjectName objectName, Object args, String[] parameters, Subject delegate) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "createMBean"));

      call.addParameter("className", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("arguments", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("signature", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(qObjectInstance);

      ObjectInstance instance = (ObjectInstance)call.invoke(new Object[]{className, objectName, args, parameters, delegate});
      return instance;
   }

   public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName, Object args, String[] parameters, Subject delegate) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "createMBean"));

      call.addParameter("className", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("loaderName", qObjectName, ParameterMode.IN);
      call.addParameter("arguments", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("signature", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(qObjectInstance);

      ObjectInstance instance = (ObjectInstance)call.invoke(new Object[]{className, objectName, loaderName, args, parameters, delegate});
      return instance;
   }

   public void unregisterMBean(ObjectName objectName, Subject delegate) throws InstanceNotFoundException, MBeanRegistrationException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "unregisterMBean"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[]{objectName, delegate});
   }

   public Object getAttribute(ObjectName objectName, String attribute, Subject delegate) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getAttribute"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("attributeName", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_ANY);

      Object result = call.invoke(new Object[]{objectName, attribute, delegate});
      return result;
   }

   public void setAttribute(ObjectName objectName, Object attribute, Subject delegate) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "setAttribute"));

      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("attribute", new QName(SOAPConstants.NAMESPACE_URI, "Attribute"), ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.AXIS_VOID);

      call.invoke(new Object[]{objectName, attribute, delegate});
   }

   public AttributeList getAttributes(ObjectName objectName, String[] attributes, Subject delegate) throws InstanceNotFoundException, ReflectionException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getAttributes"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("attributeNames", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(new QName(SOAPConstants.NAMESPACE_URI, "AttributeList"));

      AttributeList list = (AttributeList)call.invoke(new Object[]{objectName, attributes, delegate});
      return list;
   }

   public AttributeList setAttributes(ObjectName objectName, Object attributes, Subject delegate) throws InstanceNotFoundException, ReflectionException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "setAttributes"));
      QName qAttributeList = new QName(SOAPConstants.NAMESPACE_URI, "AttributeList");
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("attributeList", qAttributeList, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(qAttributeList);

      AttributeList list = (AttributeList)call.invoke(new Object[]{objectName, attributes, delegate});
      return list;
   }

   public Object invoke(ObjectName objectName, String methodName, Object args, String[] parameters, Subject delegate) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "invoke"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("operationName", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("arguments", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("signature", XMLType.SOAP_ARRAY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_ANY);

      Object object = call.invoke(new Object[]{objectName, methodName, args, parameters, delegate});
      return object;
   }

   public Integer getMBeanCount(Subject delegate) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getMBeanCount"));
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_INT);

      Integer count = (Integer)call.invoke(new Object[]{delegate});
      return count;
   }

   public boolean isRegistered(ObjectName objectName, Subject delegate) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "isRegistered"));

      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_BOOLEAN);

      Boolean registered = (Boolean)call.invoke(new Object[]{objectName, delegate});
      return registered.booleanValue();
   }

   public ObjectInstance getObjectInstance(ObjectName objectName, Subject delegate) throws InstanceNotFoundException, IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "getObjectInstance"));
      call.addParameter("objectName", qObjectName, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(qObjectInstance);

      ObjectInstance instance = (ObjectInstance)call.invoke(new Object[]{objectName, delegate});
      return instance;
   }

   public Set queryMBeans(ObjectName patternName, Object filter, Subject delegate) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "queryMBeans"));
      call.addParameter("pattern", qObjectName, ParameterMode.IN);
      call.addParameter("query", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(new QName(SOAPConstants.NAMESPACE_URI, "Set"));

      Set set = (Set)call.invoke(new Object[]{patternName, filter, delegate});
      return set;
   }

   public Set queryNames(ObjectName patternName, Object filter, Subject delegate) throws IOException
   {
      Call call = createCall();

      call.setOperationName(new QName(SOAPConstants.NAMESPACE_URI, "queryNames"));
      call.addParameter("pattern", qObjectName, ParameterMode.IN);
      call.addParameter("query", XMLType.XSD_ANY, ParameterMode.IN);
      call.addParameter("delegate", qSubject, ParameterMode.IN);
      call.setReturnType(new QName(SOAPConstants.NAMESPACE_URI, "Set"));

      Set set = (Set)call.invoke(new Object[]{patternName, filter, delegate});
      return set;
   }

   private Call createCall() throws IOException
   {
      try
      {
         Call call = (Call)service.createCall();

         call.setTargetEndpointAddress(endpoint);

         SOAPHeaderElement connectionIDHeader = new SOAPHeaderElement(SOAPConstants.NAMESPACE_URI, SOAPConstants.CONNECTION_ID_HEADER_NAME, connectionId);
         connectionIDHeader.setMustUnderstand(true);
         call.addHeader(connectionIDHeader);

         return call;
      }
      catch (ServiceException x)
      {
         throw new IOException(x.toString());
      }
   }
}

--- SOAPConnectionProxy.java DELETED ---

--- ServerInvoker.java DELETED ---

--- SOAPConnection.java DELETED ---

--- ClientSOAPConnection.java DELETED ---

--- NEW FILE: SOAPService.java ---
/*
 * Copyright (C) MX4J.
 * All rights reserved.
 *
 * This software is distributed under the terms of the MX4J License version 1.0.
 * See the terms of the MX4J License in the documentation provided with this software.
 */

package mx4j.tools.remote.soap;

import mx4j.tools.remote.http.HTTPService;
import org.apache.axis.MessageContext;

/**
 * The server-side service (the WebService actually) where remote calls end up
 * after being parsed by Axis.
 * This is, in Axis jargon, the 'pivot' of the invocation chain.
 * It is used in the Axis deployment descriptor, and as such must be a public class.
 *
 * @author <a href="mailto:[email protected]">Simone Bordet</a>
 * @version $Revision: 1.1 $
 */
public class SOAPService extends HTTPService
{
   protected String findRequestURL()
   {
      MessageContext context = MessageContext.getCurrentContext();
      return (String)context.getProperty(MessageContext.TRANS_URL);
   }

   protected String getProtocol()
   {
      return "soap";
   }

   protected String findConnectionId()
   {
      MessageContext context = MessageContext.getCurrentContext();
      return (String)context.getProperty(SOAPConstants.CONNECTION_ID_HEADER_NAME);
   }
}

--- SOAPRemoteNotificationClientHandler.java DELETED ---

Index: ConnectionIDRequestHandler.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap/ConnectionIDRequestHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ConnectionIDRequestHandler.java	16 Sep 2003 10:14:44 -0000	1.2
--- ConnectionIDRequestHandler.java	10 Aug 2004 08:52:36 -0000	1.3
***************
*** 9,21 ****
  package mx4j.tools.remote.soap;
  
- import org.apache.axis.handlers.BasicHandler;
- import org.apache.axis.MessageContext;
  import org.apache.axis.AxisFault;
  import org.apache.axis.Message;
  import org.apache.axis.encoding.XMLType;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.message.SOAPHeaderElement;
  
  /**
   *
   * @author <a href="mailto:[email protected]">Simone Bordet</a>
--- 9,23 ----
  package mx4j.tools.remote.soap;
  
  import org.apache.axis.AxisFault;
  import org.apache.axis.Message;
+ import org.apache.axis.MessageContext;
  import org.apache.axis.encoding.XMLType;
+ import org.apache.axis.handlers.BasicHandler;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.message.SOAPHeaderElement;
  
  /**
+  * This class is used in the Axis deployment descriptor, and parses the SOAP header
+  * (on server-side) that contains the connection ID sent by the client.
   *
   * @author <a href="mailto:[email protected]">Simone Bordet</a>

--- SOAPConnectionPivot.java DELETED ---

Index: SOAPConnector.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap/SOAPConnector.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** SOAPConnector.java	1 Mar 2004 18:04:17 -0000	1.16
--- SOAPConnector.java	10 Aug 2004 08:52:36 -0000	1.17
***************
*** 9,23 ****
  
  import java.io.IOException;
- import java.net.MalformedURLException;
  import java.util.Map;
- 
  import javax.management.MBeanServerConnection;
  import javax.management.remote.JMXServiceURL;
  import javax.security.auth.Subject;
  
! import mx4j.remote.ConnectionResolver;
! import mx4j.remote.HeartBeat;
! import mx4j.remote.RemoteNotificationClientHandler;
! import mx4j.tools.remote.AbstractJMXConnector;
  
  /**
--- 9,20 ----
  
  import java.io.IOException;
  import java.util.Map;
  import javax.management.MBeanServerConnection;
  import javax.management.remote.JMXServiceURL;
  import javax.security.auth.Subject;
  
! import mx4j.tools.remote.http.HTTPConnection;
! import mx4j.tools.remote.http.HTTPConnectionMBeanServerConnection;
! import mx4j.tools.remote.http.HTTPConnector;
  
  /**
***************
*** 25,36 ****
   * @version $Revision$
   */
! public class SOAPConnector extends AbstractJMXConnector
  {
-    public static final String SOAP_TRANSPORT_PROTOCOL = "jmx.remote.x.soap.transport.protocol";
- 
-    private transient ClientSOAPConnection connection;
-    private transient RemoteNotificationClientHandler notificationHandler;
-    private transient HeartBeat heartbeat;
- 
     public SOAPConnector(JMXServiceURL url, Map environment) throws IOException
     {
--- 22,27 ----
   * @version $Revision$
   */
! public class SOAPConnector extends HTTPConnector
  {
     public SOAPConnector(JMXServiceURL url, Map environment) throws IOException
     {
***************
*** 38,77 ****
     }
  
-    protected void doConnect(Map environment) throws IOException, SecurityException
-    {
-       JMXServiceURL address = getAddress();
-       String protocol = address.getProtocol();
-       ConnectionResolver resolver = ConnectionResolver.newConnectionResolver(protocol, environment);
-       if (resolver == null) throw new MalformedURLException("Unsupported protocol: " + protocol);
- 
-       connection = (ClientSOAPConnection)resolver.lookupClient(address, environment);
-       connection = (ClientSOAPConnection)resolver.bindClient(connection, environment);
- 
-       Object credentials = environment == null ? null : environment.get(CREDENTIALS);
-       connection.connect(credentials);
- 
-       this.heartbeat = new SOAPHeartBeat(connection, getConnectionNotificationEmitter(), environment);
-       this.notificationHandler = new SOAPRemoteNotificationClientHandler(connection, getConnectionNotificationEmitter(), heartbeat, environment);
- 
-       this.heartbeat.start();
-       this.notificationHandler.start();
-    }
- 
-    protected void doClose() throws IOException
-    {
-       if (notificationHandler != null) notificationHandler.stop();
-       if (heartbeat != null) heartbeat.stop();
-       if (connection != null) connection.close();
-    }
- 
     protected MBeanServerConnection doGetMBeanServerConnection(Subject delegate) throws IOException
     {
!       SOAPConnection catcher = ClientExceptionCatcher.newInstance(connection);
!       return new ClientInvoker(catcher, notificationHandler, delegate);
!    }
! 
!    public String getConnectionId() throws IOException
!    {
!       return connection.getConnectionId();
     }
  }
--- 29,36 ----
     }
  
     protected MBeanServerConnection doGetMBeanServerConnection(Subject delegate) throws IOException
     {
!       HTTPConnection catcher = ClientExceptionCatcher.newInstance(getHTTPConnection());
!       return new HTTPConnectionMBeanServerConnection(catcher, delegate, getRemoteNotificationClientHandler());
     }
  }

--- ClientInvoker.java DELETED ---



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.