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

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


    @Test
    public void testAnnotateRPC() throws Exception {
        init(method, parameter, SOAPBinding.Style.RPC, true);
        parameter.annotate(new WebParamAnnotator());
        JAnnotation annotation = parameter.getAnnotation();
        assertEquals(2, annotation.getElements().size());
        assertEquals("@WebParam(partName = \"y\", name = \"y\")",
                     annotation.toString());
    }
View Full Code Here


        if (ja instanceof JavaInterface) {
            intf = (JavaInterface) ja;
        } else {
            throw new RuntimeException("WebService can only annotate JavaInterface");
        }
        JAnnotation serviceAnnotation = new JAnnotation(WebService.class);
        serviceAnnotation.addElement(new JAnnotationElement("targetNamespace",
                                                                   intf.getNamespace()));
        serviceAnnotation.addElement(new JAnnotationElement("name", intf.getWebServiceName()));
       
        intf.addAnnotation(serviceAnnotation);
    }
View Full Code Here

        }
        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
            if (!method.isWrapperStyle()
                && !SOAPBinding.ParameterStyle.BARE.equals(method.getInterface().getSOAPParameterStyle())) {
           
                JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
                bindingAnnotation.addElement(new JAnnotationElement("parameterStyle",
                                                                           SOAPBinding.ParameterStyle.BARE));
                method.addAnnotation("SOAPBinding", bindingAnnotation);
            } else if (method.isWrapperStyle()
                && SOAPBinding.ParameterStyle.BARE.equals(method.getInterface().getSOAPParameterStyle())) {
                JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
                bindingAnnotation.addElement(new JAnnotationElement("parameterStyle",
                                                                        SOAPBinding.ParameterStyle.WRAPPED));
                method.addAnnotation("SOAPBinding", bindingAnnotation);               
            }
        } else if (!SOAPBinding.Style.RPC.equals(method.getInterface().getSOAPStyle())) {
            JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
            bindingAnnotation.addElement(new JAnnotationElement("style",
                                                                       SOAPBinding.Style.RPC));
            method.addAnnotation("SOAPBinding", bindingAnnotation);           
        }
    }
View Full Code Here

            if (paramInList.isIN() && parameter.isOUT()) {
                parameter.setStyle(JavaType.Style.INOUT);
            }
        }

        JAnnotation webParamAnnotation = new JAnnotation(WebParam.class);
        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.addElement(new JAnnotationElement("partName", partName));
        }
        if (parameter.getStyle() == JavaType.Style.OUT) {
            webParamAnnotation.addElement(new JAnnotationElement("mode", WebParam.Mode.OUT));
        } else if (parameter.getStyle() == JavaType.Style.INOUT) {
            webParamAnnotation.addElement(new JAnnotationElement("mode", WebParam.Mode.INOUT));
        }
        webParamAnnotation.addElement(new JAnnotationElement("name", name));
        if (null != targetNamespace
                && (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT || parameter.isHeader())) {       
            webParamAnnotation.addElement(new JAnnotationElement("targetNamespace",
                                                                        targetNamespace));       
        }

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

            method = (JavaMethod) ja;
        } else {
            throw new RuntimeException("RequestWrapper and ResponseWrapper can only annotate JavaMethod");
        }
        if (wrapperRequest != null) {
            JAnnotation requestAnnotation = new JAnnotation(RequestWrapper.class);
            requestAnnotation.addElement(new JAnnotationElement("localName",
                                                                       wrapperRequest.getType()));
            requestAnnotation.addElement(new JAnnotationElement("targetNamespace",
                                                                       wrapperRequest.getTargetNamespace()));
            requestAnnotation.addElement(new JAnnotationElement("className",
                                                                       wrapperRequest.getClassName()));

            method.addAnnotation("RequestWrapper", requestAnnotation);
            method.getInterface().addImports(requestAnnotation.getImports());
        }
        if (wrapperResponse != null) {
            List<JAnnotationElement> elements = new ArrayList<JAnnotationElement>();
            elements.add(new JAnnotationElement("localName", wrapperResponse.getType()));
            elements.add(new JAnnotationElement("targetNamespace", wrapperResponse.getTargetNamespace()));
            elements.add(new JAnnotationElement("className", wrapperResponse.getClassName()));

            JAnnotation responseAnnotation = new JAnnotation(ResponseWrapper.class);
            responseAnnotation.getElements().addAll(elements);
            method.addAnnotation("ResponseWrapper", responseAnnotation);
            method.getInterface().addImports(responseAnnotation.getImports());
        }
    }
