FileDocCategorySizeDatePackage
JAXWSServiceDelegate.javaAPI DocGlassfish v2 API11483Fri May 04 22:36:10 BST 2007com.sun.enterprise.webservice

JAXWSServiceDelegate

public class JAXWSServiceDelegate extends Service
Used as a delegate to concrete JAXWS Service implementation.

Fields Summary
private com.sun.enterprise.deployment.ServiceReferenceDescriptor
serviceRef
private Service
serviceDelegate
private ClassLoader
classLoader
private URL
wsdlLocation
private boolean
fullWsdl
private boolean
noWsdl
private static final int
ADD_PORT
private static final int
CREATE_DISPATCH_CLASS
private static final int
CREATE_DISPATCH_CONTEXT
private static final int
GET_EXECUTOR
private static final int
SET_EXECUTOR
private static final int
GET_HANDLER_RESOLVER
private static final int
GET_PORT_CONTAINER_MANAGED
private static final int
GET_PORT_CLIENT_MANAGED
private static final int
GET_PORTS
private static final int
GET_SERVICE_NAME
private static final int
SET_HANDLER_RESOLVER
private static final int
GET_WSDL_LOCATION
private static final int
GENERATED_SERVICE_METHOD
private static Map
serviceMethodTypes
private static Set
fullWsdlIllegalMethods
private static Set
noWsdlIllegalMethods
Constructors Summary
public JAXWSServiceDelegate(com.sun.enterprise.deployment.ServiceReferenceDescriptor descriptor, Service delegate, ClassLoader loader)


     
        Init();
    
        super((new WsUtil()).privilegedGetServiceRefWsdl(descriptor),
                descriptor.getServiceName());
        serviceRef = descriptor;
        serviceDelegate = delegate;
        classLoader = loader;
        if( serviceRef.hasWsdlFile() ) {
            wsdlLocation = (new WsUtil()).privilegedGetServiceRefWsdl(serviceRef);
            fullWsdl = true;
        } else {
            noWsdl = true;
        }
    
Methods Summary
private static voidInit()
Convert invocation method to a constant for easier processing.


        serviceMethodTypes     = new HashMap();
        fullWsdlIllegalMethods = new HashSet();
        noWsdlIllegalMethods   = new HashSet();

        try {

            Class noParams[]   = new Class[0];
            Class serviceClass = javax.xml.ws.Service.class;

            //
            // Map Service method to method type.
            //

            Method addPort = serviceClass.getDeclaredMethod
                ("addPort", new Class[] {QName.class, URI.class, String.class});
            serviceMethodTypes.put(addPort, 
                                   new Integer(ADD_PORT));

            Method createDispatchClass = serviceClass.getDeclaredMethod
                ("createDispatch", new Class[] {QName.class, Class.class, Service.Mode.class});
            serviceMethodTypes.put(createDispatchClass, 
                                   new Integer(CREATE_DISPATCH_CLASS));

            Method createDispatchContext = serviceClass.getDeclaredMethod
                ("createDispatch", new Class[] {QName.class, JAXBContext.class, Service.Mode.class});
            serviceMethodTypes.put(createDispatchContext, 
                                   new Integer(CREATE_DISPATCH_CONTEXT));

            Method getExecutor = serviceClass.getDeclaredMethod
                ("getExecutor", noParams);
            serviceMethodTypes.put(getExecutor, 
                                   new Integer(GET_EXECUTOR));

            Method setExecutor = serviceClass.getDeclaredMethod
                ("setExecutor", new Class[] {Executor.class});
            serviceMethodTypes.put(setExecutor, 
                                   new Integer(SET_EXECUTOR));

            Method getHandlerResolver = serviceClass.getDeclaredMethod
                ("getHandlerResolver", noParams);
            serviceMethodTypes.put(getHandlerResolver, 
                                   new Integer(GET_HANDLER_RESOLVER));

            Method getPortContainerManaged = serviceClass.getDeclaredMethod
                ("getPort", new Class[] { Class.class });
            serviceMethodTypes.put(getPortContainerManaged, 
                                   new Integer(GET_PORT_CONTAINER_MANAGED));

            Method getPortClientManaged = serviceClass.getDeclaredMethod
                ("getPort", new Class[] { QName.class, Class.class });
            serviceMethodTypes.put(getPortClientManaged, 
                                   new Integer(GET_PORT_CLIENT_MANAGED));
            
            Method getPorts = serviceClass.getDeclaredMethod
                ("getPorts", noParams);
            serviceMethodTypes.put(getPorts, new Integer(GET_PORTS));

            Method getServiceName = serviceClass.getDeclaredMethod
                ("getServiceName", noParams);
            serviceMethodTypes.put(getServiceName, 
                                   new Integer(GET_SERVICE_NAME));

            Method setHandlerResolver = serviceClass.getDeclaredMethod
                ("setHandlerResolver", new Class[] {HandlerResolver.class});
            serviceMethodTypes.put(setHandlerResolver, 
                                   new Integer(SET_HANDLER_RESOLVER));

            Method getWsdlLocation = serviceClass.getDeclaredMethod
                ("getWSDLDocumentLocation", noParams);
            serviceMethodTypes.put(getWsdlLocation,
                                   new Integer(GET_WSDL_LOCATION));
        } catch(NoSuchMethodException nsme) {}

        noWsdlIllegalMethods.add(new Integer(GET_PORT_CONTAINER_MANAGED));
        noWsdlIllegalMethods.add(new Integer(GET_PORT_CLIENT_MANAGED));
        noWsdlIllegalMethods.add(new Integer(GET_PORTS));
        noWsdlIllegalMethods.add(new Integer(GET_SERVICE_NAME));
        noWsdlIllegalMethods.add(new Integer(GET_WSDL_LOCATION));

        // This case shouldn't happen since if service-ref has generated
        // service and no WSDL it won't get past deployment, but it's here
        // for completeness.
        noWsdlIllegalMethods.add(new Integer(GENERATED_SERVICE_METHOD));
    
