FileDocCategorySizeDatePackage
ServiceReferenceDescriptor.javaAPI DocGlassfish v2 API19319Fri May 04 22:31:22 BST 2007com.sun.enterprise.deployment

ServiceReferenceDescriptor

public class ServiceReferenceDescriptor extends EnvironmentProperty implements com.sun.enterprise.deployment.types.HandlerChainContainer
Information about a J2EE web service client.
author
Kenneth Saks

Fields Summary
private String
serviceInterface
private String
mappedName
private String
wsdlFileUri
private URL
wsdlFileUrl
Derived, non-peristent location of wsdl file. Only used at deployment/runtime.
private String
mappingFileUri
private File
mappingFile
Derived, non-peristent location of mapping file. Only used at deployment/runtime.
private String
serviceNamespaceUri
private String
serviceLocalPart
private String
serviceNameNamespacePrefix
private Set
portsInfo
private BundleDescriptor
bundleDescriptor
private LinkedList
handlers
private LinkedList
handlerChain
private Set
callProperties
private String
serviceImplClassName
private URL
wsdlOverride
private String
injectionTargetType
Constructors Summary
public ServiceReferenceDescriptor(ServiceReferenceDescriptor other)

 
    
       
        super(other);
	serviceInterface = other.serviceInterface;
        mappedName = other.mappedName;
	wsdlFileUri = other.wsdlFileUri;
	wsdlFileUrl = other.wsdlFileUrl;
	mappingFileUri = other.mappingFileUri;
	mappingFile = other.mappingFile;
	serviceNamespaceUri = other.serviceNamespaceUri;
	serviceLocalPart = other.serviceLocalPart;
	serviceNameNamespacePrefix = other.serviceNameNamespacePrefix;
	portsInfo = new HashSet(); // ServiceRefPortInfo
	for (Iterator i = other.portsInfo.iterator(); i.hasNext();) {
	    ServiceRefPortInfo port = new ServiceRefPortInfo(
		(ServiceRefPortInfo)i.next());
	    port.setServiceReference(this); // reset reference
	    portsInfo.add(port);
	}
	handlers = new LinkedList(); // WebServiceHandler
	for (Iterator i = other.handlers.iterator(); i.hasNext();) {
	    handlers.add(new WebServiceHandler
                ((WebServiceHandler)i.next()));
	}
	handlerChain = new LinkedList(); // WebServiceHandlerChain
	for (Iterator i = other.handlerChain.iterator(); i.hasNext();) {
	    handlerChain.add(new WebServiceHandlerChain((WebServiceHandlerChain)i.next()));
	}
        callProperties = new HashSet(); // NameValuePairDescriptor
	for (Iterator i = other.callProperties.iterator(); i.hasNext();) {
	    callProperties.add(new NameValuePairDescriptor(
		(NameValuePairDescriptor)i.next()));
	}
	serviceImplClassName = other.serviceImplClassName;
    
public ServiceReferenceDescriptor(String name, String description, String service)

        super(name, "", description);
        handlers = new LinkedList();
        handlerChain = new LinkedList();
        portsInfo = new HashSet();
        callProperties = new HashSet();
        serviceInterface = service;
    
public ServiceReferenceDescriptor()

        handlers = new LinkedList();
        handlerChain = new LinkedList();
        portsInfo = new HashSet();
        callProperties = new HashSet();
    
Methods Summary
public voidaddCallProperty(NameValuePairDescriptor property)
Add call property, using property name as a key. This will replace the property value of any existing stub property with the same name.

        NameValuePairDescriptor prop = 
            getCallPropertyByName(property.getName());
        if( prop != null ) {
            prop.setValue(property.getValue());
        } else {
            callProperties.add(property);
        }
    
public ServiceRefPortInfoaddContainerManagedPort(java.lang.String serviceEndpointInterface)

        ServiceRefPortInfo info = new ServiceRefPortInfo();
        info.setServiceEndpointInterface(serviceEndpointInterface);
        info.setIsContainerManaged(true);
        info.setServiceReference(this);
        portsInfo.add(info);
        super.changed();
        return info;
    
public voidaddHandler(WebServiceHandler handler)
Append handler to end of handler chain for this endpoint.

        handlers.addLast(handler);
        super.changed();
    
public voidaddHandlerChain(WebServiceHandlerChain handler)
HandlerChain related setters, getters, adders, finders

        handlerChain.addLast(handler);
        super.changed();
    
public voidaddPortInfo(ServiceRefPortInfo portInfo)

        portInfo.setServiceReference(this);
        portsInfo.add(portInfo);
        super.changed();
    
