Package org.jboss.errai.codegen

Examples of org.jboss.errai.codegen.Statement


      }
    }

    final String varName = InjectUtil.getUniqueVarName();

    final Statement subscribeStatement;

    if (local) {
      subscribeStatement = Stmt.invokeStatic(ErraiBus.class, "get")
              .invoke("subscribeLocal", svcName, injectableInstance.getValueStatement());
    }
    else {
      subscribeStatement = Stmt.invokeStatic(ErraiBus.class, "get")
              .invoke("subscribe", svcName, injectableInstance.getValueStatement());
    }

    final Statement declareVar = Stmt.declareFinalVariable(varName, Subscription.class, subscribeStatement);

    final MetaClass destructionCallbackType =
            parameterizedAs(DestructionCallback.class, typeParametersOf(injectableInstance.getEnclosingType()));

    // register a destructor to unregister the service when the bean is destroyed.
    final BlockBuilder<AnonymousClassStructureBuilder> destroyMeth
            = ObjectBuilder.newInstanceOf(destructionCallbackType).extend()
            .publicOverridesMethod("destroy", Parameter.of(injectableInstance.getEnclosingType(), "obj", true))
            .append(Stmt.loadVariable(varName).invoke("remove"));

    final Statement descrCallback = Stmt.create().loadVariable("context").invoke("addDestructionCallback",
            Refs.get(injectableInstance.getInjector().getInstanceVarName()), destroyMeth.finish().finish());


    return Arrays.asList(declareVar, descrCallback);
  }
View Full Code Here


    if (!method.isPublic()) {
      instance.ensureMemberExposed();
    }

    Statement callbackStmt = Stmt.newObject(Runnable.class).extend()
            .publicOverridesMethod("run")
            .append(instance.callOrBind())
            .finish()
            .finish();
View Full Code Here

          if (injector.isSingleton() && injector.isCreated()) return;

          final IOCProcessingContext processingContext = ctx.getProcessingContext();

          final Statement objectInstantiate = Stmt.newObject(type, parameterStatements);

          processingContext.append(
              Stmt.declareFinalVariable(injector.getInstanceVarName(), type, objectInstantiate)
          );
          callback.beanConstructed(ConstructionType.CONSTRUCTOR);
View Full Code Here

    final List<Statement> initStatements = new ArrayList<Statement>();

    renderLifeCycleEvents(PostConstruct.class, injector, ctx, initStatements, postConstructTasks);

    final Statement initCallback = createInitializationCallback(injector.getInjectedType(), "obj", initStatements);

    final IOCProcessingContext pc = ctx.getProcessingContext();

    pc.getBootstrapBuilder()
        .privateField(varName, initializationCallbackType)
View Full Code Here

    final List<Statement> initMeth = new ArrayList<Statement>();

    renderLifeCycleEvents(PreDestroy.class, injector, ctx, initMeth, preDestroyTasks);

    Statement destructionCallback = createDestructionCallback(injector.getInjectedType(), "obj", initMeth);

    final IOCProcessingContext pc = ctx.getProcessingContext();

    pc.getBootstrapBuilder().privateField(varName, destructionCallbackType)
        .initializesWith(destructionCallback).finish();
View Full Code Here

    final MetaClass[] parmTypes = parametersToClassTypeArray(parms);
    final Statement[] parmValues = new Statement[parmTypes.length];

    for (int i = 0; i < parmTypes.length; i++) {
      Statement stmt;
      try {
        final InjectableInstance injectableInstance = InjectableInstance.getParameterInjectedInstance(
            parms[i],
            null,
            ctx);
View Full Code Here

    final MetaClass[] parmTypes = parametersToClassTypeArray(parms);
    final Statement[] parmValues = new Statement[parmTypes.length];

    for (int i = 0; i < parmTypes.length; i++
        ) {
      final Statement stmt;
      try {
        stmt = recordInlineReference(
            getInjectorOrProxy(
                ctx,
                InjectableInstance.getParameterInjectedInstance(parms[i], null, ctx),
View Full Code Here

    final String varName = InjectUtil.getUniqueVarName();

    ctx.getProcessingContext()
        .append(Stmt.declareFinalVariable(varName, parm.getType().getErased(), beanCreationStmt));

    final Statement stmt = Refs.get(varName);

    ctx.addInlineBeanReference(parm, stmt);

    return stmt;
  }
View Full Code Here

      final MetaClass proxyResolverRef = parameterizedAs(ProxyResolver.class, typeParametersOf(proxiedType));

      final BlockBuilder<AnonymousClassStructureBuilder> proxyResolverBody = newObject(proxyResolverRef)
              .extend().publicOverridesMethod("resolve", Parameter.of(proxiedType, "obj"));

      final Statement proxyResolver = proxyResolverBody._(loadVariable(varName)
              .invoke(ProxyMaker.PROXY_BIND_METHOD, Refs.get("obj"))).finish().finish();

      proxyResolverBody._(Stmt.loadVariable("context").invoke("addProxyReference", Refs.get(varName), Refs.get("obj")));

      pCtx.append(loadVariable("context").invoke("addUnresolvedProxy", proxyResolver,
View Full Code Here

        final BlockBuilderUpdater updater
            = new BlockBuilderUpdater(injectContext, AsyncTypeInjector.this, constructionType, targetBlock, blockBuilder);

        setAttribute("BlockBuilderUpdater", updater);
        final Statement beanRef = updater.run();

        injectContext.addBeanReference(type, beanRef);
        addStatementToEndOfInjector(Stmt.loadVariable("async").invoke("runOnFinish", blockBuilder.finish().finish()));

        /* mark this injector as injected so we don't go into a loop if there is a cycle. */
 
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.Statement

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.