Search in sources :

Example 1 with WebServiceFeatureAnnotation

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

the class WebServiceFeatureList method getWebServiceFeatureBean.

private static WebServiceFeature getWebServiceFeatureBean(Annotation a) {
    WebServiceFeatureAnnotation wsfa = a.annotationType().getAnnotation(WebServiceFeatureAnnotation.class);
    Class<? extends WebServiceFeature> beanClass = wsfa.bean();
    WebServiceFeature bean;
    Constructor ftrCtr = null;
    String[] paramNames = null;
    for (Constructor con : beanClass.getConstructors()) {
        FeatureConstructor ftrCtrAnn = (FeatureConstructor) con.getAnnotation(FeatureConstructor.class);
        if (ftrCtrAnn != null) {
            if (ftrCtr == null) {
                ftrCtr = con;
                paramNames = ftrCtrAnn.value();
            } else {
                throw new WebServiceException(ModelerMessages.RUNTIME_MODELER_WSFEATURE_MORETHANONE_FTRCONSTRUCTOR(a, beanClass));
            }
        }
    }
    if (ftrCtr == null) {
        bean = getWebServiceFeatureBeanViaBuilder(a, beanClass);
        if (bean != null) {
            return bean;
        } else {
            throw new WebServiceException(ModelerMessages.RUNTIME_MODELER_WSFEATURE_NO_FTRCONSTRUCTOR(a, beanClass));
        }
    }
    if (ftrCtr.getParameterTypes().length != paramNames.length) {
        throw new WebServiceException(ModelerMessages.RUNTIME_MODELER_WSFEATURE_ILLEGAL_FTRCONSTRUCTOR(a, beanClass));
    }
    try {
        Object[] params = new Object[paramNames.length];
        for (int i = 0; i < paramNames.length; i++) {
            Method m = a.annotationType().getDeclaredMethod(paramNames[i]);
            params[i] = m.invoke(a);
        }
        bean = (WebServiceFeature) ftrCtr.newInstance(params);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
    return bean;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) FeatureConstructor(com.sun.xml.ws.api.FeatureConstructor) Constructor(java.lang.reflect.Constructor) FeatureConstructor(com.sun.xml.ws.api.FeatureConstructor) Method(java.lang.reflect.Method) RuntimeModelerException(com.sun.xml.ws.model.RuntimeModelerException) WebServiceException(jakarta.xml.ws.WebServiceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WebServiceFeatureAnnotation(jakarta.xml.ws.spi.WebServiceFeatureAnnotation) ImpliesWebServiceFeature(com.sun.xml.ws.api.ImpliesWebServiceFeature) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) WSDLFeaturedObject(com.sun.xml.ws.api.model.wsdl.WSDLFeaturedObject)

Aggregations

FeatureConstructor (com.sun.xml.ws.api.FeatureConstructor)1 ImpliesWebServiceFeature (com.sun.xml.ws.api.ImpliesWebServiceFeature)1 WSDLFeaturedObject (com.sun.xml.ws.api.model.wsdl.WSDLFeaturedObject)1 RuntimeModelerException (com.sun.xml.ws.model.RuntimeModelerException)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)1 WebServiceFeatureAnnotation (jakarta.xml.ws.spi.WebServiceFeatureAnnotation)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1