FileDocCategorySizeDatePackage
WebServiceEndpoint.javaAPI DocGlassfish v2 API32902Fri May 04 22:31:24 BST 2007com.sun.enterprise.deployment

WebServiceEndpoint

public class WebServiceEndpoint extends Descriptor implements com.sun.enterprise.deployment.types.HandlerChainContainer
Represents a single port-component in a webservice in webservices.xml

Fields Summary
public static final String
TRANSPORT_NONE
public static final String
TRANSPORT_INTEGRAL
public static final String
TRANSPORT_CONFIDENTIAL
public static final String
CLIENT_CERT
public static final String
SOAP11_TOKEN
public static final String
SOAP12_TOKEN
public static final String
SOAP11_MTOM_TOKEN
public static final String
SOAP12_MTOM_TOKEN
public static final String
XML_TOKEN
public static final String
PUBLISHING_SUBCONTEXT
private String
endpointName
private String
serviceEndpointInterface
private QName
wsdlPort
private String
wsdlPortNamespacePrefix
private QName
wsdlService
private String
wsdlServiceNamespacePrefix
private String
mtomEnabled
private String
protocolBinding
private boolean
securePipeline
private String
ejbLink
private EjbDescriptor
ejbComponentImpl
private String
webComponentLink
private WebComponentDescriptor
webComponentImpl
private LinkedList
handlers
private LinkedList
handlerChains
private WebService
webService
private String
endpointAddressUri
private String
authMethod
private String
realm
private String
transportGuarantee
private String
serviceNamespaceUri
private String
serviceLocalPart
private String
servletImplClass
private String
tieClassName
private com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor
messageSecBindingDesc
private String
debuggingEnabled
private List
props
Constructors Summary
public WebServiceEndpoint(WebServiceEndpoint other)


    // copy constructor
       
	super(other);
	endpointName = other.endpointName; // String
	serviceEndpointInterface = other.serviceEndpointInterface; // String
	wsdlPort = other.wsdlPort; // QName
	wsdlPortNamespacePrefix = other.wsdlPortNamespacePrefix; 
        wsdlService = other.wsdlService;
	wsdlServiceNamespacePrefix = other.wsdlServiceNamespacePrefix;         
        mtomEnabled = other.mtomEnabled;
        protocolBinding = other.protocolBinding;        
	ejbLink = other.ejbLink; // String
	ejbComponentImpl = other.ejbComponentImpl; // EjbDescriptor copy as-is
	webComponentLink = other.webComponentLink; // String
	webComponentImpl = other.webComponentImpl; // WebComponentDescriptorImpl copy as-is
	handlers = other.handlers; // copy LinkedList(WebServiceHandler)
	if (other.handlers != null) {
            handlers = new LinkedList();
	    for (Iterator i = other.handlers.iterator(); i.hasNext();) {
		WebServiceHandler wsh = (WebServiceHandler)i.next();
		handlers.addLast(new WebServiceHandler(wsh));
	    }
	} else {
	    handlers = null;
	}
        if (other.handlerChains!= null) {
            handlerChains = new LinkedList();
	    for (Iterator i = other.handlerChains.iterator(); i.hasNext();) {
		WebServiceHandlerChain wsh = (WebServiceHandlerChain)i.next();
		handlerChains.addLast(new WebServiceHandlerChain(wsh));
	    }
	} else {
	    handlers = null;
	}

	webService = other.webService; // WebService copy as-is
	endpointAddressUri = other.endpointAddressUri; // String
	authMethod = other.authMethod; // String
	transportGuarantee = other.transportGuarantee; // String
	serviceNamespaceUri = other.serviceNamespaceUri; // String
	serviceLocalPart = other.serviceLocalPart; // String
	servletImplClass = other.servletImplClass; // String
	tieClassName = other.tieClassName; // String
    
public WebServiceEndpoint()

        handlers = new LinkedList();
        handlerChains = new LinkedList();
        authMethod = null;
        wsdlPort = null;
    
Methods Summary
public voidaddHandler(WebServiceHandler handler)
Append handler to end of handler chain for this endpoint.

        handlers.addLast(handler);
        super.changed();
    
