Examples of JAnnotationUse


Examples of com.sun.codemodel.JAnnotationUse

   
   

    protected void annotateReturnType(JMethod method, MessagePartInfo returnPart)
    {
        JAnnotationUse wrAnn = method.annotate(WebResult.class);
       
        wrAnn.param("name", returnPart.getName().getLocalPart());
        wrAnn.param("targetNamespace", returnPart.getName().getNamespaceURI());
    }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

{

    protected JClass generateExceptionClass(MessagePartInfo part, JCodeModel model, JType paramType, JDefinedClass exCls)
    {
        exCls._extends(Exception.class);
        JAnnotationUse webFaultAnn = exCls.annotate(WebFault.class);
        webFaultAnn.param("name", part.getName().getLocalPart());
        webFaultAnn.param("targetNamespace", part.getName().getNamespaceURI());
       
        exCls.field(JMod.PRIVATE, paramType, "faultInfo");
       
        JMethod getFaultInfo = exCls.method(JMod.PUBLIC, paramType, "getFaultInfo");
        getFaultInfo.body()._return(JExpr.ref("faultInfo"));
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

       
        JDefinedClass servCls = model._class(portName);
        servCls._extends(javax.xml.ws.Service.class);
       
        String wsdlUrl = context.getWsdlLocation();
        JAnnotationUse clientAnn = servCls.annotate(WebServiceClient.class);
        clientAnn.param("targetNamespace", ns);
        clientAnn.param("name", name);
        clientAnn.param("wsdlLocation", wsdlUrl);
       
        JType qnameType = model._ref(QName.class);
       
        /**
         * Constructor
         */
        JMethod constructor = servCls.constructor(JMod.PUBLIC);
        constructor._throws(MalformedURLException.class);
       
        JType urlType = model._ref(URL.class);
       
        JInvocation newURL = JExpr._new(urlType).arg(wsdlUrl);
        JInvocation newSN = JExpr._new(qnameType).arg(ns).arg(name);
       
        JInvocation superService = JExpr.invoke("super").arg(newURL).arg(newSN);
        constructor.body().add(superService);
       
        boolean addedLocal = false;
       
        JBlock staticBlock = servCls.init();
       
        JType hashMapType = model._ref(HashMap.class);
        JType mapType = model._ref(Map.class);
        JVar portsVar = servCls.field(JMod.PRIVATE + JMod.STATIC,
                                      mapType, "ports", JExpr._new(hashMapType));

        JMethod method = servCls.method(JMod.PUBLIC + JMod.STATIC, mapType, "getPortClassMap");
        method.body()._return(JExpr.ref("ports"));
       
        for (Service service : services)
        {
            JClass serviceIntf = (JClass) service.getProperty(ServiceInterfaceGenerator.SERVICE_INTERFACE);

            JFieldVar intfClass = servCls.field(JMod.STATIC + JMod.PUBLIC,
                                                Class.class,
                                                javify(serviceIntf.name()),
                                                JExpr.dotclass(serviceIntf));

            // hack to get local support
            if (!addedLocal)
            {
                Soap11Binding localBind = new Soap11Binding(new QName(ns, name + "LocalBinding"),
                                                            LocalTransport.BINDING_ID,
                                                            service);
                service.addBinding(localBind);
                service.addEndpoint(new QName(ns, name + "LocalPort"), localBind, "xfire.local://" + name);
               
                addedLocal = true;
            }
           
            for (Iterator itr = service.getEndpoints().iterator(); itr.hasNext();)
            {
                Endpoint endpoint = (Endpoint) itr.next();
   
                JInvocation newQN = JExpr._new(qnameType);
                newQN.arg(endpoint.getName().getNamespaceURI());
                newQN.arg(endpoint.getName().getLocalPart());
               
                JInvocation bindingQN = JExpr._new(qnameType);
                bindingQN.arg(endpoint.getBinding().getName().getNamespaceURI());
                bindingQN.arg(endpoint.getBinding().getName().getLocalPart());

                // Add a getFooEndpointMethod
                JMethod getFooEndpoint = servCls.method(JMod.PUBLIC, serviceIntf, javify("get" + endpoint.getName().getLocalPart()));
                JBlock geBody = getFooEndpoint.body();
   
                geBody._return(JExpr.cast(serviceIntf, JExpr.direct("this").invoke("getPort").arg(newQN).arg(intfClass)));
               
                JAnnotationUse weAnn = getFooEndpoint.annotate(WebEndpoint.class);
                weAnn.param("name", endpoint.getName().getLocalPart());
               
                staticBlock.add(portsVar.invoke("put").arg(newQN).arg(intfClass));
            }
        }
    }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

        QName resTypeName = new QName(op.getOutputMessage().getName().getNamespaceURI(), op.getName() + "Response");
       
        JType reqType = context.getSchemaGenerator().getType(context, reqTypeName, null);
        JType resType = context.getSchemaGenerator().getType(context, resTypeName, null);
       
        JAnnotationUse reqA = m.annotate(RequestWrapper.class);
        reqA.param("targetNamespace", reqTypeName.getNamespaceURI());
        reqA.param("localName", reqTypeName.getLocalPart());
        reqA.param("className", reqType.fullName());

        JAnnotationUse resA = m.annotate(ResponseWrapper.class);
        resA.param("targetNamespace", resTypeName.getNamespaceURI());
        resA.param("localName", resTypeName.getLocalPart());
        resA.param("className", resType.fullName());
    }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

        wsa.param("targetNamespace", serviceNS);
        wsa.param("wsdlLocation", wsdlLocation);
    }

    private void writeWebEndpoint(Port port, JMethod m) {
        JAnnotationUse webEndpointAnn = m.annotate(cm.ref(WebEndpoint.class));
        webEndpointAnn.param("name", port.getName().getLocalPart());
    }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

