FileDocCategorySizeDatePackage
ServiceProxy.javaAPI DocApache Tomcat 6.0.144837Fri Jul 20 04:20:34 BST 2007org.apache.naming.factory.webservices

ServiceProxy

public class ServiceProxy extends Object implements InvocationHandler
Object proxy for Web Services.
author
Fabien Carrion

Fields Summary
private javax.xml.rpc.Service
service
Service object. used for delegation
private static Method
portQNameClass
changing behavior to method : Service.getPort(QName, Class)
private static Method
portClass
changing behavior to method : Service.getPort(Class)
private Hashtable
portComponentRef
PortComponentRef list
Constructors Summary
public ServiceProxy(javax.xml.rpc.Service service)
Constructs a new ServiceProxy wrapping given Service instance.

param
service the wrapped Service instance
throws
ServiceException should be never thrown


                             
         
        this.service = service;
        try {
            portQNameClass = Service.class.getDeclaredMethod("getPort", new Class[]{QName.class, Class.class});
            portClass = Service.class.getDeclaredMethod("getPort", new Class[]{Class.class});
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    
Methods Summary
private java.rmi.RemotegetProxyPortClass(java.lang.Object[] args)

param
args Method call arguments
return
Returns the correct Port
throws
ServiceException if port's QName is an unknown Port

        Class serviceendpointClass = (Class) args[0];

        if (this.portComponentRef == null)
            return service.getPort(serviceendpointClass);

        QName portname = (QName) this.portComponentRef.get(serviceendpointClass.getName());
        if (portname != null) {
            return service.getPort(portname, serviceendpointClass);
        } else {
            return service.getPort(serviceendpointClass);
        }
    
private java.lang.ObjectgetProxyPortQNameClass(java.lang.Object[] args)

param
args Method call arguments
return
Returns the correct Port
throws
ServiceException if port's QName is an unknown Port (not defined in WSDL).

        QName name = (QName) args[0];
        String nameString = name.getLocalPart();
        Class serviceendpointClass = (Class) args[1];

        for (Iterator ports = service.getPorts(); ports.hasNext();) {
            QName portName = (QName) ports.next();
            String portnameString = portName.getLocalPart();
            if (portnameString.equals(nameString)) {
                return service.getPort(name, serviceendpointClass);
            }
        }

        // no ports have been found
        throw new ServiceException("Port-component-ref : " + name + " not found");
    
public java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)

see
java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])


        if (portQNameClass.equals(method)) {
            return getProxyPortQNameClass(args);
        }

        if (portClass.equals(method)) {
            return getProxyPortClass(args);
        }

        try {
            return method.invoke(service, args);
        } catch (InvocationTargetException ite) {
            throw ite.getTargetException();
        }
    
public voidsetPortComponentRef(java.util.Hashtable portComponentRef)

param
portComponentRef List

        this.portComponentRef = portComponentRef;