Package com.sun.codemodel

Examples of com.sun.codemodel.JInvocation


      JVar currMethodParams = staticInit.decl(fieldDefListClass, varName).init(JExpr._new(fieldDefListClass));

      ParameterSchemaArray parameters = actionSchema.getParameters();
      for (ParameterSchema parameterSchema : parameters == null? new ParameterSchemaArray() : parameters)
      {
        JInvocation fieldDefParam = createFieldDef(parameterSchema.getName(), parameterSchema.getType(), facadeClass);
        staticInit.add(currMethodParams.invoke("add").arg(fieldDefParam));
      }
      String methodName = actionSchema.getName();
      JInvocation newSchema = createMetadata(methodName, currMethodParams);
      staticInit.add(requestMetadataMap.invoke("put").arg(methodName).arg(newSchema));
    }
    return requestMetadataMap;
  }
View Full Code Here


   */
  private JInvocation createFieldDef(String name, String type, JDefinedClass parent)
  {
    JavaBinding binding = getJavaBindingType(type, parent);
    JExpression schema = getCodeModel().ref(DataTemplateUtil.class).staticInvoke("getSchema").arg(binding.schemaClass.dotclass());
    JInvocation fieldDefInvocation = JExpr._new(getCodeModel().ref(FieldDef.class).narrow(binding.valueClass))
        .arg(name).arg(binding.valueClass.dotclass())
        .arg(schema);
    return fieldDefInvocation;
  }
View Full Code Here

    derivedBuilderClass._extends(baseBuilderClass.narrow(derivedBuilderClass));
    JMethod derivedBuilderConstructor = derivedBuilderClass.constructor(JMod.PUBLIC);
    JVar uriParam = derivedBuilderConstructor.param(_stringClass, "baseUriTemplate");
    JVar resourceSpecParam = derivedBuilderConstructor.param(_resourceSpecClass, "resourceSpec");
    JVar requestOptionsParam = derivedBuilderConstructor.param(RestliRequestOptions.class, "requestOptions");
    JInvocation invocation = derivedBuilderConstructor.body().invoke(SUPER).arg(uriParam);

    // the new BatchGetEntityRequestBuilderBase does not need the valueClass parameter in constructor
    if (!baseBuilderClass.fullName().startsWith(BatchGetEntityRequestBuilderBase.class.getName() + "<"))
    {
      invocation.arg(valueClass.dotclass());
    }
    invocation.arg(resourceSpecParam).arg(requestOptionsParam);
    if (finderName != null)
    {
      derivedBuilderConstructor.body().add(JExpr._super().invoke("name").arg(finderName));
    }
View Full Code Here

    // Setter method.

    JMethod setter = unionClass.method(JMod.PUBLIC, Void.TYPE, setterName);
    param = setter.param(memberClass, "value");
    JClass dataClass = determineDataClass(memberType, unionClass, memberType.getUnionMemberKey());
    JInvocation inv = setter.body().invoke("select" + wrappedOrDirect).arg(memberField).arg(JExpr.dotclass(memberClass));
    dataClassArg(inv, dataClass).arg(memberKey).arg(param);
  }
View Full Code Here

  {
    JFieldVar schemaField = templateClass.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
                                                schema.getClass(),
                                                DataTemplateUtil.SCHEMA_FIELD_NAME);
    String schemaJson = SchemaToJsonEncoder.schemaToJson(schema, JsonBuilder.Pretty.COMPACT);
    JInvocation parseSchemaInvocation;
    if (schemaJson.length() < MAX_SCHEMA_JSON_LENGTH)
    {
      parseSchemaInvocation = _dataTemplateUtilClass.staticInvoke("parseSchema").arg(schemaJson);
    }
    else
    {
      JInvocation stringBuilderInvocation = JExpr._new(_stringBuilderClass);
      for (int index = 0; index < schemaJson.length(); index += MAX_SCHEMA_JSON_LENGTH)
      {
        stringBuilderInvocation = stringBuilderInvocation.
          invoke("append").
          arg(schemaJson.substring(index, Math.min(schemaJson.length(), index + MAX_SCHEMA_JSON_LENGTH)));
      }
      stringBuilderInvocation = stringBuilderInvocation.invoke("toString");
      parseSchemaInvocation = _dataTemplateUtilClass.staticInvoke("parseSchema").arg(stringBuilderInvocation);
    }
    schemaField.init(JExpr.cast(getCodeModel()._ref(schema.getClass()),
                                parseSchemaInvocation));
View Full Code Here

  private static void generateConstructorWithArg(JDefinedClass cls, JVar schemaField, JClass paramClass, JClass elementClass, JClass dataClass)
  {
    JMethod argConstructor = cls.constructor(JMod.PUBLIC);
    JVar param = argConstructor.param(paramClass, "data");
    JInvocation inv = argConstructor.body().invoke(SUPER).arg(param).arg(schemaField).arg(JExpr.dotclass(elementClass));
    dataClassArg(inv, dataClass);
  }