* @author Arun Gupta
*/
public class W3CAddressingJavaGeneratorExtension extends TJavaGeneratorExtension {
    @Override
    public void writeMethodAnnotations(TWSDLOperation two, JMethod jMethod) {
        JAnnotationUse actionAnn = null;

        if (!(two instanceof Operation))
            return;

        Operation o = ((Operation)two);

        // explicit input action
        if (o.getInput().getAction() != null && !o.getInput().getAction().equals("")) {
            // explicitly specified
            actionAnn = jMethod.annotate(Action.class);
            actionAnn.param("input", o.getInput().getAction());
        }

        // explicit output action
        if (o.getOutput() != null && o.getOutput().getAction() != null && !o.getOutput().getAction().equals("")) {
            // explicitly specified
            if (actionAnn == null)
                actionAnn = jMethod.annotate(Action.class);

            actionAnn.param("output", o.getOutput().getAction());
        }

        // explicit fault action
        if (o.getFaults() != null && o.getFaults().size() > 0) {
            Map<String, JClass> map = o.getFaults();
            JAnnotationArrayMember jam = null;

            for (Fault f : o.faults()) {
                if (f.getAction() == null)
                    continue;

                if (f.getAction().equals(""))
                    continue;

                if (actionAnn == null) {
                    actionAnn = jMethod.annotate(Action.class);
                }
                if (jam == null) {
                    jam = actionAnn.paramArray("fault");
                }
                final JAnnotationUse faAnn = jam.annotate(FaultAction.class);
                faAnn.param("className", map.get(f.getName()));
                faAnn.param("value", f.getAction());
            }
        }
    }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