public voidaddPort(javax.xml.namespace.QName q, java.lang.String id, java.lang.String addr)

        checkUnsupportedMethods(ADD_PORT);
        serviceDelegate.addPort(q, id, addr);
        return;
    
private voidcheckUnsupportedMethods(int methodType)


        Set illegalMethods = fullWsdl ?
            fullWsdlIllegalMethods : noWsdlIllegalMethods;

        if( illegalMethods.contains(new Integer(methodType)) ) {
            throw new UnsupportedOperationException();
        }

        return;
    
public javax.xml.ws.DispatchcreateDispatch(javax.xml.namespace.QName qName, java.lang.Class aClass, javax.xml.ws.Service$Mode mode)

        checkUnsupportedMethods(CREATE_DISPATCH_CLASS);
        return null;
    
public javax.xml.ws.DispatchcreateDispatch(javax.xml.namespace.QName qName, javax.xml.bind.JAXBContext jaxbContext, javax.xml.ws.Service$Mode mode)

        checkUnsupportedMethods(CREATE_DISPATCH_CONTEXT);
        return null;
    
public java.util.concurrent.ExecutorgetExecutor()

        checkUnsupportedMethods(GET_EXECUTOR);
        return serviceDelegate.getExecutor();
    
public javax.xml.ws.handler.HandlerResolvergetHandlerResolver()

        checkUnsupportedMethods(GET_HANDLER_RESOLVER);
        return serviceDelegate.getHandlerResolver();
    
public java.lang.ObjectgetPort(javax.xml.namespace.QName q, java.lang.Class sei)

        checkUnsupportedMethods(GET_PORT_CLIENT_MANAGED);
        return serviceDelegate.getPort(q, sei);
    
public java.lang.ObjectgetPort(java.lang.Class sei)

        checkUnsupportedMethods(GET_PORT_CONTAINER_MANAGED);
        String serviceEndpointInterface = sei.getName();
        ServiceRefPortInfo portInfo = 
                serviceRef.getPortInfo(serviceEndpointInterface);
        Object retVal;
        if( (portInfo != null) && portInfo.hasWsdlPort() ) {
            retVal = getPort(portInfo.getWsdlPort(), sei);
        } else {
            retVal = serviceDelegate.getPort(sei);
        }
        return retVal;
    
public java.util.IteratorgetPorts()

        checkUnsupportedMethods(GET_PORTS);
        return serviceDelegate.getPorts();
    
public javax.xml.namespace.QNamegetServiceName()

        checkUnsupportedMethods(GET_SERVICE_NAME);
        return serviceRef.getServiceName();
    
public java.net.URLgetWSDLDocumentLocation()

        checkUnsupportedMethods(SET_HANDLER_RESOLVER);
        return wsdlLocation;
    
public voidsetExecutor(java.util.concurrent.Executor obj)

        checkUnsupportedMethods(SET_EXECUTOR);
        serviceDelegate.setExecutor(obj);
        return;
    
public voidsetHandlerResolver(javax.xml.ws.handler.HandlerResolver resolver)

        checkUnsupportedMethods(SET_HANDLER_RESOLVER);
        serviceDelegate.setHandlerResolver(resolver);
        return;