Package com.sun.codemodel

Examples of com.sun.codemodel.JInvocation


        JBlock consBody = constructor.body();
        JType qnameType = model.ref(QName.class);
       
        JDefinedClass serviceIntf = (JDefinedClass) service.getProperty(ServiceInterfaceGenerator.SERVICE_INTERFACE);

        JInvocation addEndpointInv = serviceVar.invoke("addEndpoint");
        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());

        addEndpointInv.arg(newQN);
        addEndpointInv.arg(bindingQN);
        addEndpointInv.arg(endpoint.getUrl());

        JType endpointType = model.ref(Endpoint.class);
        JVar epVar = consBody.decl(endpointType, javify(endpoint.getName().getLocalPart()) + "EP", addEndpointInv);

        JInvocation addEndpoint = endpointsVar.invoke("put").arg(newQN).arg(epVar);
        consBody.add(addEndpoint);
       
        // Add a getFooEndpointMethod
        JMethod getFooEndpoint = servCls.method(JMod.PUBLIC, serviceIntf, "get"
                + javify(endpoint.getName().getLocalPart()));
        JBlock geBody = getFooEndpoint.body();

        geBody._return(JExpr.cast(serviceIntf, JExpr.direct("this").invoke(getEndpoint).arg(newQN)));

        JMethod getFooEndpoint1 = servCls.method(JMod.PUBLIC, serviceIntf, "get"
                + javify(endpoint.getName().getLocalPart()));
        getFooEndpoint1.param(String.class,"url");
        JBlock geBody1 = getFooEndpoint1.body();
        JInvocation getEndp = JExpr.invoke(getFooEndpoint);
        JVar tpe = geBody1.decl(serviceIntf, "var", getEndp );
       
        geBody1.directStatement("org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);");
        geBody1._return(tpe);
    }
View Full Code Here


    }

    public JExpression getBindingProviderExpr(GenerationContext context)
    {
        JType aegis = context.getCodeModel()._ref(AegisBindingProvider.class);
        JInvocation expr = JExpr._new(aegis);
       
        JType xbean = context.getCodeModel()._ref(XmlBeansTypeRegistry.class);
        expr.arg(JExpr._new(xbean));
       
        return expr;//JExpr._new()
    }
View Full Code Here

        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();
   
