@Test public void testAnalysis() { AnalysisContext analysisContext = simpleAnalysisContextFactory.buildContext(); analysisContext.getAOPRepository().put(aopAnnotationASTType, methodInterceptorASTType); for (ASTMethod astMethod : proxyTargetASTType.getMethods()) { proxyAnalyzer.analyzeMethod( proxyTargetInjectionNode, proxyTargetASTType, astMethod, analysisContext); } assertTrue(proxyTargetInjectionNode.containsAspect(AOPProxyAspect.class)); AOPProxyAspect aspect = proxyTargetInjectionNode.getAspect(AOPProxyAspect.class); for (ASTMethod astMethod : proxyTargetASTType.getMethods()) { assertTrue(aspect.getMethodInterceptors().containsKey(astMethod)); Set<InjectionNode> interceptorInjectionNodes = aspect.getMethodInterceptors().get(astMethod); for (InjectionNode interceptorInjectionNode : interceptorInjectionNodes) { assertEquals(methodInterceptorASTType, interceptorInjectionNode.getASTType()); } } }
@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); } }
private NonConfigurationAspect buildAspect(InjectionNode injectionNode) { if (!injectionNode.containsAspect(NonConfigurationAspect.class)) { injectionNode.addAspect(new NonConfigurationAspect()); } return injectionNode.getAspect(NonConfigurationAspect.class); }