Package org.apache.cxf.tools.common.model

Examples of org.apache.cxf.tools.common.model.JavaMethod


import org.apache.cxf.tools.util.SOAPBindingUtil;

public class SoapBindingAnnotator implements Annotator {

    public void annotate(JavaAnnotatable ja) {
        JavaMethod method;
        if (ja instanceof JavaMethod) {
            method = (JavaMethod) ja;
        } else {
            throw new RuntimeException("SOAPBindingAnnotator can only annotate JavaMethod");
        }
        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
            if (!method.isWrapperStyle()
                && !SOAPBinding.ParameterStyle.BARE.equals(method.getInterface().getSOAPParameterStyle())) {
           
                JavaAnnotation bindingAnnotation = new JavaAnnotation("SOAPBinding");
                bindingAnnotation.addArgument("parameterStyle",
                                              SOAPBindingUtil.getBindingAnnotation("BARE"), "");
                method.addAnnotation("SOAPBinding", bindingAnnotation);
            } else if (method.isWrapperStyle()
                && SOAPBinding.ParameterStyle.BARE.equals(method.getInterface().getSOAPParameterStyle())) {
                JavaAnnotation bindingAnnotation = new JavaAnnotation("SOAPBinding");
                bindingAnnotation.addArgument("parameterStyle",
                                              SOAPBindingUtil.getBindingAnnotation("WRAPPED"), "");
                method.addAnnotation("SOAPBinding", bindingAnnotation);               
            }
        }
    }
View Full Code Here


        if (ja instanceof JavaParameter) {
            parameter = (JavaParameter) ja;
        } else {
            throw new RuntimeException("WebParamAnnotator only annotate the JavaParameter");
        }
        JavaMethod method = parameter.getMethod();
        JavaAnnotation webParamAnnotation = new JavaAnnotation("WebParam");
        String name = parameter.getName();
        String targetNamespace = method.getInterface().getNamespace();
        String partName = null;

        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT
            || parameter.isHeader()) {
            targetNamespace = parameter.getTargetNamespace();
            if (parameter.getQName() != null) {
                name = parameter.getQName().getLocalPart();
            }
            if (!method.isWrapperStyle()) {
                partName = parameter.getPartName();
            }
        }

        if (method.getSoapStyle() == SOAPBinding.Style.RPC) {
            name = parameter.getPartName();
            partName = parameter.getPartName();
        }

        if (partName != null) {
            webParamAnnotation.addArgument("partName", partName);
        }
        if (parameter.getStyle() == JavaType.Style.OUT || parameter.getStyle() == JavaType.Style.INOUT) {
            webParamAnnotation.addArgument("mode", "Mode." + parameter.getStyle().toString(), "");
        }
        webParamAnnotation.addArgument("name", name);
        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT || parameter.isHeader()) {
            webParamAnnotation.addArgument("targetNamespace", targetNamespace);
        }

        parameter.setAnnotation(webParamAnnotation);
    }
