FileDocCategorySizeDatePackage
WSDDDeployment.javaAPI DocApache Axis 1.419668Sat Apr 22 18:57:26 BST 2006org.apache.axis.deployment.wsdd

WSDDDeployment

public class WSDDDeployment extends WSDDElement implements WSDDTypeMappingContainer, org.apache.axis.WSDDEngineConfiguration
WSDD deployment element
author
James Snell
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
protected static Log
log
private HashMap
handlers
private HashMap
services
private HashMap
transports
private HashMap
typeMappings
private WSDDGlobalConfiguration
globalConfig
private HashMap
namespaceToServices
Mapping of namespaces -> services
private org.apache.axis.AxisEngine
engine
org.apache.axis.encoding.TypeMappingRegistry
tmr
private boolean
tmrDeployed
Constructors Summary
public WSDDDeployment()
Default constructor

    
public WSDDDeployment(Element e)
Create an element in WSDD that wraps an extant DOM element

param
e the element to create the deployment from
throws
WSDDException when problems occur deploying a service or type mapping.

        super(e);
        Element [] elements = getChildElements(e, ELEM_WSDD_HANDLER);
        int i;
        for (i = 0; i < elements.length; i++) {
            WSDDHandler handler = new WSDDHandler(elements[i]);
            deployHandler(handler);
        }
        elements = getChildElements(e, ELEM_WSDD_CHAIN);
        for (i = 0; i < elements.length; i++) {
            WSDDChain chain = new WSDDChain(elements[i]);
            deployHandler(chain);
        }
        elements = getChildElements(e, ELEM_WSDD_TRANSPORT);
        for (i = 0; i < elements.length; i++) {
            WSDDTransport transport = new WSDDTransport(elements[i]);
            deployTransport(transport);
        }
        elements = getChildElements(e, ELEM_WSDD_SERVICE);
        for (i = 0; i < elements.length; i++) {
            try {
                WSDDService service = new WSDDService(elements[i]);
                deployService(service);
            } catch (WSDDNonFatalException ex) {
                // If it's non-fatal, just keep on going
                log.info(Messages.getMessage("ignoringNonFatalException00"), ex);
            } catch (WSDDException ex) {
                // otherwise throw it upwards
                throw ex;
            }
        }
        elements = getChildElements(e, ELEM_WSDD_TYPEMAPPING);
        for (i = 0; i < elements.length; i++) {
            try {
                WSDDTypeMapping mapping = new WSDDTypeMapping(elements[i]);
                deployTypeMapping(mapping);
            } catch (WSDDNonFatalException ex) {
                // If it's non-fatal, just keep on going
                log.info(Messages.getMessage("ignoringNonFatalException00"), ex);
            } catch (WSDDException ex) {
                // otherwise throw it upwards
                throw ex;
            }
        }
        elements = getChildElements(e, ELEM_WSDD_BEANMAPPING);
        for (i = 0; i < elements.length; i++) {
            WSDDBeanMapping mapping = new WSDDBeanMapping(elements[i]);
            deployTypeMapping(mapping);
        }

        elements = getChildElements(e, ELEM_WSDD_ARRAYMAPPING);
        for (i = 0; i < elements.length; i++) {
            WSDDArrayMapping mapping =
                    new WSDDArrayMapping(elements[i]);
            deployTypeMapping(mapping);
        }

        Element el = getChildElement(e, ELEM_WSDD_GLOBAL);
        if (el != null)
            globalConfig = new WSDDGlobalConfiguration(el);
    
Methods Summary
protected voidaddHandler(WSDDHandler handler)


        
        handlers.put(handler.getQName(), handler);
    
protected voidaddService(WSDDService service)

        WSDDService oldService = (WSDDService) services.get(service.getQName());
        if (oldService != null) {
            oldService.removeNamespaceMappings(this);
        }
        services.put(service.getQName(), service);
    
protected voidaddTransport(WSDDTransport transport)

        transports.put(transport.getQName(), transport);
    
