Package org.jboss.errai.codegen

Examples of org.jboss.errai.codegen.InnerClass


    // with the translation service.
    for (String resource : resources) {
      // Generate this component's ClientBundle resource interface
      BuildMetaClass messageBundleResourceInterface = generateMessageBundleResourceInterface(resource);
      // Add it as an inner class to the generated translation service
      classBuilder.getClassDefinition().addInnerClass(new InnerClass(messageBundleResourceInterface));

      // Instantiate the ClientBundle MessageBundle resource
      final String msgBundleVarName = InjectUtil.getUniqueVarName();
      ctor.append(Stmt.declareVariable(messageBundleResourceInterface).named(msgBundleVarName)
              .initializeWith(Stmt.invokeStatic(GWT.class, "create", messageBundleResourceInterface)));
View Full Code Here


          }

        }).finish();

    ctx.getInjectionContext().getProcessingContext().getBootstrapClass()
        .addInnerClass(new InnerClass(componentTemplateResource.getClassDefinition()));

    getConstructedTemplateTypes(ctx).put(type, componentTemplateResource.getClassDefinition());
  }
View Full Code Here

    for (MetaClass remote : remotes) {
      if (remote.isInterface()) {
        // create the remote proxy for this interface
        ClassStructureBuilder<?> remoteProxy =
            new JaxrsProxyGenerator(remote, context, interceptorProvider, exceptionMappers).generate();
        loadProxies.append(new InnerClass(remoteProxy.getClassDefinition()));

        // create the proxy provider
        Statement proxyProvider = ObjectBuilder.newInstanceOf(ProxyProvider.class)
            .extend()
            .publicOverridesMethod("getProxy")
View Full Code Here

            .publicMethod(AbstractGwtValidator.class, "createValidator")
            .append(
                    Stmt.invokeStatic(GWT.class, "create", validatorInterface.getClassDefinition()).returnValue()
            )
            .finish();
    builder.getClassDefinition().addInnerClass(new InnerClass(validatorInterface.getClassDefinition()));

    return builder.toJavaString();
  }
View Full Code Here

                if (context.canMarshal(toMap.getFullyQualifiedName())) {
                  if (gwtTarget) {
                    BuildMetaClass arrayMarshaller = MarshallerGeneratorFactory.createArrayMarshallerClass(type);
                   
                    if (!containsInnerClass(classStructureBuilder, arrayMarshaller)) {
                      classStructureBuilder.declaresInnerClass(new InnerClass(arrayMarshaller));
                    }
                    Statement deferred = context.getArrayMarshallerCallback().deferred(type, arrayMarshaller);
                    MarshallingGenUtil.ensureMarshallerFieldCreated(classStructureBuilder, toMap, type, lazyInitMethod,
                        deferred);
                    constructorParameters.add(
                        Stmt.loadVariable(MarshallingGenUtil.getVarName(type)).invoke("demarshall",
                            extractJSONObjectProperty(mapping.getKey(), EJObject.class), Stmt.loadVariable("a1")));
                  }
                  else {
                    MarshallingGenUtil.ensureMarshallerFieldCreated(classStructureBuilder, toMap, type, lazyInitMethod);
                    constructorParameters.add(context.getArrayMarshallerCallback()
                        .demarshall(type, extractJSONObjectProperty(mapping.getKey(), EJObject.class)));
                  }
                }
                else {
                  throw new MarshallingException("Encountered non-marshallable type " + toMap +
                          " while building a marshaller for " + mappingDefinition.getMappingClass());
                }
              }
              else {
                MarshallingGenUtil.ensureMarshallerFieldCreated(classStructureBuilder, toMap, type, lazyInitMethod);
                if (context.canMarshal(type.getFullyQualifiedName())) {
                  Statement s = maybeAddAssumedTypes(builder,
                      "c" + constructorParameters.size(),
                      // null,
                      mapping, fieldDemarshall(mapping, EJObject.class));

                  constructorParameters.add(s);
                }
                else {
                  throw new MarshallingException("Encountered non-marshallable type " + type +
                          " while building a marshaller for " + mappingDefinition.getMappingClass());
                }
              }
            }

            if (instantiationMapping instanceof ConstructorMapping) {
              final ConstructorMapping mapping = (ConstructorMapping) instantiationMapping;
              final MetaConstructor constructor = mapping.getMember();

              if (constructor.isPublic()) {
                builder
                    .append(Stmt.declareVariable(toMap).named("entity")
                        .initializeWith(
                            Stmt.newObject(toMap, constructorParameters
                                .toArray(new Object[constructorParameters.size()]))));
              }
              else {
                PrivateAccessUtil.addPrivateAccessStubs(gwtTarget ? "jsni" : "reflection", classStructureBuilder,
                    constructor);
                builder.append(Stmt.declareVariable(toMap).named("entity")
                    .initializeWith(
                        Stmt.invokeStatic(
                            classStructureBuilder.getClassDefinition(),
                            PrivateAccessUtil.getPrivateMethodName(constructor),
                            constructorParameters.toArray(new Object[constructorParameters.size()]))));
              }
            }
            else if (instantiationMapping instanceof FactoryMapping) {
              builder.append(Stmt.declareVariable(toMap).named("entity")
                  .initializeWith(
                      Stmt.invokeStatic(toMap, ((FactoryMapping) instantiationMapping).getMember().getName(),
                          constructorParameters.toArray(new Object[constructorParameters.size()]))));
            }
          }
          else {
            // use default constructor

            builder._(
                Stmt.declareVariable(toMap).named("entity").initializeWith(
                    Stmt.nestedCall(Stmt.newObject(toMap))));
          }

          builder._(loadVariable("a1").invoke("recordObject",
              loadVariable("objId"), loadVariable("entity")));
        }

        /**
         *
         * FIELD BINDINGS
         *
         */
        for (final MemberMapping memberMapping : mappingDefinition.getMemberMappings()) {
          if (!memberMapping.canWrite())
            continue;
          if (memberMapping.getTargetType().isConcrete() && !context.isRendered(memberMapping.getTargetType())) {
            context.getMarshallerGeneratorFactory().addMarshaller(memberMapping.getTargetType());
          }

          final Statement bindingStatement;
          final Statement val;

          context.getMarshallerGeneratorFactory().addOrMarkMarshallerUnlazy(
              memberMapping.getType().getOuterComponentType());

          BlockBuilder<?> lazyInitMethod = (needsLazyInit(memberMapping.getType())) ? initMethod : null;
          if (memberMapping.getType().isArray()) {
            if (gwtTarget) {
              BuildMetaClass arrayMarshaller =
                  MarshallerGeneratorFactory.createArrayMarshallerClass(memberMapping.getType().asBoxed());

              if (!containsInnerClass(classStructureBuilder, arrayMarshaller)) {
                classStructureBuilder.declaresInnerClass(new InnerClass(arrayMarshaller));
              }
              Statement deferred =
                  context.getArrayMarshallerCallback().deferred(memberMapping.getType().asBoxed(), arrayMarshaller);
              MarshallingGenUtil.ensureMarshallerFieldCreated(classStructureBuilder, toMap, memberMapping.getType()
                  .asBoxed(), lazyInitMethod, deferred);
View Full Code Here

            MarshallerGeneratorFactory.MARSHALLER_NAME_PREFIX + MarshallingGenUtil.getVarName(type) + "Impl";

        final ClassStructureBuilder<?> marshaller = strategy.getMapper().getMarshaller(marshallerClassName);
        customMarshaller = marshaller.getClassDefinition();
      }
      classStructureBuilder.declaresInnerClass(new InnerClass(customMarshaller));
      addMarshaller(customMarshaller, type);
    }
  }
