Ejemplo n.º 1
0
  @Before
  public void setup() {
    TransfuseTestInjector.inject(this);

    methodInterceptorASTType =
        astClassFactory.buildASTClassType(AOPAnnotationMethodInterceptor.class);
    aopAnnotationASTType = astClassFactory.buildASTClassType(AOPAnnotation.class);
    proxyTargetASTType = astClassFactory.buildASTClassType(AOPProxyTarget.class);
    proxyTargetInjectionNode =
        injectionPointFactory.buildInjectionNode(
            proxyTargetASTType, simpleAnalysisContextFactory.buildContext());
  }
  @Override
  public void analyzeField(
      InjectionNode injectionNode,
      ASTType concreteType,
      ASTField astField,
      AnalysisContext context) {

    if (astField.isAnnotated(NonConfigurationInstance.class)) {
      NonConfigurationAspect aspect = buildAspect(injectionNode);
      aspect.add(injectionPointFactory.buildInjectionPoint(concreteType, astField, context));

      if (!injectionNode.containsAspect(ASTInjectionAspect.class)) {
        injectionNode.addAspect(ASTInjectionAspect.class, new ASTInjectionAspect());
      }

      injectionNode
          .getAspect(ASTInjectionAspect.class)
          .setAssignmentType(ASTInjectionAspect.InjectionAssignmentType.FIELD);
    }
  }