public voidconfigureEngine(org.apache.axis.AxisEngine engine)

        this.engine = engine;
    
public voiddeployHandler(WSDDHandler handler)
Put a WSDDHandler into this deployment, replacing any other WSDDHandler which might already be present with the same QName.

param
handler a WSDDHandler to insert in this deployment

        handler.deployToRegistry(this);
    
private voiddeployMapping(WSDDTypeMapping mapping)

        try {
            String encodingStyle = mapping.getEncodingStyle();
            if (encodingStyle == null) {
                encodingStyle = Constants.URI_DEFAULT_SOAP_ENC;
            }
            TypeMapping tm = tmr.getOrMakeTypeMapping(encodingStyle);
            SerializerFactory   ser = null;
            DeserializerFactory deser = null;
            // Try to construct a serializerFactory by introspecting for the
            // following:
            // public static create(Class javaType, QName xmlType)
            // public <constructor>(Class javaType, QName xmlType)
            // public <constructor>()
            //
            // The BaseSerializerFactory createFactory() method is a utility
            // that does this for us.
            //log.debug("start creating sf and df");
            if (mapping.getSerializerName() != null &&
                    !mapping.getSerializerName().equals("")) {
                ser = BaseSerializerFactory.createFactory(mapping.getSerializer(),
                        mapping.getLanguageSpecificType(),
                        mapping.getQName());
            }

            if ((mapping instanceof WSDDArrayMapping) && (ser instanceof ArraySerializerFactory)) {
                WSDDArrayMapping am = (WSDDArrayMapping) mapping;
                ArraySerializerFactory factory = (ArraySerializerFactory) ser;
                factory.setComponentType(am.getInnerType());
            }

            //log.debug("set ser factory");

            if (mapping.getDeserializerName() != null &&
                    !mapping.getDeserializerName().equals("")) {
                deser = BaseDeserializerFactory.createFactory(mapping.getDeserializer(),
                        mapping.getLanguageSpecificType(),
                        mapping.getQName());
            }
            //log.debug("set dser factory");
            tm.register(mapping.getLanguageSpecificType(), mapping.getQName(), ser, deser);
            //log.debug("registered");
        } catch (ClassNotFoundException e) {
            log.error(Messages.getMessage("unabletoDeployTypemapping00", mapping.getQName().toString()), e);
            throw new WSDDNonFatalException(e);
        } catch (Exception e) {
            throw new WSDDException(e);
        }
    
public voiddeployService(WSDDService service)
Put a WSDDService into this deployment, replacing any other WSDDService which might already be present with the same QName.

param
service a WSDDHandler to insert in this deployment

        service.deployToRegistry(this);
    
public voiddeployToRegistry(org.apache.axis.deployment.wsdd.WSDDDeployment target)

        WSDDGlobalConfiguration global = getGlobalConfiguration();
        if (global != null) {
            target.setGlobalConfiguration(global);
        }
        Iterator i = handlers.values().iterator();
        while (i.hasNext()) {
            WSDDHandler handler = (WSDDHandler) i.next();
            target.deployHandler(handler);
        }
        i = transports.values().iterator();
        while (i.hasNext()) {
            WSDDTransport transport = (WSDDTransport) i.next();
            target.deployTransport(transport);
        }
        i = services.values().iterator();
        while (i.hasNext()) {
            WSDDService service = (WSDDService) i.next();
            service.deployToRegistry(target);
        }
        i = typeMappings.values().iterator();
        while (i.hasNext()) {
            WSDDTypeMapping mapping = (WSDDTypeMapping) i.next();
            target.deployTypeMapping(mapping);
        }
    
public voiddeployTransport(WSDDTransport transport)
Put a WSDDTransport into this deployment, replacing any other WSDDTransport which might already be present with the same QName.

param
transport a WSDDTransport to insert in this deployment

        transport.deployToRegistry(this);
    