public voidaddHandlerChain(WebServiceHandlerChain handlerChain)
Append handlerchain to end of handlerchain for this endpoint.

        handlerChains.addLast(handlerChain);
        super.changed();
    
public voidaddProperty(NameValuePairDescriptor newProp)

        if (props==null) {
            props = new ArrayList();
        }
        props.add(newProp);
    
public java.net.URLcomposeEndpointAddress(java.net.URL root)
Given the root portion of a URL representing the :: of the webserver, return the endpoint address used to make web service invocations on this endpoint.

           
        String uri = null;

        // Compose file portion of URL depending on endpoint type.
        // The file portion of the URL MUST have a single leading slash.
        // Note that the context root and the endpoint address uri strings
        // from the descriptors may or may not each have a leading slash.
        if( implementedByWebComponent() ) {
            if (endpointAddressUri == null) {
                updateServletEndpointRuntime();
            }
            
            // for servlets, endpoint address uri is relative to 
            // web app context root.
            WebBundleDescriptor webBundle = 
                webComponentImpl.getWebBundleDescriptor();
            String contextRoot = webBundle.getContextRoot();

            if( contextRoot != null ) {
                if( !contextRoot.startsWith("/") ) {
                    contextRoot = "/" + contextRoot;
                }
            
                uri = contextRoot +
                    (endpointAddressUri.startsWith("/") ?
                     endpointAddressUri : ("/" + endpointAddressUri));
            }
        } else {
            if( hasEndpointAddressUri() ) {
                uri = endpointAddressUri.startsWith("/") ?
                    endpointAddressUri : ("/" + endpointAddressUri);
            } else {
                // we need to define a standard endpoint address
                uri = "/" + getWebService().getName() + "/" + 
                        getEndpointName();
                setEndpointAddressUri(uri);
            }
        }

        URL endpointAddressURL = 
            new URL(root.getProtocol(), root.getHost(), root.getPort(), uri);

        return endpointAddressURL;
    
public java.net.URLcomposeFinalWsdlUrl(java.net.URL root)
Generate a URL pointing to the initial wsdl document for this endpoint's web service.

        
        // WSDL for this webservice is published in a subcontext created
        // under the endpoint address uri.  The hierarchy under there mirrors
        // the structure of the module file in which this endpoint's
        // webservice is defined.  This allows easy retrieval of the wsdl
        // content using jar URLs.
        URL context = composeEndpointAddress(root);
        String mainFile = context.getFile() + "/" + 
            PUBLISHING_SUBCONTEXT + "/" + webService.getWsdlFileUri();
        URL finalWsdlUrl = new URL(context.getProtocol(), context.getHost(),
                                   context.getPort(), mainFile);  
        return finalWsdlUrl;
    
public java.lang.StringgetAuthMethod()

        return authMethod;
    
public BundleDescriptorgetBundleDescriptor()

        return getWebService().getBundleDescriptor();
    
public java.lang.StringgetDebugging()

        return debuggingEnabled;        
    
private EjbBundleDescriptorgetEjbBundle()

        return (EjbBundleDescriptor) getBundleDescriptor();
    
public EjbDescriptorgetEjbComponentImpl()

        return ejbComponentImpl;
    
public java.lang.StringgetEjbLink()

        return ejbLink;
    
public java.lang.StringgetEndpointAddressUri()

        return endpointAddressUri;
    
public java.lang.StringgetEndpointName()

        return endpointName;
    
public java.util.LinkedListgetHandlerChain()
Get ordered list of WebServiceHandler handler chains for this endpoint.

        return handlerChains;
    
public java.util.LinkedListgetHandlers()
Get ordered list of WebServiceHandler handler for this endpoint.

        return handlers;
    
public java.lang.StringgetLinkName()

        String linkName = null;
        if( implementedByEjbComponent() ) {
            linkName = ejbLink;
        } else if( implementedByWebComponent() ) {
            linkName = webComponentLink;
        }
        return linkName;
    
public com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptorgetMessageSecurityBinding()

        return messageSecBindingDesc;
    
public java.lang.StringgetMtomEnabled()

        return mtomEnabled;
    
