Search in sources :

Example 1 with ReflectAnnotationReader

use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.

the class EndpointFactory method getDefaultServiceName.

@NotNull
public static QName getDefaultServiceName(Class<?> implType, boolean isStandard, MetadataReader metadataReader) {
    if (metadataReader == null) {
        metadataReader = new ReflectAnnotationReader();
    }
    QName serviceName;
    WebServiceProvider wsProvider = metadataReader.getAnnotation(WebServiceProvider.class, implType);
    if (wsProvider != null) {
        String tns = wsProvider.targetNamespace();
        String local = wsProvider.serviceName();
        serviceName = new QName(tns, local);
    } else {
        serviceName = RuntimeModeler.getServiceName(implType, metadataReader, isStandard);
    }
    assert serviceName != null;
    return serviceName;
}
Also used : WebServiceProvider(jakarta.xml.ws.WebServiceProvider) QName(javax.xml.namespace.QName) ReflectAnnotationReader(com.sun.xml.ws.model.ReflectAnnotationReader) NotNull(com.sun.istack.NotNull)

Example 2 with ReflectAnnotationReader

use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.

the class EndpointFactory method getDefaultPortName.

@NotNull
public static QName getDefaultPortName(QName serviceName, Class<?> implType, boolean isStandard, MetadataReader metadataReader) {
    if (metadataReader == null) {
        metadataReader = new ReflectAnnotationReader();
    }
    QName portName;
    WebServiceProvider wsProvider = metadataReader.getAnnotation(WebServiceProvider.class, implType);
    if (wsProvider != null) {
        String tns = wsProvider.targetNamespace();
        String local = wsProvider.portName();
        portName = new QName(tns, local);
    } else {
        portName = RuntimeModeler.getPortName(implType, metadataReader, serviceName.getNamespaceURI(), isStandard);
    }
    assert portName != null;
    return portName;
}
Also used : WebServiceProvider(jakarta.xml.ws.WebServiceProvider) QName(javax.xml.namespace.QName) ReflectAnnotationReader(com.sun.xml.ws.model.ReflectAnnotationReader) NotNull(com.sun.istack.NotNull)

Example 3 with ReflectAnnotationReader

use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.

the class EndpointFactory method verifyImplementorClass.

/**
 * Verifies if the endpoint implementor class has @WebService or @WebServiceProvider
 * annotation; passing MetadataReader instance allows to read annotations from
 * xml descriptor instead of class's annotations
 *
 * @return
 *       true if it is a Provider or AsyncProvider endpoint
 *       false otherwise
 * @throws java.lang.IllegalArgumentException
 *      If it doesn't have any one of @WebService or @WebServiceProvider
 *      If it has both @WebService and @WebServiceProvider annotations
 */
public static boolean verifyImplementorClass(Class<?> clz, MetadataReader metadataReader) {
    if (metadataReader == null) {
        metadataReader = new ReflectAnnotationReader();
    }
    WebServiceProvider wsProvider = metadataReader.getAnnotation(WebServiceProvider.class, clz);
    WebService ws = metadataReader.getAnnotation(WebService.class, clz);
    if (wsProvider == null && ws == null) {
        throw new IllegalArgumentException(clz + " has neither @WebService nor @WebServiceProvider annotation");
    }
    if (wsProvider != null && ws != null) {
        throw new IllegalArgumentException(clz + " has both @WebService and @WebServiceProvider annotations");
    }
    if (wsProvider != null) {
        if (Provider.class.isAssignableFrom(clz) || AsyncProvider.class.isAssignableFrom(clz)) {
            return true;
        }
        throw new IllegalArgumentException(clz + " doesn't implement Provider or AsyncProvider interface");
    }
    return false;
}
Also used : WebServiceProvider(jakarta.xml.ws.WebServiceProvider) AsyncProvider(com.sun.xml.ws.api.server.AsyncProvider) WebService(jakarta.jws.WebService) ReflectAnnotationReader(com.sun.xml.ws.model.ReflectAnnotationReader) AsyncProvider(com.sun.xml.ws.api.server.AsyncProvider) Provider(jakarta.xml.ws.Provider) WebServiceProvider(jakarta.xml.ws.WebServiceProvider)

Example 4 with ReflectAnnotationReader

use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.

the class HandlerAnnotationProcessor method getSEI.