public voiddeployTypeMapping(WSDDTypeMapping typeMapping)

        QName qname = typeMapping.getQName();
        String encoding = typeMapping.getEncodingStyle();
        // We have to include the encoding in the key
        // because otherwise we would overwrite exiting mappings
        typeMappings.put(qname + encoding, typeMapping);
        if (tmrDeployed)
            deployMapping(typeMapping);
    
public java.util.IteratorgetDeployedServices()
Get an enumeration of the services deployed to this engine

        ArrayList serviceDescs = new ArrayList();
        for (Iterator i = services.values().iterator(); i.hasNext();) {
            WSDDService service = (WSDDService) i.next();
            try {
                service.makeNewInstance(this);
                serviceDescs.add(service.getServiceDesc());
            } catch (WSDDNonFatalException ex) {
                // If it's non-fatal, just keep on going
                log.info(Messages.getMessage("ignoringNonFatalException00"), ex);
            }
        }
        return serviceDescs.iterator();
    
public org.apache.axis.deployment.wsdd.WSDDDeploymentgetDeployment()

        return this;
    
protected javax.xml.namespace.QNamegetElementName()

        return QNAME_DEPLOY;
    
public org.apache.axis.AxisEnginegetEngine()

        return engine;
    
public WSDDGlobalConfigurationgetGlobalConfiguration()
Get our global configuration

return
a global configuration object

        return globalConfig;
    
public java.util.HashtablegetGlobalOptions()

        return globalConfig.getParametersTable();
    
public org.apache.axis.HandlergetGlobalRequest()

        if (globalConfig != null) {
            WSDDRequestFlow reqFlow = globalConfig.getRequestFlow();
            if (reqFlow != null)
                return reqFlow.getInstance(this);
        }
        return null;
    
public org.apache.axis.HandlergetGlobalResponse()

        if (globalConfig != null) {
            WSDDResponseFlow respFlow = globalConfig.getResponseFlow();
            if (respFlow != null)
                return respFlow.getInstance(this);
        }
        return null;
    
public org.apache.axis.HandlergetHandler(javax.xml.namespace.QName name)
Return an instance of the named handler.

param
name the name of the handler to get
return
an Axis handler with the specified QName or null of not found

        WSDDHandler h = (WSDDHandler) handlers.get(name);
        if (h != null) {
            return h.getInstance(this);
        }
        return null;
    
public WSDDHandler[]getHandlers()

        WSDDHandler [] handlerArray = new WSDDHandler[handlers.size()];
        handlers.values().toArray(handlerArray);
        return handlerArray;
    
public java.util.ListgetRoles()

        return globalConfig == null ? new ArrayList() : globalConfig.getRoles();
    
public org.apache.axis.handlers.soap.SOAPServicegetService(javax.xml.namespace.QName name)
Retrieve an instance of the named service.

param
name the QName identifying the Service
return
the Service associated with qname
throws
ConfigurationException if there was an error resolving the qname

        WSDDService s = (WSDDService) services.get(name);
        if (s != null) {
            return (SOAPService) s.getInstance(this);
        }
        return null;
    
public org.apache.axis.handlers.soap.SOAPServicegetServiceByNamespaceURI(java.lang.String namespace)

        WSDDService s = (WSDDService) namespaceToServices.get(namespace);
        if (s != null) {
            return (SOAPService) s.getInstance(this);
        }
        return null;
    
public WSDDService[]getServices()
Return an array of the services in this deployment

        WSDDService [] serviceArray = new WSDDService[services.size()];
        services.values().toArray(serviceArray);
        return serviceArray;
    
public org.apache.axis.HandlergetTransport(javax.xml.namespace.QName name)
Retrieve an instance of the named transport.

param
name the QName of the transport
return
a Handler implementing the transport
throws
ConfigurationException if there was an error resolving the transport

        WSDDTransport t = (WSDDTransport) transports.get(name);
        if (t != null) {
            return t.getInstance(this);
        }
        return null;
    
