Search in sources :

Example 1 with ExternalMetadataFeature

use of com.oracle.webservices.api.databinding.ExternalMetadataFeature in project metro-jax-ws by eclipse-ee4j.

the class SDODatabindingTestBase method invmSetup.

protected WebServiceFeature[] invmSetup(final URL wsdlURL, final Class sei, final Class seb, final QName serviceName, final QName portName) {
    DatabindingModeFeature dbmf = new DatabindingModeFeature("eclipselink.sdo");
    Class implementorClass = seb;
    boolean handlersSetInDD = false;
    Container container = Container.NONE;
    Map<String, SDDocumentSource> docs = new HashMap<String, SDDocumentSource>();
    SDDocumentSource primaryWSDL = SDDocumentSource.create(wsdlURL);
    docs.put(wsdlURL.toString(), primaryWSDL);
    ExternalMetadataFeature exm = ExternalMetadataFeature.builder().setReader(new com.sun.xml.ws.model.ReflectAnnotationReader() {

        public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
            if (WebService.class.equals(annType)) {
                final WebService ws = cls.getAnnotation(WebService.class);
                return (A) new jakarta.jws.WebService() {

                    public Class<? extends Annotation> annotationType() {
                        return WebService.class;
                    }

                    @Override
                    public String endpointInterface() {
                        return sei.getName();
                    }

                    @Override
                    public String name() {
                        return (ws != null) ? ws.name() : null;
                    }

                    @Override
                    public String portName() {
                        return (ws != null) ? ws.portName() : null;
                    }

                    @Override
                    public String serviceName() {
                        return (ws != null) ? ws.serviceName() : null;
                    }

                    @Override
                    public String targetNamespace() {
                        return (ws != null) ? ws.targetNamespace() : null;
                    }

                    @Override
                    public String wsdlLocation() {
                        return (ws != null) ? ws.wsdlLocation() : null;
                    }
                };
            }
            return cls.getAnnotation(annType);
        }
    }).build();
    BindingID bindingID = BindingID.parse(implementorClass);
    WSBinding binding = bindingID.createBinding(dbmf, exm);
    final WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), XmlUtil.createEntityResolver(null), false);
    ComponentFeature cf = new ComponentFeature(new com.sun.xml.ws.api.Component() {

        public <S> S getSPI(Class<S> spiType) {
            if (TransportTubeFactory.class.equals(spiType))
                return (S) new TransportTubeFactory() {

                    public Tube doCreate(ClientTubeAssemblerContext context) {
                        return new InVmTransportTube(context.getCodec(), context.getBinding(), wsdlURL, endpoint);
                    }
                };
            return null;
        }
    });
    WebServiceFeature[] f = { dbmf, cf };
    return f;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) Tube(com.sun.xml.ws.api.pipe.Tube) HashMap(java.util.HashMap) WebService(jakarta.jws.WebService) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) BindingID(com.sun.xml.ws.api.BindingID) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) Container(com.sun.xml.ws.api.server.Container) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) Annotation(java.lang.annotation.Annotation) ExternalMetadataFeature(com.oracle.webservices.api.databinding.ExternalMetadataFeature) WebService(jakarta.jws.WebService) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Example 2 with ExternalMetadataFeature

use of com.oracle.webservices.api.databinding.ExternalMetadataFeature in project metro-jax-ws by eclipse-ee4j.

the class DeploymentDescriptorParser method parseAdapters.

