Package org.jboss.errai.ioc.rebind.ioc.codegen.meta

Examples of org.jboss.errai.ioc.rebind.ioc.codegen.meta.MetaMethod


  }

  @Override
  public Statement generateDecorator(InjectableInstance<Observes> instance) {
    final Context ctx = instance.getInjectionContext().getProcessingContext().getContext();
    final MetaMethod method = instance.getMethod();
    final MetaParameter parm = instance.getParm();

    final String parmClassName = parm.getType().getFullyQualifiedName();
    final Statement bus = instance.getInjectionContext().getInjector(MessageBus.class).getType(instance);
    final String subscribeMethodName = method.isAnnotationPresent(Local.class) ? "subscribeLocal" : "subscribe";

    final String subject = CDI.getSubjectNameByType(parmClassName);
    final Annotation[] qualifiers = InjectUtil.extractQualifiers(instance).toArray(new Annotation[0]);
    final Set<String> qualifierNames = CDI.getQualifiersPart(qualifiers);

    AnonymousClassStructureBuilderImpl callBack = Stmt.newObject(AbstractCDIEventCallback.class).extend();

    BlockBuilder<AnonymousClassStructureBuilderImpl> callBackBlock;
    if (qualifierNames != null) {
      callBackBlock = callBack.initialize();
      for (String qualifierName : qualifierNames) {
        callBackBlock.append(Stmt.loadClassMember("qualifiers").invoke("add", qualifierName));
      }
      callBack = callBackBlock.finish();
    }

    callBackBlock = callBack.publicOverridesMethod("callback", Parameter.of(Message.class, "message"))
        .append(Stmt.declareVariable("msgQualifiers", new TypeLiteral<Set<String>>() {},
            Stmt.loadVariable("message").invoke("get", Set.class, CDIProtocol.QUALIFIERS)))
        .append(Stmt
            .if_(Bool.or(
                Stmt.loadClassMember("qualifiers").invoke("equals", Refs.get("msgQualifiers")),
                Bool.and(Bool.equals(Refs.get("msgQualifiers"), null),
                    Stmt.loadClassMember("qualifiers").invoke("isEmpty"))))
            .append(Stmt.loadVariable(instance.getInjector().getVarName()).invoke(method.getName(),
                Stmt.loadVariable("message").invoke("get", parm.getType().asClass(), CDIProtocol.OBJECT_REF)))
            .finish());

    return Stmt.create(ctx).nestedCall(bus).invoke(subscribeMethodName, subject, callBackBlock.finish().finish());
  }
View Full Code Here


            for (Method method : methods) {
              final Annotation aInstance = method.getAnnotation(aClass);

              final MetaClass type = MetaClassFactory.get(method.getDeclaringClass());
              final MetaMethod metaMethod = MetaClassFactory.get(method);

              entry.addProcessingDelegate(new ProcessingDelegate<MetaField>() {
                @Override
                public boolean process() {
                  injectorFactory.addType(type);
View Full Code Here

            for (Method method : methods) {
              final Annotation aInstance = method.getAnnotation(aClass);

              final MetaClass type = MetaClassFactory.get(method.getDeclaringClass());
              final MetaMethod metaMethod = MetaClassFactory.get(method);

              entry.addProcessingDelegate(new ProcessingDelegate<MetaField>() {
                @Override
                public boolean process() {
                  injectorFactory.addType(type);
View Full Code Here

  public BlockBuilder<AnonymousClassStructureBuilderImpl> publicOverridesMethod(String name, Parameter... args) {
    List<MetaClass> types = new ArrayList<MetaClass>();
    for (Parameter arg : args) {
      types.add(arg.getType());
    }
    MetaMethod method = toExtend.getBestMatchingMethod(name, types.toArray(new MetaClass[args.length]));
    if (method == null)
      throw new UndefinedMethodException("Method not found:" + name);

    return publicOverridesMethod(method, DefParameters.fromParameters(args));
  }
View Full Code Here

    CallParameters callParams = fromStatements(GenUtil.generateCallParameters(context, parameters));

    statement.generate(context);

    MetaClass[] parameterTypes = callParams.getParameterTypes();
    MetaMethod method = (staticMethod) ? statement.getType().getBestMatchingStaticMethod(methodName, parameterTypes)
            : statement.getType().getBestMatchingMethod(methodName, parameterTypes);
    if (method == null) {
      throw new UndefinedMethodException(statement.getType(), methodName, parameterTypes);
    }
View Full Code Here

    }

    for (MetaField field : type.getDeclaredFields()) {
      if (isInjectionPoint(field)) {
        if (!field.isPublic()) {
          MetaMethod meth = type.getMethod(ReflectionUtil.getSetter(field.getName()),
                  field.getType());

          if (meth == null) {
            InjectionTask task = new InjectionTask(injector, field);
            accumulator.add(task);
          }
          else {
            InjectionTask task = new InjectionTask(injector, meth);
            task.setField(field);
            accumulator.add(task);
          }

        }
        else {
          accumulator.add(new InjectionTask(injector, field));
        }
      }

      ElementType[] elTypes;
      for (Class<? extends Annotation> a : decorators) {
        elTypes = a.isAnnotationPresent(Target.class) ? a.getAnnotation(Target.class).value()
                : new ElementType[]{ElementType.FIELD};

        for (ElementType elType : elTypes) {
          switch (elType) {
            case FIELD:
              if (field.isAnnotationPresent(a)) {
                accumulator.add(new DecoratorTask(injector, field, ctx.getDecorator(a)));
              }
              break;
          }
        }
      }
    }

    for (MetaMethod meth : type.getDeclaredMethods()) {
      if (isInjectionPoint(meth)) {
        accumulator.add(new InjectionTask(injector, meth));
      }

      ElementType[] elTypes;
      for (Class<? extends Annotation> a : decorators) {
        elTypes = a.isAnnotationPresent(Target.class) ? a.getAnnotation(Target.class).value()
                : new ElementType[]{ElementType.FIELD};

        for (ElementType elType : elTypes) {
          switch (elType) {
            case METHOD:
              if (meth.isAnnotationPresent(a)) {
                accumulator.add(new DecoratorTask(injector, meth, ctx.getDecorator(a)));
              }
              break;
            case PARAMETER:
              for (MetaParameter parameter : meth.getParameters()) {
                if (parameter.isAnnotationPresent(a)) {
                  DecoratorTask task = new DecoratorTask(injector, parameter, ctx.getDecorator(a));
                  task.setMethod(meth);
                  accumulator.add(task);
                }
View Full Code Here

TOP

Related Classes of org.jboss.errai.ioc.rebind.ioc.codegen.meta.MetaMethod

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.