public WSDDTransport[]getTransports()

        WSDDTransport [] transportArray = new WSDDTransport[transports.size()];
        transports.values().toArray(transportArray);
        return transportArray;
    
public org.apache.axis.encoding.TypeMappinggetTypeMapping(java.lang.String encodingStyle)


          
        return (TypeMapping) getTypeMappingRegistry().getTypeMapping(encodingStyle);
    
public org.apache.axis.encoding.TypeMappingRegistrygetTypeMappingRegistry()


         
        if (false == tmrDeployed) {
            Iterator i = typeMappings.values().iterator();
            while (i.hasNext()) {
                WSDDTypeMapping mapping = (WSDDTypeMapping) i.next();
                deployMapping(mapping);
            }
            tmrDeployed = true;
        }
        return tmr;
    
public WSDDTypeMapping[]getTypeMappings()

return
an array of type mappings in this deployment

        WSDDTypeMapping[] t = new WSDDTypeMapping[typeMappings.size()];
        typeMappings.values().toArray(t);
        return t;
    
public WSDDHandlergetWSDDHandler(javax.xml.namespace.QName qname)

        return (WSDDHandler) handlers.get(qname);
    
public WSDDServicegetWSDDService(javax.xml.namespace.QName qname)
Return the WSDD description for a given named service

        return (WSDDService) services.get(qname);
    
public WSDDTransportgetWSDDTransport(javax.xml.namespace.QName qname)

        return (WSDDTransport) transports.get(qname);
    
public voidregisterNamespaceForService(java.lang.String namespace, WSDDService service)
Register a particular namepsace which maps to a given WSDDService. This will be used for namespace-based dispatching.

param
namespace a namespace URI
param
service the target WSDDService

        namespaceToServices.put(namespace, service);
    
public voidremoveNamespaceMapping(java.lang.String namespace)
Remove a namespace -> WSDDService mapping.

param
namespace the namespace URI to unmap

        namespaceToServices.remove(namespace);
    
public voidsetGlobalConfiguration(WSDDGlobalConfiguration globalConfig)

        this.globalConfig = globalConfig;
    
public voidundeployHandler(javax.xml.namespace.QName qname)
Remove a named handler

param
qname the QName of the handler to remove

        handlers.remove(qname);
    
public voidundeployService(javax.xml.namespace.QName qname)
Remove a named service

param
qname the QName of the service to remove

        WSDDService service = (WSDDService) services.get(qname);
        if (service != null) {
            service.removeNamespaceMappings(this);
            services.remove(qname);
        }
    
public voidundeployTransport(javax.xml.namespace.QName qname)
Remove a named transport

param
qname the QName of the transport to remove

        transports.remove(qname);
    
public voidwriteEngineConfig(org.apache.axis.AxisEngine engine)

    
public voidwriteToContext(org.apache.axis.encoding.SerializationContext context)

        context.registerPrefixForURI(NS_PREFIX_WSDD, URI_WSDD);
        context.registerPrefixForURI(NS_PREFIX_WSDD_JAVA, URI_WSDD_JAVA);
        context.startElement(QNAME_DEPLOY, null);
        if (globalConfig != null) {
            globalConfig.writeToContext(context);
        }
        Iterator i = handlers.values().iterator();
        while (i.hasNext()) {
            WSDDHandler handler = (WSDDHandler) i.next();
            handler.writeToContext(context);
        }
        i = services.values().iterator();
        while (i.hasNext()) {
            WSDDService service = (WSDDService) i.next();
            service.writeToContext(context);
        }
        i = transports.values().iterator();
        while (i.hasNext()) {
            WSDDTransport transport = (WSDDTransport) i.next();
            transport.writeToContext(context);
        }
        i = typeMappings.values().iterator();
        while (i.hasNext()) {
            WSDDTypeMapping mapping = (WSDDTypeMapping) i.next();
            mapping.writeToContext(context);
        }
        context.endElement();