View Full Code Here

  private String addArrayMarshaller(final MetaClass type, boolean gwtTarget) {
    final String varName = getVarName(type);

    if (!arrayMarshallers.contains(varName)) {
      final String marshallerClassName = MARSHALLER_NAME_PREFIX + getVarName(type) + "_Impl";
      final InnerClass arrayMarshaller = new InnerClass(generateArrayMarshaller(type, marshallerClassName, gwtTarget));
      classStructureBuilder.declaresInnerClass(arrayMarshaller);

      updateConditionalBlock(type);
     
      conditionalGenerationBlock.append(
            Stmt.loadVariable("m").assignValue(
                Stmt.newObject(QualifyingMarshallerWrapper.class, Stmt.newObject(arrayMarshaller.getType()), type
                    .asClass())));
    }
    arrayMarshallers.add(varName);

    return varName;
View Full Code Here

      }
      final Set<String> proxies = (Set<String>) context.getAttribute(RENDERED_PROXIES);
      if (!proxies.contains(type.getCanonicalName())) {
        context.getProcessingContext().getBootstrapClass()
            .addInnerClass(new InnerClass(type));
        proxies.add(type.getCanonicalName());
      }

      final List<Statement> proxyCloseStmts = new ArrayList<Statement>();
View Full Code Here

TOP

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

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.