public voidaddRuntimePortInfo(ServiceRefPortInfo runtimePortInfo)
Special handling of case where runtime port info is added. Ensures that port info is not duplicated when multiple runtime info instances are parsed using same standard descriptor.

        ServiceRefPortInfo existing = null;

        if( runtimePortInfo.hasServiceEndpointInterface() ) {
            existing = 
                getPortInfoBySEI(runtimePortInfo.getServiceEndpointInterface());
        } 
        if( (existing == null) && runtimePortInfo.hasWsdlPort() ) {
            existing = getPortInfoByPort(runtimePortInfo.getWsdlPort());
        }

        if( existing == null ) {
            if (portsInfo!=null && portsInfo.size()>0) {
                LocalStringManagerImpl localStrings =
                    new LocalStringManagerImpl(ServiceReferenceDescriptor.class);            
                DOLUtils.getDefaultLogger().warning( 
                    localStrings.getLocalString("enterprise.deployment.unknownportforruntimeinfo",
                    "Runtime port info SEI {0} is not declared in standard service-ref " + 
                    "deployment descriptors (under port-component-ref), is this intended ?", 
                    new Object[] {runtimePortInfo.getServiceEndpointInterface()}));                
            }
            addPortInfo(runtimePortInfo);
        } else {
            if( !existing.hasServiceEndpointInterface() ) {
                existing.setServiceEndpointInterface
                    (runtimePortInfo.getServiceEndpointInterface());
            }
            if( !existing.hasWsdlPort() ) {
                existing.setWsdlPort(runtimePortInfo.getWsdlPort());
            }
            for(Iterator iter = runtimePortInfo.
                    getStubProperties().iterator(); iter.hasNext();) {
                NameValuePairDescriptor next = 
                    (NameValuePairDescriptor) iter.next();
                // adds using name as key
                existing.addStubProperty(next);
            }
            for(Iterator iter = runtimePortInfo.getCallProperties()
                    .iterator(); iter.hasNext();) {
                NameValuePairDescriptor next = 
                    (NameValuePairDescriptor) iter.next();
                // adds using name as key
                existing.addCallProperty(next);
            }
            if (runtimePortInfo.getMessageSecurityBinding() != null) {
                existing.setMessageSecurityBinding(
                    runtimePortInfo.getMessageSecurityBinding());
            }
        }
    
public booleanequals(java.lang.Object object)

        if (object instanceof ServiceReferenceDescriptor) {
            ServiceReferenceDescriptor thatReference = 
                (ServiceReferenceDescriptor) object;
            return thatReference.getName().equals(this.getName());
        }
        return false;
    
public BundleDescriptorgetBundleDescriptor()

        return bundleDescriptor;
    
public java.util.SetgetCallProperties()
Runtime information.

        return callProperties;
    
public NameValuePairDescriptorgetCallPropertyByName(java.lang.String name)

        NameValuePairDescriptor prop = null;
        for(Iterator iter = callProperties.iterator(); iter.hasNext();) {
            NameValuePairDescriptor next = (NameValuePairDescriptor) 
                iter.next();
            if( next.getName().equals(name) ) {
                prop = next;
                break;
            }
        }
        return prop;
    
public java.util.LinkedListgetHandlerChain()

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

        return handlers;
    
public java.lang.StringgetInjectionTargetType()

        return injectionTargetType;
    
public java.lang.StringgetMappedName()

        return mappedName;
    
public java.io.FilegetMappingFile()

        return mappingFile;
    
public java.lang.StringgetMappingFileUri()

        return mappingFileUri;
    
public ServiceRefPortInfogetPortInfo(java.lang.String serviceEndpointInterface)
Lookup port info by service endpoint interface.

        return getPortInfoBySEI(serviceEndpointInterface);
    
public ServiceRefPortInfogetPortInfoByPort(javax.xml.namespace.QName wsdlPort)
Lookup port info by wsdl port.

        for(Iterator iter = portsInfo.iterator(); iter.hasNext();) {
            ServiceRefPortInfo next = (ServiceRefPortInfo) iter.next();
            if( next.hasWsdlPort() && wsdlPort.equals(next.getWsdlPort()) ) {
                return next;
            }
        }
        return null;
    
public ServiceRefPortInfogetPortInfoBySEI(java.lang.String serviceEndpointInterface)
Lookup port info by service endpoint interface.

        for(Iterator iter = portsInfo.iterator(); iter.hasNext();) {
            ServiceRefPortInfo next = (ServiceRefPortInfo) iter.next();
            if( serviceEndpointInterface.equals
                (next.getServiceEndpointInterface()) ) {
                return next;
            }
        }
        return null;
    
public java.util.SetgetPortsInfo()

        return portsInfo;
    