View Full Code Here

    JMethod setterWithMode =  templateClass.method(JMod.PUBLIC, templateClass, setterName);
    addAccessorDoc(setterWithMode, field, "Setter");
    setDeprecatedAnnotationAndJavadoc(setterWithMode, field);
    JVar param = setterWithMode.param(type, "value");
    modeParam = setterWithMode.param(_setModeClass, "mode");
    JInvocation inv = setterWithMode.body().invoke("put" + wrappedOrDirect).arg(fieldField).arg(JExpr.dotclass(type));
    dataClassArg(inv, dataClass).arg(param).arg(modeParam);
    setterWithMode.body()._return(JExpr._this());

    // Setter method without mode
    JMethod setter =  templateClass.method(JMod.PUBLIC, templateClass, setterName);
View Full Code Here

    return provider;
  }

  public JExpression getBindingProviderExpr(GenerationContext context) {
    JType aegis = context.getCodeModel()._ref(AegisBindingProvider.class);
    JInvocation expr = JExpr._new(aegis);

    JType xbean = context.getCodeModel()._ref(JaxbTypeRegistry.class);
    expr.arg(JExpr._new(xbean));

    return expr;
  }
View Full Code Here

        JVar epVar = getEndpoint.param(Endpoint.class, "endpoint");
       
        JBlock geBody = getEndpoint.body();
        JTryBlock tryBlock = geBody._try();
       
        JInvocation createProxy = pfVar.invoke("create");
        createProxy.arg(JExpr.direct(epVar.name()).invoke("getBinding"));
        createProxy.arg(JExpr.direct(epVar.name()).invoke("getUrl"));
       
        tryBlock.body()._return(createProxy);

        JCatchBlock catchBlock = tryBlock._catch(model.ref(MalformedURLException.class));
        JType xreType = model._ref(XFireRuntimeException.class);
        JInvocation xreThrow = JExpr._new(xreType);
        xreThrow.arg("Invalid URL");
        xreThrow.arg(catchBlock.param("e"));
       
        catchBlock.body()._throw(xreThrow);
       

        /**
         * T getEndpoint(QName)
         */
        JMethod getEndpointByName = servCls.method(JMod.PUBLIC, objectType, "getEndpoint");
        JVar epname = getEndpointByName.param(QName.class, "name");
       
        geBody = getEndpointByName.body();
       
        // Endpoint endpoint = (Endpoint) service.getEndpoint(name);
        JType endpointType = model._ref(Endpoint.class);
        JInvocation getEndpointInv = endpointsVar.invoke("get");
        getEndpointInv.arg(JExpr.direct(epname.name()));

        epVar = geBody.decl(endpointType, "endpoint", JExpr.cast(endpointType, getEndpointInv));
       
        // if (endpoint == null)
        JBlock noEPBlock = geBody._if(JExpr.direct(epVar.name()).eq(JExpr._null()))._then();
       
        // throw IllegalStateException
        JType iseType = model._ref(IllegalStateException.class);
        JInvocation iseThrow = JExpr._new(iseType);
        iseThrow.arg("No such endpoint!");
        noEPBlock._throw(iseThrow);
       
        // return endpoint
       
        JInvocation geInvoke = JExpr.invoke(getEndpoint);
        geInvoke.arg(JExpr.direct(epVar.name()));
        geBody._return(geInvoke);
       
        /**
         * Collection getEndpoints()
         */
 
View Full Code Here

        JType qnameType = model._ref(QName.class);
        JType soapTransType = model._ref(SoapTransport.class);
        JType hashMapType = model._ref(HashMap.class);
       
        JVar tmVar = create.body().decl(tmType, "tm", JExpr.direct("org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager()"));
        JInvocation asfCons = JExpr._new(asfType);
        asfCons.arg(JExpr._new(jsr181Type));
        asfCons.arg(tmVar);
        asfCons.arg(context.getSchemaGenerator().getBindingProviderExpr(context));
       
        JVar propsVar = create.body().decl(hashMapType, "props", JExpr._new(hashMapType));
        create.body().add(propsVar.invoke("put").arg("annotations.allow.interface").arg(JExpr.TRUE));
       
        JVar asfVar = create.body().decl(asfType, "asf", asfCons);
        JInvocation createInvoke = asfVar.invoke("create");
       
        createInvoke.arg(JExpr.direct(serviceIntf.fullName() + ".class"));
        createInvoke.arg(propsVar);
       
        JInvocation bindingCreation = asfVar.invoke("setBindingCreationEnabled");
        bindingCreation.arg(JExpr.lit(false));
        create.body().add(bindingCreation);
       
        JType serviceType = model._ref(Service.class);
        create.body().assign(serviceVar, createInvoke);
       
        for (Iterator itr = service.getBindings().iterator(); itr.hasNext();)
        {
            Binding binding = (Binding) itr.next();
            if (!(binding instanceof AbstractSoapBinding)) continue;
           
            AbstractSoapBinding soapBinding = (AbstractSoapBinding) binding;

            JBlock block = create.body().block();
           
            JInvocation createBinding;
            if (soapBinding instanceof Soap12Binding)
            {
                createBinding = asfVar.invoke("createSoap12Binding");
            }
            else
            {
                createBinding = asfVar.invoke("createSoap11Binding");
            }
           
            createBinding.arg(serviceVar);
           
            JInvocation newQN = JExpr._new(qnameType);
            newQN.arg(soapBinding.getName().getNamespaceURI());
            newQN.arg(soapBinding.getName().getLocalPart());
            createBinding.arg(newQN);
            createBinding.arg(soapBinding.getBindingId());

            JVar sbVar = block.decl(abSoapBindingType, "soapBinding", createBinding);
        }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JInvocation

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.