FileDocCategorySizeDatePackage
ServiceReferenceNode.javaAPI DocGlassfish v2 API9898Fri May 04 22:31:38 BST 2007com.sun.enterprise.deployment.node

ServiceReferenceNode

public class ServiceReferenceNode extends DisplayableComponentNode
This node is responsible for loading web services reference information
author
Kenneth Saks

Fields Summary
private String
serviceEndpointInterface
private com.sun.enterprise.deployment.ServiceRefPortInfo
portInfo
Constructors Summary
public ServiceReferenceNode()
Creates a new instance of ServiceReferenceNode


           
      
        super();
        registerElementHandler
            (new XMLElement(WebServicesTagNames.HANDLER),
             WebServiceHandlerNode.class, "addHandler");
        registerElementHandler
            (new XMLElement(WebServicesTagNames.HANDLER_CHAIN),
             WebServiceHandlerChainNode.class, "addHandlerChain");
        registerElementHandler
            (new XMLElement(TagNames.INJECTION_TARGET), 
             InjectionTargetNode.class, "addInjectionTarget");         
    
Methods Summary
protected java.util.MapgetDispatchTable()
all sub-implementation of this class can use a dispatch table to map xml element to method name on the descriptor class for setting the element value.

return
map with the element name as a key, the setter method as a value

        Map table = super.getDispatchTable();
        table.put(WebServicesTagNames.SERVICE_REF_NAME, "setName");
        table.put(WebServicesTagNames.SERVICE_INTERFACE, "setServiceInterface");
        table.put(WebServicesTagNames.WSDL_FILE, "setWsdlFileUri");
        table.put(WebServicesTagNames.JAXRPC_MAPPING_FILE, "setMappingFileUri");
        table.put(WebServicesTagNames.MAPPED_NAME, "setMappedName");
        table.put(WebServicesTagNames.SERVICE_REF_TYPE, "setInjectionTargetType");
        return table;
    
private com.sun.enterprise.deployment.ServiceReferenceDescriptorgetServiceReferenceDescriptor()

        return (ServiceReferenceDescriptor) getDescriptor();
    
public voidsetElementValue(XMLElement element, java.lang.String value)
receives notiification of the value for a particular tag

param
element the xml element
param
value it's associated value

    
        String qname = element.getQName();
        if (WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE.equals(qname)) {
            portInfo = getServiceReferenceDescriptor().getPortInfoBySEI(value);
            if( portInfo == null  ) {
                portInfo = getServiceReferenceDescriptor().
                    addContainerManagedPort(value);
            }
        } else if( WebServicesTagNames.SERVICE_QNAME.equals(qname) ) {
            String prefix = getPrefixFromQName(value);
            String localPart = getLocalPartFromQName(value);
            String namespaceUri = resolvePrefix(element, prefix);
            if( namespaceUri == null) {
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                    new Object[] { prefix , getServiceReferenceDescriptor().getName()});
            } else {
                QName serviceName = new QName(namespaceUri, localPart);
                getServiceReferenceDescriptor().setServiceName
                    (serviceName, prefix);
            }
        } else if(WebServicesTagNames.ENABLE_MTOM.equals(qname)) {
            portInfo.setMtomEnabled(value);
        } else if( WebServicesTagNames.PORT_COMPONENT_LINK.equals(qname) ) {
            // set link name.  link resolution will be performed during
            // validation stage.
            portInfo.setPortComponentLinkName(value);
            portInfo = null;
        } else {
            super.setElementValue(element, value);
        }
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.ServiceReferenceDescriptor descriptor)
write the method descriptor class to a query-method DOM tree and return it

param
parent node in the DOM tree
param
node name for the root element of this xml fragment
param
the descriptor to write
return
the DOM tree top node

        
        Node serviceRefNode = 
            super.writeDescriptor(parent, nodeName, descriptor);

        writeDisplayableComponentInfo(serviceRefNode, descriptor);
        appendTextChild(serviceRefNode, WebServicesTagNames.SERVICE_REF_NAME, 
                        descriptor.getName());
        appendTextChild(serviceRefNode, WebServicesTagNames.SERVICE_INTERFACE, 
                        descriptor.getServiceInterface());
        appendTextChild(serviceRefNode, WebServicesTagNames.SERVICE_REF_TYPE, 
                descriptor.getInjectionTargetType());        
        appendTextChild(serviceRefNode, WebServicesTagNames.WSDL_FILE,
                        descriptor.getWsdlFileUri());
        appendTextChild(serviceRefNode, WebServicesTagNames.JAXRPC_MAPPING_FILE,
                        descriptor.getMappingFileUri());

        if( descriptor.hasServiceName() ) {
            QName serviceName = descriptor.getServiceName();
            appendQNameChild(WebServicesTagNames.SERVICE_QNAME, serviceRefNode,
                             serviceName.getNamespaceURI(),
                             serviceName.getLocalPart(), 
                             descriptor.getServiceNameNamespacePrefix());
        }

        for(Iterator iter = descriptor.getPortsInfo().iterator(); 
            iter.hasNext();) {
            ServiceRefPortInfo next = (ServiceRefPortInfo) iter.next();
            if( next.isContainerManaged() ) {
                String serviceEndpointInterface = 
                    next.getServiceEndpointInterface();
                Node portComponentRefNode = appendChild
                    (serviceRefNode, WebServicesTagNames.PORT_COMPONENT_REF);
                appendTextChild(portComponentRefNode, 
                                WebServicesTagNames.SERVICE_ENDPOINT_INTERFACE,
                                serviceEndpointInterface);
                appendTextChild(portComponentRefNode,
                                WebServicesTagNames.ENABLE_MTOM,
                                next.getMtomEnabled());
                appendTextChild(portComponentRefNode,
                                WebServicesTagNames.PORT_COMPONENT_LINK,
                                next.getPortComponentLinkName());
            }
        }

        WebServiceHandlerNode handlerNode = new WebServiceHandlerNode();
        handlerNode.writeWebServiceHandlers(serviceRefNode, 
                                            descriptor.getHandlers());

        WebServiceHandlerChainNode handlerChainNode = 
                new WebServiceHandlerChainNode();
        handlerChainNode.writeWebServiceHandlerChains(serviceRefNode, 
                                            descriptor.getHandlerChain());
                
        appendTextChild(serviceRefNode, WebServicesTagNames.MAPPED_NAME,
                descriptor.getMappedName());
        
        if (descriptor.isInjectable()) {
            InjectionTargetNode ijNode = new InjectionTargetNode();
            for (InjectionTarget target : descriptor.getInjectionTargets()) {
                ijNode.writeDescriptor(serviceRefNode, TagNames.INJECTION_TARGET, target);
            }
        }

        return serviceRefNode;