public java.lang.StringgetServiceImplClassName()

        return serviceImplClassName;
    
public java.lang.StringgetServiceInterface()

        return serviceInterface;
    
public java.lang.StringgetServiceLocalPart()

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

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

        return ( hasServiceName() ? 
                 new QName(serviceNamespaceUri, serviceLocalPart) : null );
    
public java.lang.StringgetServiceNameNamespacePrefix()

        return serviceNameNamespacePrefix;
    
public java.lang.StringgetServiceNamespaceUri()

        return serviceNamespaceUri;
    
public java.lang.StringgetWsdlFileUri()

        return wsdlFileUri;
    
public java.net.URLgetWsdlFileUrl()

        return wsdlFileUrl;
    
public java.net.URLgetWsdlOverride()

        return wsdlOverride;
    
public booleanhasClientManagedPorts()

        boolean clientManaged = false;
        for(Iterator iter = portsInfo.iterator(); iter.hasNext();) {
            ServiceRefPortInfo next = (ServiceRefPortInfo) iter.next();
            if( next.isClientManaged() ) {
                clientManaged = true;
                break;
            }
        }
        return clientManaged;
    
public booleanhasContainerManagedPorts()

        boolean containerManaged = false;
        for(Iterator iter = portsInfo.iterator(); iter.hasNext();) {
            ServiceRefPortInfo next = (ServiceRefPortInfo) iter.next();
            if( next.isContainerManaged() ) {
                containerManaged = true;
                break;
            }
        }
        return containerManaged;
    
public booleanhasGeneratedServiceInterface()

        return !(hasGenericServiceInterface());
    
public booleanhasGenericServiceInterface()

        return serviceInterface.equals("javax.xml.rpc.Service");
    
public booleanhasHandlerChain()

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

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

        return (mappingFileUri != null);
    
public booleanhasServiceImplClassName()

        return (serviceImplClassName != null);
    
public booleanhasServiceName()

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

        return (wsdlFileUri != null);
    
public booleanhasWsdlOverride()

        return (wsdlOverride != null);
    
public voidremoveCallProperty(NameValuePairDescriptor property)
Remove call property, using property name as a key. This will remove the property value of an existing stub property with the matching name.

        NameValuePairDescriptor prop = 
            getCallPropertyByName(property.getName());
        if( prop != null ) {
            callProperties.remove(property);
        } 
    
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 handler)

        handlerChain.remove(handler);
        super.changed();
    
public voidremovePortInfo(ServiceRefPortInfo portInfo)

        portsInfo.remove(portInfo);
        super.changed();
    
public voidsetBundleDescriptor(BundleDescriptor bundle)

        bundleDescriptor = bundle;
    
public voidsetInjectionTargetType(java.lang.String type)

        injectionTargetType = type;
    
public voidsetMappedName(java.lang.String value)

        mappedName = value;
    
public voidsetMappingFile(java.io.File file)
Derived, non-peristent location of mapping file. Only used at deployment/runtime.

        mappingFile = file;
        super.changed();
    
public voidsetMappingFileUri(java.lang.String uri)

        mappingFileUri = uri;
        super.changed();
    
public voidsetServiceImplClassName(java.lang.String className)

        serviceImplClassName = className;
    
public voidsetServiceInterface(java.lang.String service)

        serviceInterface = service;
        super.changed();
    
public voidsetServiceLocalPart(java.lang.String localpart)

        serviceLocalPart = localpart;
        serviceNameNamespacePrefix = null;
        super.changed();
    
public voidsetServiceName(javax.xml.namespace.QName serviceName)

        setServiceName(serviceName, null);
    
public voidsetServiceName(javax.xml.namespace.QName serviceName, java.lang.String prefix)

        serviceNamespaceUri = serviceName.getNamespaceURI();
        serviceLocalPart = serviceName.getLocalPart();
        serviceNameNamespacePrefix = prefix;
        super.changed();
    
public voidsetServiceNameNamespacePrefix(java.lang.String prefix)

        serviceNameNamespacePrefix = prefix;
        super.changed();
    
public voidsetServiceNamespaceUri(java.lang.String uri)

        serviceNamespaceUri = uri;
        serviceNameNamespacePrefix = null;
        super.changed();
    
public voidsetWsdlFileUri(java.lang.String uri)

        if(uri.startsWith("file:")) {
            uri = uri.substring(5);
        }
        wsdlFileUri = uri;
        super.changed();
    
public voidsetWsdlFileUrl(java.net.URL url)
Derived, non-peristent location of wsdl file. Only used at deployment/runtime.

        wsdlFileUrl = url;
        super.changed();
    
public voidsetWsdlOverride(java.net.URL override)

        wsdlOverride = override;