Search in sources :

Example 6 with JavaClass

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

the class WrapperTest method testGetWrapperBeanClassFromMethod.

@Test
public void testGetWrapperBeanClassFromMethod() throws Exception {
    String pkgName = "org.apache.cxf.tools.fortest.classnoanno.docwrapped";
    Class<?> stockClass = Class.forName(pkgName + ".Stock");
    Method method = stockClass.getMethod("getPrice", String.class);
    Wrapper wrapper = new Wrapper();
    wrapper.setMethod(method);
    JavaClass jClass = wrapper.getWrapperBeanClass(method);
    assertNotNull(jClass);
    assertNull(jClass.getPackageName());
    assertNull(jClass.getName());
    wrapper = new RequestWrapper();
    jClass = wrapper.getWrapperBeanClass(method);
    assertEquals("GetPrice", jClass.getName());
    assertEquals(pkgName + ".jaxws", jClass.getPackageName());
    wrapper = new ResponseWrapper();
    jClass = wrapper.getWrapperBeanClass(method);
    assertEquals("GetPriceResponse", jClass.getName());
    assertEquals(pkgName + ".jaxws", jClass.getPackageName());
}
Also used : JavaClass(org.apache.cxf.tools.common.model.JavaClass) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 7 with JavaClass

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

the class FaultBeanGenerator method generateBeanClasses.

protected Collection<JavaClass> generateBeanClasses(final ServiceInfo serviceInfo) {
    Set<Class<?>> exceptionClasses = new HashSet<>();
    String seiPackageName = null;
    for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
        Method method = (Method) op.getProperty("operation.method");
        exceptionClasses.addAll(getExceptionClasses(method));
        seiPackageName = getSEIPackage(method);
    }
    Collection<JavaClass> faultBeanClasses = new HashSet<>();
    String defaultPackage = seiPackageName + ".jaxws";
    FaultBean bean = new FaultBean();
    for (Class<?> clz : exceptionClasses) {
        if (!bean.faultBeanExists(clz)) {
            faultBeanClasses.add(bean.transform(clz, defaultPackage));
        }
    }
    return faultBeanClasses;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaClass(org.apache.cxf.tools.common.model.JavaClass) JavaClass(org.apache.cxf.tools.common.model.JavaClass) Method(java.lang.reflect.Method) FaultBean(org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.FaultBean) HashSet(java.util.HashSet)

Example 8 with JavaClass

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

the class WrapperBeanGenerator method generateBeanClasses.

protected Collection<JavaClass> generateBeanClasses(final ServiceInfo serviceInfo) {
    Collection<JavaClass> wrapperClasses = new HashSet<>();
    for (OperationInfo op : serviceInfo.getInterface().getOperations()) {
        if (op.getUnwrappedOperation() != null) {
            if (op.hasInput()) {
                RequestWrapper requestWrapper = new RequestWrapper();
                requestWrapper.setOperationInfo(op);
                JavaClass jClass = requestWrapper.buildWrapperBeanClass();
                if (requestWrapper.isWrapperBeanClassNotExist()) {
                    wrapperClasses.add(jClass);
                }
            }
            if (op.hasOutput()) {
                ResponseWrapper responseWrapper = new ResponseWrapper();
                responseWrapper.setOperationInfo(op);
                JavaClass jClass = responseWrapper.buildWrapperBeanClass();
                if (responseWrapper.isWrapperBeanClassNotExist()) {
                    wrapperClasses.add(jClass);
                }
            }
        }
    }
    return wrapperClasses;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaClass(org.apache.cxf.tools.common.model.JavaClass) RequestWrapper(org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.RequestWrapper) ResponseWrapper(org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.ResponseWrapper) HashSet(java.util.HashSet)

Aggregations

JavaClass (org.apache.cxf.tools.common.model.JavaClass)8 Test (org.junit.Test)4 OperationInfo (org.apache.cxf.service.model.OperationInfo)3 File (java.io.File)2 Method (java.lang.reflect.Method)2 HashSet (java.util.HashSet)2 JavaField (org.apache.cxf.tools.common.model.JavaField)2 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 Compiler (org.apache.cxf.common.util.Compiler)1 VelocityGenerator (org.apache.cxf.tools.common.VelocityGenerator)1 JAnnotation (org.apache.cxf.tools.common.model.JAnnotation)1 JavaMethod (org.apache.cxf.tools.common.model.JavaMethod)1 FaultBean (org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.FaultBean)1 RequestWrapper (org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.RequestWrapper)1 ResponseWrapper (org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.ResponseWrapper)1 FileWriterUtil (org.apache.cxf.tools.util.FileWriterUtil)1