Search in sources :

Example 1 with FeatureConstructor

use of com.sun.xml.ws.api.FeatureConstructor in project Payara by payara.

the class WebServiceReferenceManagerImpl method getWebServiceFeatureBean.

private 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) {
        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(javax.xml.ws.WebServiceException) FeatureConstructor(com.sun.xml.ws.api.FeatureConstructor) FeatureConstructor(com.sun.xml.ws.api.FeatureConstructor) NamingException(javax.naming.NamingException) PrivilegedActionException(java.security.PrivilegedActionException) WebServiceException(javax.xml.ws.WebServiceException) WebServiceFeatureAnnotation(javax.xml.ws.spi.WebServiceFeatureAnnotation) WebServiceFeature(javax.xml.ws.WebServiceFeature)

Aggregations

FeatureConstructor (com.sun.xml.ws.api.FeatureConstructor)1 PrivilegedActionException (java.security.PrivilegedActionException)1 NamingException (javax.naming.NamingException)1 WebServiceException (javax.xml.ws.WebServiceException)1 WebServiceFeature (javax.xml.ws.WebServiceFeature)1 WebServiceFeatureAnnotation (javax.xml.ws.spi.WebServiceFeatureAnnotation)1