Search in sources :

Example 6 with JavaReturn

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

the class ParameterProcessor method getReturnFromQName.

private JavaReturn getReturnFromQName(QName element, MessagePartInfo part) {
    String fullJavaName = "";
    String simpleJavaName = "";
    fullJavaName = this.dataBinding.getWrappedElementType(part.getElementQName(), element);
    simpleJavaName = fullJavaName;
    int index = fullJavaName.lastIndexOf(".");
    if (index > -1) {
        simpleJavaName = fullJavaName.substring(index);
    }
    String targetNamespace = "";
    if (isHeader(part)) {
        targetNamespace = part.getMessageInfo().getOperation().getInterface().getService().getTargetNamespace();
    } else {
        targetNamespace = element.getNamespaceURI();
    }
    String jpname = ProcessorUtil.mangleNameToVariableName(simpleJavaName);
    JavaReturn returnType = new JavaReturn(jpname, fullJavaName, targetNamespace);
    returnType.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriterForWrappedElement(part, context, element));
    returnType.setQName(element);
    returnType.setStyle(JavaType.Style.OUT);
    return returnType;
}
Also used : JavaReturn(org.apache.cxf.tools.common.model.JavaReturn)

Example 7 with JavaReturn

use of org.apache.cxf.tools.common.model.JavaReturn 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 8 with JavaReturn

use of org.apache.cxf.tools.common.model.JavaReturn 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)

Aggregations

JavaReturn (org.apache.cxf.tools.common.model.JavaReturn)8 JavaParameter (org.apache.cxf.tools.common.model.JavaParameter)5 JavaMethod (org.apache.cxf.tools.common.model.JavaMethod)4 GenericArrayType (java.lang.reflect.GenericArrayType)2 Method (java.lang.reflect.Method)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)2 OperationInfo (org.apache.cxf.service.model.OperationInfo)2 JAnnotation (org.apache.cxf.tools.common.model.JAnnotation)2 JavaException (org.apache.cxf.tools.common.model.JavaException)2 JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)2 WebMethodAnnotator (org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebMethodAnnotator)2 QName (javax.xml.namespace.QName)1 Message (org.apache.cxf.common.i18n.Message)1 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)1 ToolException (org.apache.cxf.tools.common.ToolException)1 JAnnotationElement (org.apache.cxf.tools.common.model.JAnnotationElement)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)1