View Full Code Here

            jf.setSOAPStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
        }

        Object[] methods = jf.getMethods().toArray();
        for (int i = 0; i < methods.length; i++) {
            JavaMethod jm = (JavaMethod)methods[i];
            if (jm.getOperationName() != null && jm.getOperationName().equals(bop.getName().getLocalPart())) {
                if (isSoapBinding()) {
                    // TODO: add customize here
                    //doCustomizeOperation(jf, jm, bop);
                    Map prop = getSoapOperationProp(bop);
                    String soapAction = prop.get(soapOPAction) == null ? "" : (String)prop.get(soapOPAction);
                    String soapStyle = prop.get(soapOPStyle) == null ? "" : (String)prop.get(soapOPStyle);
                    jm.setSoapAction(soapAction);
                    if (SOAPBindingUtil.getSoapStyle(soapStyle) == null && this.bindingObj == null) {
                        org.apache.cxf.common.i18n.Message msg =
                            new  org.apache.cxf.common.i18n.Message("BINDING_STYLE_NOT_DEFINED",
                                                                         LOG);
                        throw new ToolException(msg);
                    }
                    if (SOAPBindingUtil.getSoapStyle(soapStyle) == null) {
                        jm.setSoapStyle(jf.getSOAPStyle());
                    } else {
                        jm.setSoapStyle(SOAPBindingUtil.getSoapStyle(soapStyle));
                    }
                } else {
                    // REVISIT: fix for xml binding
                    jm.setSoapStyle(jf.getSOAPStyle());
                }

                if (jm.getSoapStyle().equals(javax.jws.soap.SOAPBinding.Style.RPC)) {
                    jm.getAnnotationMap().remove("SOAPBinding");
                }

                OperationProcessor processor = new OperationProcessor(context);

                int headerType = isNonWrappable(bop);

                OperationInfo opinfo = bop.getOperationInfo();
               
                JAXWSBinding opBinding = (JAXWSBinding)opinfo.getExtensor(JAXWSBinding.class);
               
                if (opBinding != null && !opBinding.isEnableWrapperStyle()) {
                    jaxwsBinding.setEnableWrapperStyle(false);
                    if (!opBinding.isEnableAsyncMapping()) {
                        jaxwsBinding.setEnableAsyncMapping(false);
                    }
                }
                               
                if (jm.isWrapperStyle() && headerType > this.noHEADER
                    || !jaxwsBinding.isEnableWrapperStyle()) {
                    // changed wrapper style

                    jm.setWrapperStyle(false);
                    processor.processMethod(jm, bop.getOperationInfo(), jaxwsBinding);
                    jm.getAnnotationMap().remove("ResponseWrapper");
                    jm.getAnnotationMap().remove("RequestWrapper");

                } else {
                    processor.processMethod(jm, bop.getOperationInfo(), jaxwsBinding);

                }

                if (headerType == this.resultHeader) {
                    JavaAnnotation resultAnno = jm.getAnnotationMap().get("WebResult");
                    if (resultAnno != null) {
                        resultAnno.addArgument("header", "true", "");
                    }
                }
                processParameter(jm, bop);
View Full Code Here

        WebMethod webMethod = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
        if (webMethod != null && webMethod.exclude()) {
            return;
        }

        JavaMethod javaMethod = new JavaMethod();

        // rule 3.5

        String operationName = method.getName();

        if (!method.getDeclaringClass().equals(seiClass)) {
            try {
                Method tmp = seiClass.getMethod(method.getName(), (Class[])method.getParameterTypes());
                operationName = tmp.getName();
            } catch (NoSuchMethodException e) {
                throw new ToolException(e.getMessage(), e);
            }
        }

        if (webMethod != null) {
            operationName = webMethod.operationName().length() > 0
                ? webMethod.operationName() : operationName;
            javaMethod.setSoapAction(webMethod.action());
        }
        javaMethod.setName(operationName);
       
      
        //process aysnMethod
        if (isAsynMethod(method)) {
            return;
        }
       
        if (isOneWayMethod(method)) {
            javaMethod.setStyle(OperationType.ONE_WAY);
        } else {
            javaMethod.setStyle(OperationType.REQUEST_RESPONSE);
        }

        switch (getMethodType(method)) {
        case WSDLConstants.DOC_BARE:
            DocBareMethodProcessor docBareProcessor = new DocBareMethodProcessor(model);
View Full Code Here

import org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtil;

public final class MethodMapper {
   
    public JavaMethod map(OperationInfo operation) {
        JavaMethod method = new JavaMethod();
        // set default Document Bare style
        method.setSoapStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);

        String operationName = operation.getName().getLocalPart();

        method.setName(ProcessorUtil.mangleNameToVariableName(operationName));
        method.setOperationName(operationName);
       
        JAXWSBinding opBinding = operation.getExtensor(JAXWSBinding.class);
        if (opBinding != null
            && opBinding.getMethodName() != null) {
            method.setName(opBinding.getMethodName());
        }


        if (operation.isOneWay()) {
            method.setStyle(OperationType.ONE_WAY);
        } else {
            method.setStyle(OperationType.REQUEST_RESPONSE);
        }
       
        method.setWrapperStyle(operation.isUnwrappedCapable());

        return method;
    }
View Full Code Here

            assertEquals("Greeter", intf.getName());
            assertEquals("org.apache.hello_world_soap_http", intf.getPackageName());

            List<JavaMethod> methods = intf.getMethods();
            assertEquals(6, methods.size());
            JavaMethod m1 = methods.get(0);
            assertEquals("testDocLitFault", m1.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

            assertEquals("Greeter", intf.getName());
            assertEquals("org.apache.hello_world_soap_http", intf.getPackageName());

            List<JavaMethod> methods = intf.getMethods();
            assertEquals(6, methods.size());
            JavaMethod m1 = methods.get(0);
            assertEquals("testDocLitFault", m1.getName());

            assertEquals(2, m1.getExceptions().size());
            assertEquals("BadRecordLitFault", m1.getExceptions().get(0).getName());
            assertEquals("NoSuchCodeLitFault", m1.getExceptions().get(1).getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

        operation.setName(new QName("urn:test:ns", "OperationTest"));
        return operation;
    }
   
    public void testMap() throws Exception {
        JavaMethod method = new MethodMapper().map(getOperation());
        assertNotNull(method);

        assertEquals(javax.jws.soap.SOAPBinding.Style.DOCUMENT, method.getSoapStyle());
        assertEquals("operationTest", method.getName());
        assertEquals("OperationTest", method.getOperationName());
        assertEquals(OperationType.REQUEST_RESPONSE, method.getStyle());
        assertFalse(method.isWrapperStyle());
        assertFalse(method.isOneWay());
    }
View Full Code Here

        OperationInfo operation = getOperation();

        MessageInfo inputMessage = operation.createMessage(new QName("urn:test:ns", "testInputMessage"));
        operation.setInput("input", inputMessage);

        JavaMethod method = new MethodMapper().map(operation);
        assertNotNull(method);
        assertTrue(method.isOneWay());
    }
View Full Code Here

    public void testMapWrappedOperation() throws Exception {
        OperationInfo operation = getOperation();
        operation.setUnwrappedOperation(operation);

        JavaMethod method = new MethodMapper().map(operation);
        assertNotNull(method);
       
        assertTrue(method.isWrapperStyle());
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.tools.common.model.JavaMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.