View Full Code Here

        } else {
            throw new RuntimeException("WebResult can only annotate JavaMethod");
        }
           
        if (method.isOneWay()) {
            JAnnotation oneWayAnnotation = new JAnnotation(Oneway.class);
            method.addAnnotation("Oneway", oneWayAnnotation);
            return;
        }

        if ("void".equals(method.getReturn().getType())) {
            return;
        }
        JAnnotation resultAnnotation = new JAnnotation(WebResult.class);
        String targetNamespace = method.getReturn().getTargetNamespace();
        String name = "return";

        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT && !method.isWrapperStyle()) {
            name = method.getName() + "Response";
        }

        if (method.getSoapStyle() == SOAPBinding.Style.RPC) {
            name = method.getReturn().getName();
            targetNamespace = method.getInterface().getNamespace();
          
        }
        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
            if (method.getReturn().getQName() != null) {
                name = method.getReturn().getQName().getLocalPart();
            }
            targetNamespace = method.getReturn().getTargetNamespace();
        }

       
        resultAnnotation.addElement(new JAnnotationElement("name", name));
        if (null != targetNamespace) {
            resultAnnotation.addElement(new JAnnotationElement("targetNamespace", targetNamespace));
        }

        if (method.getSoapStyle() == SOAPBinding.Style.RPC
            || (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT && !method.isWrapperStyle())) {
            resultAnnotation.addElement(new JAnnotationElement("partName",
                                                                      method.getReturn().getName()));
        }

        method.addAnnotation("WebResult", resultAnnotation);
        method.getInterface().addImport("javax.jws.WebResult");
View Full Code Here

        } else {
            throw new RuntimeException("BindingAnnotator can only annotate JavaInterface");
        }
       
        if (processBinding(intf)) {
            JAnnotation bindingAnnotation = new JAnnotation(SOAPBinding.class);
            if (!SOAPBinding.Style.DOCUMENT.equals(intf.getSOAPStyle())) {
                bindingAnnotation.addElement(new JAnnotationElement("style",
                                                                    intf.getSOAPStyle()));
            }
            if (!SOAPBinding.Use.LITERAL.equals(intf.getSOAPUse())) {
                bindingAnnotation.addElement(new JAnnotationElement("use", intf.getSOAPUse()));
            }           
            if (intf.getSOAPStyle() == SOAPBinding.Style.DOCUMENT
                && intf.getSOAPParameterStyle() != SOAPBinding.ParameterStyle.WRAPPED) {
                bindingAnnotation.addElement(new JAnnotationElement("parameterStyle",
                                                                     intf.getSOAPParameterStyle()));
            }
            intf.addAnnotation(bindingAnnotation);
        }
       
View Full Code Here

            beanClass = (WrapperBeanClass) clz;
        } else {
            throw new RuntimeException("WrapperBeanAnnotator expect JavaClass as input");
        }

        JAnnotation xmlRootElement = new JAnnotation(XmlRootElement.class);
        xmlRootElement.addElement(new JAnnotationElement("name",
                                                         beanClass.getElementName().getLocalPart()));
        xmlRootElement.addElement(new JAnnotationElement("namespace",
                                                         beanClass.getElementName().getNamespaceURI()));
       
        JAnnotation xmlAccessorType = new JAnnotation(XmlAccessorType.class);
        xmlAccessorType.addElement(new JAnnotationElement(null, XmlAccessType.FIELD));

        JAnnotation xmlType = new JAnnotation(XmlType.class);
        xmlType.addElement(new JAnnotationElement("name",
                                                  beanClass.getElementName().getLocalPart()));
        xmlType.addElement(new JAnnotationElement("namespace",
                                                  beanClass.getElementName().getNamespaceURI()));
       
        // Revisit: why annotation is string?
        beanClass.addAnnotation(xmlRootElement);
        beanClass.addAnnotation(xmlAccessorType);
View Full Code Here

        asyncHandler.setClassName(getAsyncClassName(method, "AsyncHandler"));
        asyncHandler.setStyle(JavaType.Style.IN);
       
        callbackMethod.addParameter(asyncHandler);
       
        JAnnotation asyncHandlerAnnotation = new JAnnotation(WebParam.class);
        asyncHandlerAnnotation.addElement(new JAnnotationElement("name", "asyncHandler"));
        asyncHandlerAnnotation.addElement(new JAnnotationElement("targetNamespace", ""));
        asyncHandler.addAnnotation("WebParam", asyncHandlerAnnotation);               

        method.getInterface().addMethod(callbackMethod);
    }
View Full Code Here

                    processor.processMethod(jm, bop.getOperationInfo());

                }

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

TOP

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

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.