View Full Code Here

  @NotNull
  public JExpression createCollectionInvocation( @NotNull JType collectionParamType, @NotNull @NonNls String simpleName, boolean isSet ) {
    JExpression expression = create( collectionParamType.erasure(), simpleName );

    JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
    if ( isSet ) {
      return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
    } else {
      return listInvocation;
    }
View Full Code Here

  @NotNull
  public JExpression createCollectionInvocation( @NotNull TypeMirror collectionParamType, @NotNull @NonNls String simpleName, boolean isSet ) {
    JExpression expression = create( TypeUtils.getErasure( collectionParamType ), simpleName );

    JInvocation listInvocation = classRefSupport.ref( Arrays.class ).staticInvoke( METHOD_NAME_AS_LIST ).arg( expression );
    if ( isSet ) {
      return JExpr._new( classRefSupport.ref( HashSet.class ) ).arg( listInvocation );
    } else {
      return listInvocation;
    }
View Full Code Here

  }

  @NotNull
  public JExpression createToStringExpression( @NotNull JInvocation getterInvocation, @NotNull FieldTypeInformation fieldInfo ) {
    JClass jClass = model.ref( String.class );
    JInvocation wrappedGetterInvocation;
    if ( fieldInfo.isType( String.class ) ) {
      wrappedGetterInvocation = getterInvocation;
    } else {
      wrappedGetterInvocation = jClass.staticInvoke( STRING_VALUE_OF ).arg( getterInvocation );
    }
View Full Code Here

    int[] fieldIndices = fieldId.getFieldIds();
    for (int i = 0; i < fieldIndices.length; i++) {
       b.assign(fieldArr.component(JExpr.lit(i)), JExpr.lit(fieldIndices[i]));
    }

    JInvocation invoke = batchName
        .invoke("getValueAccessorById") //
        .arg( vvClass.dotclass())
        .arg(fieldArr);

    JVar obj = b.decl( //
        objClass, //
        getNextVar("tmp"), //
        invoke.invoke(vectorAccess));

    b._if(obj.eq(JExpr._null()))._then()._throw(JExpr._new(t).arg(JExpr.lit(String.format("Failure while loading vector %s with id: %s.", vv.name(), fieldId.toString()))));
    //b.assign(vv, JExpr.cast(retClass, ((JExpression) JExpr.cast(wrapperClass, obj) ).invoke(vectorAccess)));
    b.assign(vv, JExpr.cast(retClass, obj ));
    vvDeclaration.put(setup, vv);
View Full Code Here

      boolean isVoidMethod = method.getReturnType() == void.class;
      for(JBlock b : blocks[i++]) {
        if(!b.isEmpty()) {
          if (blocksInMethod > MAX_BLOCKS_IN_FUNCTION) {
            JMethod inner = clazz.method(JMod.PRIVATE, model._ref(method.getReturnType()), method.getMethodName() + methodIndex);
            JInvocation methodCall = JExpr.invoke(inner);
            for (CodeGeneratorArgument arg : method) {
              inner.param(arg.getType(), arg.getName());
              methodCall.arg(JExpr.direct(arg.getName()));
            }
            for (Class<?> c : method.getThrowsIterable()) {
              inner._throws(model.ref(c));
            }
            inner._throws(SchemaChangeException.class);
View Full Code Here

        internalVars[i] = sub.decl(g.getModel()._ref(workspaceVars[i].type), workspaceVars[i].name, workspaceJVars[i]);
        continue;
      }
      //sub.assign(workspaceJVars[i], JExpr._new(g.getHolderType(workspaceVars[i].majorType)));
      //Access workspaceVar through workspace vector.
      JInvocation getValueAccessor = g.getWorkspaceVectors().get(workspaceVars[i]).invoke("getAccessor").invoke("get");
      if (Types.usesHolderForGet(workspaceVars[i].majorType)) {
        sub.add(getValueAccessor.arg(wsIndexVariable).arg(workspaceJVars[i]));
      } else {
        sub.assign(workspaceJVars[i].ref("value"), getValueAccessor.arg(wsIndexVariable));
      }
      internalVars[i] = sub.decl(g.getHolderType(workspaceVars[i].majorType),  workspaceVars[i].name, workspaceJVars[i]);
    }

    Preconditions.checkNotNull(body);
    sub.directStatement(body);
    JVar successVar = sub.decl(JType.parse(g.getModel(), "boolean"), "success", JExpr.lit(false));

    // reassign workspace variables back.
    for(int i =0; i < workspaceJVars.length; i++){
      sub.assign(workspaceJVars[i], internalVars[i]);

      // Injected buffers are not stored as vectors skip storing them in vectors
      if (workspaceVars[i].isInject()) {
        continue;
      }
      //Change workspaceVar through workspace vector.
      JInvocation setMeth;
      if (Types.usesHolderForGet(workspaceVars[i].majorType)) {
        setMeth = g.getWorkspaceVectors().get(workspaceVars[i]).invoke("getMutator").invoke("setSafe").arg(wsIndexVariable).arg(workspaceJVars[i]);
      }else{
        setMeth = g.getWorkspaceVectors().get(workspaceVars[i]).invoke("getMutator").invoke("setSafe").arg(wsIndexVariable).arg(workspaceJVars[i].ref("value"));
      }
View Full Code Here

    JVar complexWriter = g.declareClassField("complexWriter", g.getModel()._ref(ComplexWriter.class));

    JClass cwClass = g.getModel().ref(ComplexWriterImpl.class);

    JInvocation container = g.getMappingSet().getOutgoing().invoke("getOutgoingContainer");

    //Default name is "col", if not passed in a reference name for the output vector.
    String refName = ref == null? "col" : ref.getRootSegment().getPath();

    g.getSetupBlock().assign(complexWriter, cwClass.staticInvoke("getWriter").arg(refName).arg(container));
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.