Search in sources :

Example 26 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class JavaFirstUtil method serviceInfo2JavaInf.

public static JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
    JavaInterface javaInf = new JavaInterface();
    InterfaceInfo inf = service.getInterface();
    for (OperationInfo op : inf.getOperations()) {
        JavaMethod jm = new JavaMethod();
        Method m = (Method) op.getProperty(ReflectionServiceFactoryBean.METHOD);
        jm.setName(m.getName());
        int i = 0;
        for (Type type : m.getGenericParameterTypes()) {
            JavaParameter jp = new JavaParameter();
            jp.setClassName(getClassName(type));
            jp.setStyle(Style.IN);
            jp.setName("arg" + i++);
            jm.addParameter(jp);
        }
        for (Type type : m.getGenericExceptionTypes()) {
            JavaException jex = new JavaException();
            String className = getClassName(type);
            jex.setClassName(className);
            jex.setName(className);
            jm.addException(jex);
        }
        JavaReturn jreturn = new JavaReturn();
        jreturn.setClassName(getClassName(m.getGenericReturnType()));
        jreturn.setStyle(Style.OUT);
        jm.setReturn(jreturn);
        String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
        javaInf.setPackageName(pkg.length() == 0 ? ToolConstants.DEFAULT_PACKAGE_NAME : pkg);
        javaInf.addMethod(jm);
        javaInf.setName(inf.getName().getLocalPart());
        jm.getParameterList();
    }
    return javaInf;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaReturn(org.apache.cxf.tools.common.model.JavaReturn) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) GenericArrayType(java.lang.reflect.GenericArrayType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) JavaException(org.apache.cxf.tools.common.model.JavaException) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) Method(java.lang.reflect.Method)

Example 27 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class AntGenerator method generate.

public void generate(ToolContext penv) throws ToolException {
    this.env = penv;
    if (passthrough()) {
        return;
    }
    JavaModel javaModel = env.get(JavaModel.class);
    Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
    Map<String, String> serverClassNamesMap = new HashMap<>();
    Map<String, String> clientClassNamesMap = new HashMap<>();
    for (JavaInterface intf : interfaces.values()) {
        clientClassNamesMap.put(intf.getName() + "Client", intf.getFullClassName() + "Client");
        serverClassNamesMap.put(intf.getName() + "Server", intf.getFullClassName() + "Server");
    }
    clearAttributes();
    setAttributes("clientClassNamesMap", clientClassNamesMap);
    setAttributes("serverClassNamesMap", serverClassNamesMap);
    setAttributes("srcdir", penv.get(ToolConstants.CFG_SOURCEDIR));
    setAttributes("clsdir", penv.get(ToolConstants.CFG_CLASSDIR));
    setAttributes("classpath", penv.get(ToolConstants.CFG_CLASSPATH));
    setAttributes("classpath", penv.get(ToolConstants.CFG_CLASSPATH));
    setCommonAttributes();
    doWrite(BUILD_TEMPLATE, parseOutputName(null, "build", ".xml"));
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) HashMap(java.util.HashMap) JavaModel(org.apache.cxf.tools.common.model.JavaModel)

Example 28 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class JAXWSFrontEndProcessor method serviceInfo2JavaInf.

public JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
    JavaInterface javaInf = new JavaInterface();
    InterfaceInfo inf = service.getInterface();
    for (OperationInfo op : inf.getOperations()) {
        JavaMethod jm = new JavaMethod();
        Method m = (Method) op.getProperty(ReflectionServiceFactoryBean.METHOD);
        jm.setName(m.getName());
        int i = 0;
        for (Type type : m.getGenericParameterTypes()) {
            JavaParameter jp = new JavaParameter();
            jp.setClassName(getClassName(type));
            jp.setStyle(Style.IN);
            jp.setName("arg" + i++);
            jm.addParameter(jp);
        }
        for (Type type : m.getGenericExceptionTypes()) {
            JavaException jex = new JavaException();
            String className = getClassName(type);
            jex.setClassName(className);
            jex.setName(className);
            jm.addException(jex);
        }
        JavaReturn jreturn = new JavaReturn();
        jreturn.setClassName(getClassName(m.getGenericReturnType()));
        jreturn.setStyle(Style.OUT);
        jm.setReturn(jreturn);
        String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
        javaInf.setPackageName(pkg.length() > 0 ? pkg : ToolConstants.DEFAULT_PACKAGE_NAME);
        javaInf.addMethod(jm);
        javaInf.setName(inf.getName().getLocalPart());
        jm.getParameterList();
    }
    return javaInf;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaReturn(org.apache.cxf.tools.common.model.JavaReturn) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) GenericArrayType(java.lang.reflect.GenericArrayType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) JavaException(org.apache.cxf.tools.common.model.JavaException) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Method(java.lang.reflect.Method) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod)

Example 29 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class JaxwsImplGenerator method generate.

public void generate(ToolContext penv) throws ToolException {
    this.env = penv;
    JavaModel javaModel = env.get(JavaModel.class);
    if (passthrough()) {
        return;
    }
    Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
    QName service = (QName) env.get(ToolConstants.SERVICE_NAME);
    for (JavaInterface intf : interfaces.values()) {
        clearAttributes();
        setAttributes("intf", intf);
        setAttributes("service", service);
        setCommonAttributes();
        doWrite(IMPL_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName() + "Impl"));
        env.put(ToolConstants.IMPL_CLASS, intf.getFullClassName() + "Impl");
    }
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) QName(javax.xml.namespace.QName) JavaModel(org.apache.cxf.tools.common.model.JavaModel)

Example 30 with JavaInterface

use of org.apache.cxf.tools.common.model.JavaInterface in project cxf by apache.

the class JaxwsSEIGenerator method generate.

public void generate(ToolContext penv) throws ToolException {
    this.env = penv;
    JavaModel javaModel = env.get(JavaModel.class);
    if (passthrough()) {
        return;
    }
    Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
    for (JavaInterface intf : interfaces.values()) {
        clearAttributes();
        setAttributes("intf", intf);
        setCommonAttributes();
        doWrite(SEI_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName()));
        env.put(ToolConstants.SEI_CLASS, intf.getFullClassName());
    }
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JavaModel(org.apache.cxf.tools.common.model.JavaModel)

Aggregations

JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)33 JavaModel (org.apache.cxf.tools.common.model.JavaModel)20 QName (javax.xml.namespace.QName)11 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)8 JavaMethod (org.apache.cxf.tools.common.model.JavaMethod)7 ArrayList (java.util.ArrayList)6 Message (org.apache.cxf.common.i18n.Message)6 JAnnotation (org.apache.cxf.tools.common.model.JAnnotation)6 JAnnotationElement (org.apache.cxf.tools.common.model.JAnnotationElement)6 JavaPort (org.apache.cxf.tools.common.model.JavaPort)6 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)5 JavaException (org.apache.cxf.tools.common.model.JavaException)5 JavaServiceClass (org.apache.cxf.tools.common.model.JavaServiceClass)5 OperationInfo (org.apache.cxf.service.model.OperationInfo)4 ToolContext (org.apache.cxf.tools.common.ToolContext)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 ToolException (org.apache.cxf.tools.common.ToolException)3 JAXWSBinding (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)3 GenericArrayType (java.lang.reflect.GenericArrayType)2