private List<A> parseAdapters(XMLStreamReader reader) {
    if (!reader.getName().equals(QNAME_ENDPOINTS)) {
        failWithFullName("runtime.parser.invalidElement", reader);
    }
    List<A> adapters = new ArrayList<>();
    Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
    String version = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_VERSION);
    if (!ATTRVALUE_SUPPORTED_VERSIONS.contains(version)) {
        failWithLocalName("runtime.parser.invalidVersionNumber", reader, version);
    }
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        if (reader.getName().equals(QNAME_ENDPOINT)) {
            attrs = XMLStreamReaderUtil.getAttributes(reader);
            String name = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_NAME);
            if (!names.add(name)) {
                logger.warning(WsservletMessages.SERVLET_WARNING_DUPLICATE_ENDPOINT_NAME());
            }
            String implementationName = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_IMPLEMENTATION);
            Class<?> implementorClass = getImplementorClass(implementationName, reader);
            MetadataReader metadataReader = null;
            ExternalMetadataFeature externalMetadataFeature = null;
            // parse subelements to instantiate externalMetadataReader, if necessary ...
            XMLStreamReaderUtil.nextElementContent(reader);
            if (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
                externalMetadataFeature = configureExternalMetadataReader(reader);
                if (externalMetadataFeature != null) {
                    metadataReader = externalMetadataFeature.getMetadataReader(implementorClass.getClassLoader(), false);
                }
            }
            QName serviceName = getQNameAttribute(attrs, ATTR_SERVICE);
            if (serviceName == null) {
                serviceName = EndpointFactory.getDefaultServiceName(implementorClass, metadataReader);
            }
            QName portName = getQNameAttribute(attrs, ATTR_PORT);
            if (portName == null) {
                portName = EndpointFactory.getDefaultPortName(serviceName, implementorClass, metadataReader);
            }
            // get enable-mtom attribute value
            String enable_mtom = getAttribute(attrs, ATTR_ENABLE_MTOM);
            String mtomThreshold = getAttribute(attrs, ATTR_MTOM_THRESHOLD_VALUE);
            String dbMode = getAttribute(attrs, ATTR_DATABINDING);
            String bindingId = getAttribute(attrs, ATTR_BINDING);
            if (bindingId != null) {
                // Convert short-form tokens to API's binding ids
                bindingId = getBindingIdForToken(bindingId);
            }
            WSBinding binding = createBinding(bindingId, implementorClass, enable_mtom, mtomThreshold, dbMode);
            if (externalMetadataFeature != null) {
                binding.getFeatures().mergeFeatures(new WebServiceFeature[] { externalMetadataFeature }, true);
            }
            String urlPattern = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_URL_PATTERN);
            // TODO use 'docs' as the metadata. If wsdl is non-null it's the primary.
            boolean handlersSetInDD = setHandlersAndRoles(binding, reader, serviceName, portName);
            EndpointFactory.verifyImplementorClass(implementorClass, metadataReader);
            SDDocumentSource primaryWSDL = getPrimaryWSDL(reader, attrs, implementorClass, metadataReader);
            WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), createEntityResolver(), false);
            adapters.add(adapterFactory.createAdapter(name, urlPattern, endpoint));
        } else {
            failWithLocalName("runtime.parser.invalidElement", reader);
        }
    }
    return adapters;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Attributes(com.sun.xml.ws.streaming.Attributes) MetadataReader(com.sun.xml.ws.api.databinding.MetadataReader) ExternalMetadataFeature(com.oracle.webservices.api.databinding.ExternalMetadataFeature) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource)

Example 3 with ExternalMetadataFeature

use of com.oracle.webservices.api.databinding.ExternalMetadataFeature in project metro-jax-ws by eclipse-ee4j.

the class DeploymentDescriptorParser method configureExternalMetadataReader.

protected ExternalMetadataFeature configureExternalMetadataReader(XMLStreamReader reader) {
    ExternalMetadataFeature.Builder featureBuilder = null;
    while (QNAME_EXT_METADA.equals(reader.getName())) {
        if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
            Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
            String file = getAttribute(attrs, ATTR_FILE);
            if (file != null) {
                if (featureBuilder == null) {
                    featureBuilder = ExternalMetadataFeature.builder();
                }
                featureBuilder.addFiles(new File(file));
            }
            String res = getAttribute(attrs, ATTR_RESOURCE);
            if (res != null) {
                if (featureBuilder == null) {
                    featureBuilder = ExternalMetadataFeature.builder();
                }
                featureBuilder.addResources(res);
            }
        }
        XMLStreamReaderUtil.nextElementContent(reader);
    }
    return buildFeature(featureBuilder);
}
Also used : Attributes(com.sun.xml.ws.streaming.Attributes) File(java.io.File) ExternalMetadataFeature(com.oracle.webservices.api.databinding.ExternalMetadataFeature)

Aggregations

ExternalMetadataFeature (com.oracle.webservices.api.databinding.ExternalMetadataFeature)3 WSBinding (com.sun.xml.ws.api.WSBinding)2 SDDocumentSource (com.sun.xml.ws.api.server.SDDocumentSource)2 Attributes (com.sun.xml.ws.streaming.Attributes)2 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)1 BindingID (com.sun.xml.ws.api.BindingID)1 ComponentFeature (com.sun.xml.ws.api.ComponentFeature)1 MetadataReader (com.sun.xml.ws.api.databinding.MetadataReader)1 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)1 TransportTubeFactory (com.sun.xml.ws.api.pipe.TransportTubeFactory)1 Tube (com.sun.xml.ws.api.pipe.Tube)1 Container (com.sun.xml.ws.api.server.Container)1 WebService (jakarta.jws.WebService)1 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)1 File (java.io.File)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 QName (javax.xml.namespace.QName)1