Search in sources :

Example 1 with WebServiceProvider

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

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

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

use of jakarta.xml.ws.WebServiceProvider in project metro-jax-ws by eclipse-ee4j.

the class WebServiceAp method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (context.getRound() != 1) {
        return true;
    }
    context.incrementRound();
    WebService webService;
    WebServiceProvider webServiceProvider;
    WebServiceVisitor webServiceVisitor = new WebServiceWrapperGenerator(this, context);
    boolean processedEndpoint = false;
    Collection<TypeElement> classes = new ArrayList<>();
    filterClasses(classes, roundEnv.getRootElements());
    for (TypeElement element : classes) {
        webServiceProvider = element.getAnnotation(WebServiceProvider.class);
        webService = element.getAnnotation(WebService.class);
        if (webServiceProvider != null) {
            if (webService != null) {
                processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_AND_WEBSERVICEPROVIDER(element.getQualifiedName()));
            }
            processedEndpoint = true;
        }
        if (webService == null) {
            continue;
        }
        element.accept(webServiceVisitor, null);
        processedEndpoint = true;
    }
    if (!processedEndpoint) {
        if (isCommandLineInvocation) {
            if (!ignoreNoWebServiceFoundWarning) {
                processWarning(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
            }
        } else {
            processError(WebserviceapMessages.WEBSERVICEAP_NO_WEBSERVICE_ENDPOINT_FOUND());
        }
    }
    return true;
}
Also used : WebServiceProvider(jakarta.xml.ws.WebServiceProvider) WebService(jakarta.jws.WebService) TypeElement(javax.lang.model.element.TypeElement) ArrayList(java.util.ArrayList)

Aggregations

WebServiceProvider (jakarta.xml.ws.WebServiceProvider)4 ReflectAnnotationReader (com.sun.xml.ws.model.ReflectAnnotationReader)3 NotNull (com.sun.istack.NotNull)2 WebService (jakarta.jws.WebService)2 QName (javax.xml.namespace.QName)2 AsyncProvider (com.sun.xml.ws.api.server.AsyncProvider)1 Provider (jakarta.xml.ws.Provider)1 ArrayList (java.util.ArrayList)1 TypeElement (javax.lang.model.element.TypeElement)1