Search in sources :

Example 1 with AsyncProvider

use of com.sun.xml.ws.api.server.AsyncProvider 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)

Aggregations

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