static Class getSEI(Class<?> clazz, MetadataReader metadataReader) {
    if (metadataReader == null) {
        metadataReader = new ReflectAnnotationReader();
    }
    if (Provider.class.isAssignableFrom(clazz) || AsyncProvider.class.isAssignableFrom(clazz)) {
        // No SEI for Provider Implementation
        return null;
    }
    if (Service.class.isAssignableFrom(clazz)) {
        // No SEI for Service class
        return null;
    }
    WebService webService = metadataReader.getAnnotation(WebService.class, clazz);
    if (webService == null) {
        throw new UtilException("util.handler.no.webservice.annotation", clazz.getCanonicalName());
    }
    String ei = webService.endpointInterface();
    if (ei.length() > 0) {
        clazz = getClass(webService.endpointInterface());
        WebService ws = metadataReader.getAnnotation(WebService.class, clazz);
        if (ws == null) {
            throw new UtilException("util.handler.endpoint.interface.no.webservice", webService.endpointInterface());
        }
        return clazz;
    }
    return null;
}
Also used : AsyncProvider(com.sun.xml.ws.api.server.AsyncProvider) WebService(jakarta.jws.WebService) ReflectAnnotationReader(com.sun.xml.ws.model.ReflectAnnotationReader) AsyncProvider(com.sun.xml.ws.api.server.AsyncProvider) Provider(jakarta.xml.ws.Provider)

Example 5 with ReflectAnnotationReader

use of com.sun.xml.ws.model.ReflectAnnotationReader in project metro-jax-ws by eclipse-ee4j.

the class HandlerAnnotationProcessor method buildHandlerInfo.

/**
 * <p>This method is called by
 * {@link EndpointFactory} when
 * they have an annotated class.
 *
 * <p>If there is no handler chain annotation on the class,
 * this method will return null. Otherwise it will load the
 * class and call the parseHandlerFile method to read the
 * information.
 *
 * @return A HandlerAnnotationInfo object that stores the
 * handlers and roles. Will return null if the class passed
 * in has no handler chain annotation.
 */
public static HandlerAnnotationInfo buildHandlerInfo(@NotNull Class<?> clazz, QName serviceName, QName portName, WSBinding binding) {
    MetadataReader metadataReader = EndpointFactory.getExternalMetadatReader(clazz, binding);
    if (metadataReader == null) {
        metadataReader = new ReflectAnnotationReader();
    }
    // clazz = checkClass(clazz);
    HandlerChain handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz);
    if (handlerChain == null) {
        clazz = getSEI(clazz, metadataReader);
        if (clazz != null)
            handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz);
        if (handlerChain == null)
            return null;
    }
    if (clazz.getAnnotation(SOAPMessageHandlers.class) != null) {
        throw new UtilException("util.handler.cannot.combine.soapmessagehandlers");
    }
    InputStream iStream = getFileAsStream(clazz, handlerChain);
    XMLStreamReader reader = XMLStreamReaderFactory.create(null, iStream, true);
    XMLStreamReaderUtil.nextElementContent(reader);
    HandlerAnnotationInfo handlerAnnInfo = HandlerChainsModel.parseHandlerFile(reader, clazz.getClassLoader(), serviceName, portName, binding);
    try {
        reader.close();
        iStream.close();
    } catch (XMLStreamException | IOException e) {
        e.printStackTrace();
        throw new UtilException(e.getMessage());
    }
    return handlerAnnInfo;
}
Also used : HandlerChain(jakarta.jws.HandlerChain) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) MetadataReader(com.sun.xml.ws.api.databinding.MetadataReader) SOAPMessageHandlers(jakarta.jws.soap.SOAPMessageHandlers) IOException(java.io.IOException) ReflectAnnotationReader(com.sun.xml.ws.model.ReflectAnnotationReader)

Aggregations

ReflectAnnotationReader (com.sun.xml.ws.model.ReflectAnnotationReader)5 WebServiceProvider (jakarta.xml.ws.WebServiceProvider)3 NotNull (com.sun.istack.NotNull)2 AsyncProvider (com.sun.xml.ws.api.server.AsyncProvider)2 WebService (jakarta.jws.WebService)2 Provider (jakarta.xml.ws.Provider)2 QName (javax.xml.namespace.QName)2 MetadataReader (com.sun.xml.ws.api.databinding.MetadataReader)1 HandlerChain (jakarta.jws.HandlerChain)1 SOAPMessageHandlers (jakarta.jws.soap.SOAPMessageHandlers)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1