Search in sources :

Example 1 with Provider

use of jakarta.xml.ws.Provider 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 2 with Provider

use of jakarta.xml.ws.Provider 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)

Aggregations

AsyncProvider (com.sun.xml.ws.api.server.AsyncProvider)2 ReflectAnnotationReader (com.sun.xml.ws.model.ReflectAnnotationReader)2 WebService (jakarta.jws.WebService)2 Provider (jakarta.xml.ws.Provider)2 WebServiceProvider (jakarta.xml.ws.WebServiceProvider)1