public java.util.IteratorgetProperties()

        if (props == null) {
            return null;
        }
        return props.iterator();
    
public java.lang.StringgetProtocolBinding()

        return ((protocolBinding==null) ? 
            javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING : protocolBinding);
    
public java.lang.StringgetPublishingUri()
This is the logical equivalent to endpoint address uri, but for url publishing. Like endpoint address uri, it does not include the context root for servlet endpoints.

return
publishing uri without a leading or trailing slash.


        String uri = endpointAddressUri.startsWith("/") ?
            endpointAddressUri.substring(1) : endpointAddressUri;

        return uri + "/" + PUBLISHING_SUBCONTEXT;
    
public java.lang.StringgetRealm()

        return realm;
    
public java.lang.StringgetServiceEndpointInterface()

        return serviceEndpointInterface;
    
public javax.xml.namespace.QNamegetServiceName()

return
service QName or null if either part of qname is not set

        // NOTE : Here we do not return getWsdlService to maintain backward
        // compatibility with JAXRPC 1.X
        return hasServiceName() ?
                new QName(serviceNamespaceUri, serviceLocalPart) :
                null;
    
public java.lang.StringgetServletImplClass()

        return servletImplClass;
    
public java.lang.StringgetSoapAddressPrefix()

        if((SOAPBinding.SOAP12HTTP_BINDING.equals(protocolBinding)) ||
            (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(protocolBinding)) ||
            (SOAP12_TOKEN.equals(protocolBinding)) ||
            (SOAP12_MTOM_TOKEN.equals(protocolBinding))) {
            return "soap12";
        }
        // anything else should be soap11
        return "soap";
    
public java.lang.StringgetTieClassName()

        return tieClassName;
    
public java.lang.StringgetTransportGuarantee()

        return transportGuarantee;
    
private WebBundleDescriptorgetWebBundle()

        return (WebBundleDescriptor) getBundleDescriptor();
    
public WebComponentDescriptorgetWebComponentImpl()

        return webComponentImpl;
    
public java.lang.StringgetWebComponentLink()

        return webComponentLink;
    
public WebServicegetWebService()

        return webService;
    
public java.lang.StringgetWsdlContentPath(java.lang.String requestUri)