            constructor6.varParam(WebServiceFeature.class, "features");
            constructor6.body().directStatement("super(wsdlLocation, serviceName, features);");
        }

        //@WebService
        JAnnotationUse webServiceClientAnn = cls.annotate(cm.ref(WebServiceClient.class));
        writeWebServiceClientAnnotation(service, webServiceClientAnn);

        //@HandlerChain
        writeHandlerConfig(Names.customJavaTypeClassName(service.getJavaInterface()), cls, options);
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

      this.valueObjectFactoryClass = valueObjectFactoryClass;

      String dotClazz = candidateClass.fullName() + ".class";

      for (JMethod method : valueObjectFactoryClass.methods()) {
        JAnnotationUse xmlElementDeclAnnotation = getAnnotation(method, xmlElementDeclModelClass);
        JExpression scope = getAnnotationMemberExpression(xmlElementDeclAnnotation, "scope");

        if (scope == null || !dotClazz.equals(generableToString(scope))) {
          continue;
        }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

          // GENERATED CODE: ... fieldName = new C<T>();
          originalImplField.init(JExpr._new(collectionImplClass));
        }

        // Annotate the field with the @XmlElementWrapper annotation using the original field name.
        JAnnotationUse xmlElementWrapperAnnotation = originalImplField.annotate(xmlElementWrapperModelClass);
        JAnnotationUse xmlElementOriginalAnnotation = getAnnotation(originalImplField, xmlElementModelClass);

        // xmlElementOriginalAnnotation can be null:
        JExpression wrapperXmlName = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "name");
        if (wrapperXmlName != null) {
          xmlElementWrapperAnnotation.param("name", wrapperXmlName);
        }
        else if (fieldConfiguration.isApplyPluralForm()) {
          xmlElementWrapperAnnotation.param("name", getXsdDeclaration(fieldPropertyInfo).getName());
        }

        JExpression wrapperXmlRequired = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "required");
        if (wrapperXmlRequired != null) {
          xmlElementWrapperAnnotation.param("required", wrapperXmlRequired);
        }

        JExpression wrapperXmlNillable = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "nillable");
        if (wrapperXmlNillable != null) {
          xmlElementWrapperAnnotation.param("nillable", wrapperXmlNillable);
        }

        // Namespace of the wrapper element
        JExpression wrapperXmlNamespace = getAnnotationMemberExpression(xmlElementOriginalAnnotation,
                    "namespace");
        if (wrapperXmlNamespace != null) {
          xmlElementWrapperAnnotation.param("namespace", wrapperXmlNamespace);
        }

        if (xmlElementOriginalAnnotation != null) {
          removeAnnotation(originalImplField, xmlElementOriginalAnnotation);
        }

        boolean xmlElementInfoWasTransferred = false;

        // Transfer @XmlAnyElement, @XmlElementRefs, @XmlElements:
        for (JClass annotationModelClass : new JClass[] { xmlAnyElementModelClass, xmlMixedModelClass,
                xmlElementRefModelClass, xmlElementRefsModelClass, xmlElementsModelClass }) {
          JAnnotationUse annotation = getAnnotation(candidate.getField(), annotationModelClass);

          if (annotation != null) {
            if (candidate.getFieldTargetNamespace() != null) {
              JAnnotationArrayMember annotationArrayMember = (JAnnotationArrayMember) getAnnotationMember(
                          annotation, "value");

              if (annotationArrayMember != null) {
                for (JAnnotationUse subAnnotation : annotationArrayMember.annotations()) {
                  if (getAnnotationMemberExpression(subAnnotation, "namespace") == null) {
                    subAnnotation.param("namespace", candidate.getFieldTargetNamespace());
                  }
                }
              }
            }

            xmlElementInfoWasTransferred = true;

            addAnnotation(originalImplField, annotation);
          }
        }

        if (!xmlElementInfoWasTransferred) {
          // Annotate the field with the @XmlElement annotation using the field name from the wrapped type as name.
          // We cannot just re-use the same annotation object instance, as for example, we need to set XML name and this
          // will impact the candidate field annotation in case candidate is unmarked from removal.
          JAnnotationUse xmlElementAnnotation = originalImplField.annotate(xmlElementModelClass);
          xmlElementOriginalAnnotation = getAnnotation(candidate.getField(), xmlElementModelClass);

          // xmlElementOriginalAnnotation can be null:
          JExpression xmlName = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "name");
          if (xmlName != null) {
            xmlElementAnnotation.param("name", xmlName);
          }
          else {
            xmlElementAnnotation.param("name", candidate.getFieldName());
          }

          JExpression xmlNamespace = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "namespace");
          if (xmlNamespace != null) {
            xmlElementAnnotation.param("namespace", xmlNamespace);
          }
          else if (candidate.getFieldTargetNamespace() != null) {
            xmlElementAnnotation.param("namespace", candidate.getFieldTargetNamespace());
          }

          JExpression type = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "type");
          if (type != null) {
            xmlElementAnnotation.param("type", type);
          }
        }

        JAnnotationUse adapterAnnotation = getAnnotation(candidate.getField(), xmlJavaTypeAdapterModelClass);

        if (adapterAnnotation != null) {
          addAnnotation(originalImplField, adapterAnnotation);
        }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

      // First check that such factory method has not yet been created. It can be the case if target class
      // is substituted with e.g. two candidates, each candidate having a field with the same name.
      // FIXME: Could it be the case that these two fields have different namespaces?
      for (JMethod method : factoryClass.methods()) {
        JAnnotationUse xmlElementDeclAnnotation = getAnnotation(method, xmlElementDeclModelClass);

        JExpression scope = getAnnotationMemberExpression(xmlElementDeclAnnotation, "scope");
        JExpression name = getAnnotationMemberExpression(xmlElementDeclAnnotation, "name");

        if (scope != null && dotClazz.equals(generableToString(scope))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.