return
the portion of a request uri that represents the location of wsdl content within a module or null if this request is invalid. Returned value does not have leading slash.

        
        // Strip off leading slash.
        String uri = (requestUri.charAt(0) == '/") ? requestUri.substring(1) :
            requestUri;

        // get "raw" internal publishing uri.  this value
        // does NOT have a leading slash.
        String publishingUriRaw = getPublishingUri();

        // Construct the publishing root.  This should NOT have a
        // leading slash but SHOULD have a trailing slash.
        String publishingRoot = null;

        if( implementedByWebComponent() ) {
            WebBundleDescriptor webBundle = 
                webComponentImpl.getWebBundleDescriptor();
            String contextRoot = webBundle.getContextRoot();
            if( contextRoot.startsWith("/") ) {
                contextRoot = contextRoot.substring(1);
            }
            publishingRoot = contextRoot + "/" + 
                publishingUriRaw + "/";
        } else {
            publishingRoot = publishingUriRaw + "/";
        }

        String wsdlPath = uri.startsWith(publishingRoot) ? 
            uri.substring(publishingRoot.length()) : null;

        return wsdlPath;
    
public javax.xml.namespace.QNamegetWsdlPort()

        return wsdlPort;
    
public java.lang.StringgetWsdlPortNamespacePrefix()

        return wsdlPortNamespacePrefix; 
    
public javax.xml.namespace.QNamegetWsdlService()

        return wsdlService;
    
public java.lang.StringgetWsdlServiceNamespacePrefix()

        return wsdlServiceNamespacePrefix; 
    
public booleanhasAuthMethod()

        return (authMethod != null);
    
public booleanhasBasicAuth()

        return ( (authMethod != null) && 
                 (authMethod.equals(HttpServletRequest.BASIC_AUTH)) );
    
public booleanhasClientCertAuth()

        return ( (authMethod != null) && 
                 (authMethod.equals(CLIENT_CERT)) );
    
public booleanhasEndpointAddressUri()

        return (endpointAddressUri != null);
    
public booleanhasHandlerChain()

return
true if this endpoint has at least one handler chain

        return ( handlerChains.size() > 0 );
    
public booleanhasHandlers()

return
true if this endpoint has at least one handler in its handler chain.

        return ( handlers.size() > 0 );
    
public booleanhasSecurePipeline()

	return securePipeline;
    
public booleanhasServiceName()

        return ((serviceNamespaceUri != null) && (serviceLocalPart != null));
    
public booleanhasServletImplClass()

        return (servletImplClass != null);
    
public booleanhasTieClassName()

        return (tieClassName != null);
    
public booleanhasTransportGuarantee()

        return (transportGuarantee != null);
    
public booleanhasUserSpecifiedProtocolBinding()

        return ((protocolBinding==null) ? false : true);
    
public booleanhasWsdlPort()

        return (wsdlPort != null);
    
public booleanhasWsdlPortNamespacePrefix()

        return (wsdlPortNamespacePrefix != null);
    
public booleanhasWsdlServiceNamespacePrefix()

        return (wsdlServiceNamespacePrefix != null);
    
public booleanimplementedByEjbComponent()

return
true if this endpoint is implemented by any ejb

        return (ejbLink != null);
    
public booleanimplementedByEjbComponent(EjbDescriptor ejb)

return
true if this endpoint is implemented by a specific ejb

        return (ejbLink != null) && ejbLink.equals(ejb.getName());
    
public booleanimplementedByWebComponent()

return
true if this endpoint is implemented by any web component

        return (webComponentLink != null);
    
public booleanimplementedByWebComponent(WebComponentDescriptor webComp)

return
true if this endpoint is implemented by a specific web component

        return ( (webComponentLink != null) && 
                 (webComponentLink.equals(webComp.getCanonicalName())) );
    
public booleanisSecure()

        return ( hasTransportGuarantee() &&
                 (transportGuarantee.equals(TRANSPORT_INTEGRAL) ||
                  transportGuarantee.equals(TRANSPORT_CONFIDENTIAL)) );
    
public booleanmatchesEjbPublishRequest(java.lang.String requestUriRaw, java.lang.String query)
Checks an ejb request uri to see if it represents a legal request for the wsdl content associated with this endpoint's web service. Equivalent matching for servlets is performed automatically by the web server. Should only be called for HTTP(S) GET.

        // Strip off leading slash.
        String requestUri = (requestUriRaw.charAt(0) == '/") ? 
            requestUriRaw.substring(1) : requestUriRaw;
            
        boolean matches = false;

        // If request of form http<s>://<host>:<port>/<endpoint-address>?WSDL
        if( query != null ) {
            String toMatch = (endpointAddressUri.charAt(0) == '/") ?
                endpointAddressUri.substring(1) : endpointAddressUri;
            matches = requestUri.equals(toMatch) && 
                      (query.equalsIgnoreCase("WSDL") ||
                       query.startsWith("xsd=") ||
                       query.startsWith("wsdl="));
        } else {                
            // Add trailing slash to make sure sub context is an exact match.
            String publishingUri = getPublishingUri() + "/";
            matches = requestUri.startsWith(publishingUri);
        }
        
        return matches;
    
public voidprint(java.lang.StringBuffer toStringBuffer)

        super.print(toStringBuffer);
        toStringBuffer.append("\n endpoint name = ").append(endpointName);
        toStringBuffer.append( "\n endpoint intf = ").append(serviceEndpointInterface);
        toStringBuffer.append( "\n wsdl Port = ").append(wsdlPort);
        toStringBuffer.append( "\n ejb Link = ").append(ejbLink);
        toStringBuffer.append( "\n web Link = ").append(webComponentLink);
    
public voidremoveHandler(WebServiceHandler handler)

        handlers.remove(handler);
        super.changed();
    
public voidremoveHandlerByName(java.lang.String handlerName)

        for(Iterator iter = handlers.iterator(); iter.hasNext();) {
            WebServiceHandler next = (WebServiceHandler) iter.next();
            if( next.getHandlerName().equals(handlerName) ) {
                iter.remove();
                super.changed();
                break;
            }
        }
    
public voidremoveHandlerChain(WebServiceHandlerChain handlerChain)

        handlerChains.remove(handlerChain);
        super.changed();
    
public booleanresolveComponentLink()
Convert the contents of the ejb-link or servlet-link element to an object representing the implementation component.

        boolean resolved = false;
        if( ejbLink != null ) {
            EjbBundleDescriptor ejbBundle = getEjbBundle();
            if( ejbBundle.hasEjbByName(ejbLink) ) {
                resolved = true;
                EjbDescriptor ejb = ejbBundle.getEjbByName(ejbLink);
                setEjbComponentImpl(ejb);
            }
        } else if( webComponentLink != null ) {
            WebBundleDescriptor webBundle = getWebBundle();
            WebComponentDescriptor webComponent = 
                (WebComponentDescriptor) webBundle.
                  getWebComponentByCanonicalName(webComponentLink);
            if( webComponent != null ) {
                resolved = true;
                setWebComponentImpl(webComponent);
            }
        }
        super.changed();
        return resolved;
    
public voidsaveServletImplClass()
Store current contents of servlet impl class in a runtime descriptor element. The standard deployment descriptor element will be replaced at deployment time with a container-provided servlet impl, so we need to make a copy of this value in the runtime information.

        if( implementedByWebComponent() ) {
            servletImplClass = ((WebComponentDescriptor) webComponentImpl).
                getWebComponentImplementation();
        } else {
            throw new IllegalStateException("requires ejb");
        }
        super.changed();
    
public voidsetAuthMethod(java.lang.String authType)

        authMethod = authType;
        super.changed();
    
public voidsetDebugging(java.lang.String debuggingEnabled)

        this.debuggingEnabled = debuggingEnabled;        
    
public voidsetEjbComponentImpl(EjbDescriptor ejbComponent)

        webComponentImpl = null;
        webComponentLink = null;

        ejbLink = ejbComponent.getName();
        ejbComponentImpl = ejbComponent;
        super.changed();
    
public voidsetEjbLink(java.lang.String link)

        ejbLink = link;
        super.changed();
    
public voidsetEndpointAddressUri(java.lang.String uri)

        if(!uri.startsWith("/")) {
            uri = "/"+uri;
        }
        endpointAddressUri = uri;
        super.changed();
    
public voidsetEndpointName(java.lang.String name)

        endpointName = name;
        super.changed();
    
public voidsetMessageSecurityBinding(com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor messageSecBindingDesc)

       this.messageSecBindingDesc = messageSecBindingDesc;
    
public voidsetMtomEnabled(java.lang.String value)

        mtomEnabled =value;
        super.changed();
    
public voidsetProtocolBinding(java.lang.String value)

        if(SOAP11_TOKEN.equals(value)) {
            protocolBinding = SOAPBinding.SOAP11HTTP_BINDING;
        } else if(SOAP11_MTOM_TOKEN.equals(value)) {
            protocolBinding = SOAPBinding.SOAP11HTTP_MTOM_BINDING;
        } else if(SOAP12_TOKEN.equals(value)) {
            protocolBinding = SOAPBinding.SOAP12HTTP_BINDING;
        } else if(SOAP12_MTOM_TOKEN.equals(value)) {
            protocolBinding = SOAPBinding.SOAP12HTTP_MTOM_BINDING;
        } else if(XML_TOKEN.equals(value)) {
            protocolBinding = HTTPBinding.HTTP_BINDING;
        } else {
            protocolBinding = value;
        }
        super.changed();
    
public voidsetRealm(java.lang.String realm)

        this.realm = realm;
    
public voidsetSecurePipeline()

	securePipeline = true;
    
public voidsetServiceEndpointInterface(java.lang.String endpointInterface)

        serviceEndpointInterface = endpointInterface;
        super.changed();
    
public voidsetServiceLocalPart(java.lang.String localpart)

        serviceLocalPart = localpart;
        super.changed();
    
public voidsetServiceNamespaceUri(java.lang.String uri)

        serviceNamespaceUri = uri;
        super.changed();
    
public voidsetServletImplClass(java.lang.String implClass)

        servletImplClass = implClass;
        super.changed();
    
public voidsetTieClassName(java.lang.String tieClass)

        tieClassName = tieClass;
    
public voidsetTransportGuarantee(java.lang.String guarantee)

        transportGuarantee = guarantee;
        super.changed();
    
public voidsetWebComponentImpl(WebComponentDescriptor webComponent)

        ejbComponentImpl = null;    
        ejbLink = null;
        webComponentLink = webComponent.getCanonicalName();
        webComponentImpl = webComponent;
        super.changed();
    
public voidsetWebComponentLink(java.lang.String link)

        webComponentLink = link;
        super.changed();
    
public voidsetWebService(WebService service)

        webService = service;
        super.changed();
    
public voidsetWsdlPort(javax.xml.namespace.QName port, java.lang.String prefix)

        wsdlPort = port;
        wsdlPortNamespacePrefix = prefix;
        super.changed();
    
public voidsetWsdlPort(javax.xml.namespace.QName port)

        wsdlPort = port;
        wsdlPortNamespacePrefix = port.getPrefix();
        super.changed();
    
public voidsetWsdlService(javax.xml.namespace.QName svc, java.lang.String prefix)

        wsdlService = svc;
        wsdlServiceNamespacePrefix = prefix;
        serviceNamespaceUri = svc.getNamespaceURI();
        serviceLocalPart = svc.getLocalPart();
        super.changed();
    
public voidsetWsdlService(javax.xml.namespace.QName service)

        wsdlService = service;
        wsdlServiceNamespacePrefix = service.getPrefix();
        serviceNamespaceUri = service.getNamespaceURI();
        serviceLocalPart = service.getLocalPart();        
        super.changed();
    
private voidupdateServletEndpointRuntime()


        // Copy the value of the servlet impl bean class into
        // the runtime information.  This way, we'll still 
        // remember it after the servlet-class element has been 
        // replaced with the name of the container's servlet class.
        saveServletImplClass();

        WebComponentDescriptor webComp = 
            (WebComponentDescriptor) getWebComponentImpl();

        WebBundleDescriptor bundle = webComp.getWebBundleDescriptor();
        WebServicesDescriptor webServices = bundle.getWebServices();
        Collection endpoints = 
            webServices.getEndpointsImplementedBy(webComp);

        if( endpoints.size() > 1 ) {
            String msg = "Servlet " + getWebComponentLink() + 
                " implements " + endpoints.size() + " web service endpoints " +
                " but must only implement 1";
            throw new IllegalStateException(msg);
        }

        if( getEndpointAddressUri() == null ) {
            Set urlPatterns = webComp.getUrlPatternsSet();
            if( urlPatterns.size() == 1 ) {

                // Set endpoint-address-uri runtime info to uri.
                // Final endpoint address will still be relative to context root
                String uri = (String) urlPatterns.iterator().next();
                setEndpointAddressUri(uri);

                // Set transport guarantee in runtime info if transport 
                // guarantee is INTEGRAL or CONDIFIDENTIAL for any 
                // security constraint with this url-pattern.
                Collection constraints = 
                    bundle.getSecurityConstraintsForUrlPattern(uri);
                for(Iterator i = constraints.iterator(); i.hasNext();) {
                    SecurityConstraint next = (SecurityConstraint) i.next();
                        
                    UserDataConstraint dataConstraint = 
                        next.getUserDataConstraint();
                    String guarantee = (dataConstraint != null) ?
                        dataConstraint.getTransportGuarantee() : null;

                    if( (guarantee != null) && 
                        ( guarantee.equals
                          (UserDataConstraint.INTEGRAL_TRANSPORT) || 
                          guarantee.equals
                          (UserDataConstraint.CONFIDENTIAL_TRANSPORT) ) ) {
                        setTransportGuarantee(guarantee);
                        break;
                    }
                }
            } else {
                String msg = "Endpoint " + getEndpointName() +
                    " has not been assigned an endpoint address " +
                    " and is associated with servlet " + 
                    webComp.getCanonicalName() + " , which has " +
                    urlPatterns.size() + " url patterns"; 
                throw new IllegalStateException(msg);
            } 
        }