Java Code Examples for org.springframework.aop.aspectj.AspectJExpressionPointcut

The following examples show how to use org.springframework.aop.aspectj.AspectJExpressionPointcut. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
@Nullable
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
		int declarationOrderInAspect, String aspectName) {

	validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());

	// 切点信息的获取
	AspectJExpressionPointcut expressionPointcut = getPointcut(
			candidateAdviceMethod, aspectInstanceFactory.getAspectMetadata().getAspectClass());
	if (expressionPointcut == null) {
		return null;
	}
	// 注释 8.8 根据切点信息生成增强器
	return new InstantiationModelAwarePointcutAdvisorImpl(expressionPointcut, candidateAdviceMethod,
			this, aspectInstanceFactory, declarationOrderInAspect, aspectName);
}
 
Example 2
@Nullable
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
	// 注释 8.5 获取方法上的注解
	AspectJAnnotation<?> aspectJAnnotation =
			AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
	if (aspectJAnnotation == null) {
		return null;
	}

	// 使用 AspectJExpressionPointCut 实例封装获取的信息
	AspectJExpressionPointcut ajexp =
			new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class<?>[0]);
	ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
	if (this.beanFactory != null) {
		ajexp.setBeanFactory(this.beanFactory);
	}
	return ajexp;
}
 
Example 3
Source Project: spring-analysis-note   Source File: AspectJPointcutAdvisorTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testPerTarget() throws SecurityException, NoSuchMethodException {
	AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
	ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

	InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
			ajexp, TestBean.class.getMethod("getAge"), af,
			new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean"),
			1, "someBean");

	assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
	assertTrue(ajpa.isPerInstance());

	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
	assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
			TestBean.class.getMethod("getAge"), TestBean.class));

	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
			TestBean.class.getMethod("getSpouse"), TestBean.class));
}
 
Example 4
@Override
@Nullable
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
		int declarationOrderInAspect, String aspectName) {

	validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());

	AspectJExpressionPointcut expressionPointcut = getPointcut(
			candidateAdviceMethod, aspectInstanceFactory.getAspectMetadata().getAspectClass());
	if (expressionPointcut == null) {
		return null;
	}

	return new InstantiationModelAwarePointcutAdvisorImpl(expressionPointcut, candidateAdviceMethod,
			this, aspectInstanceFactory, declarationOrderInAspect, aspectName);
}
 
Example 5
@Nullable
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
	AspectJAnnotation<?> aspectJAnnotation =
			AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
	if (aspectJAnnotation == null) {
		return null;
	}

	AspectJExpressionPointcut ajexp =
			new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class<?>[0]);
	ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
	if (this.beanFactory != null) {
		ajexp.setBeanFactory(this.beanFactory);
	}
	return ajexp;
}
 
Example 6
@Test
public void testPerTarget() throws SecurityException, NoSuchMethodException {
	AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
	ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

	InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
			ajexp, TestBean.class.getMethod("getAge"), af,
			new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean"),
			1, "someBean");

	assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
	assertTrue(ajpa.isPerInstance());

	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
	assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
			TestBean.class.getMethod("getAge"), TestBean.class));

	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
			TestBean.class.getMethod("getSpouse"), TestBean.class));
}
 
Example 7
/**
 * 设置注册bean动态AOP信息
 *
 * @param configs
 * @param beanFactory
 */
private void setAopInfo(List<String> configs, ConfigurableListableBeanFactory beanFactory) {

    if (beanFactory instanceof BeanDefinitionRegistry) {
        BeanDefinitionRegistry beanDefinitionRegistry = (BeanDefinitionRegistry) beanFactory;
        for (String config : configs) {
            //增强器
            RootBeanDefinition advisor = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
            advisor.getPropertyValues().addPropertyValue("adviceBeanName", new RuntimeBeanReference("httpParamsValidateAdvisor").getBeanName());
            //切点类
            RootBeanDefinition pointCut = new RootBeanDefinition(AspectJExpressionPointcut.class);
            pointCut.setScope(BeanDefinition.SCOPE_PROTOTYPE);
            pointCut.setSynthetic(true);
            pointCut.getPropertyValues().addPropertyValue("expression", config);

            advisor.getPropertyValues().addPropertyValue("pointcut", pointCut);
            //注册到spring容器
            String beanName = BeanDefinitionReaderUtils.generateBeanName(advisor, beanDefinitionRegistry, false);
            beanDefinitionRegistry.registerBeanDefinition(beanName, advisor);
        }
    }

}
 
Example 8
@Test
public void testPerTarget() throws SecurityException, NoSuchMethodException {
	AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
	ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

	InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
			new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean");
	assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
	assertTrue(ajpa.isPerInstance());

	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
	assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
			TestBean.class.getMethod("getAge", (Class[]) null),
			TestBean.class));

	assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
			TestBean.class.getMethod("getSpouse", (Class[]) null),
			TestBean.class));
}
 
Example 9
public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
		Method aspectJAdviceMethod, AspectJAdvisorFactory aspectJAdvisorFactory,
		MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
	// 简单赋值
	this.declaredPointcut = declaredPointcut;
	this.declaringClass = aspectJAdviceMethod.getDeclaringClass();
	this.methodName = aspectJAdviceMethod.getName();
	this.parameterTypes = aspectJAdviceMethod.getParameterTypes();
	this.aspectJAdviceMethod = aspectJAdviceMethod;
	this.aspectJAdvisorFactory = aspectJAdvisorFactory;
	this.aspectInstanceFactory = aspectInstanceFactory;
	this.declarationOrder = declarationOrder;
	this.aspectName = aspectName;

	if (aspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
		// Static part of the pointcut is a lazy type.
		Pointcut preInstantiationPointcut = Pointcuts.union(
				aspectInstanceFactory.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);

		// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
		// If it's not a dynamic pointcut, it may be optimized out
		// by the Spring AOP infrastructure after the first evaluation.
		this.pointcut = new PerTargetInstantiationModelPointcut(
				this.declaredPointcut, preInstantiationPointcut, aspectInstanceFactory);
		this.lazy = true;
	}
	else {
		// A singleton aspect.
		this.pointcut = this.declaredPointcut;
		this.lazy = false;
		// 初始化增强器
		this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
	}
}
 
Example 10
public PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
		Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {

	this.declaredPointcut = declaredPointcut;
	this.preInstantiationPointcut = preInstantiationPointcut;
	if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator) {
		this.aspectInstanceFactory = (LazySingletonAspectInstanceFactoryDecorator) aspectInstanceFactory;
	}
}
 
Example 11
Source Project: spring-analysis-note   Source File: ConfigBeanDefinitionParser.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a {@link BeanDefinition} for the {@link AspectJExpressionPointcut} class using
 * the supplied pointcut expression.
 */
protected AbstractBeanDefinition createPointcutDefinition(String expression) {
	RootBeanDefinition beanDefinition = new RootBeanDefinition(AspectJExpressionPointcut.class);
	beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	beanDefinition.setSynthetic(true);
	beanDefinition.getPropertyValues().add(EXPRESSION, expression);
	return beanDefinition;
}
 
Example 12
Source Project: spring-analysis-note   Source File: AspectJPointcutAdvisorTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
	AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
	ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

	InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
			ajexp, TestBean.class.getMethod("getAge"), af,
			new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null), "someBean"),
			1, "someBean");

	assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
	assertFalse(ajpa.isPerInstance());
}
 
Example 13
@Before
public void setUp() throws Exception {
	this.comparator = new AspectJPrecedenceComparator();
	this.anyOldMethod = getClass().getMethods()[0];
	this.anyOldPointcut = new AspectJExpressionPointcut();
	this.anyOldPointcut.setExpression("execution(* *(..))");
}
 
Example 14
Source Project: spring-analysis-note   Source File: GroovyAspectTests.java    License: MIT License 5 votes vote down vote up
@Test
public void manualGroovyBeanWithStaticPointcut() throws Exception {
	TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
			new ClassPathResource("GroovyServiceImpl.grv", getClass())));

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(String.format("execution(* %s.TestService+.*(..))", ClassUtils.getPackageName(getClass())));
	testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
 
Example 15
Source Project: spring-analysis-note   Source File: GroovyAspectTests.java    License: MIT License 5 votes vote down vote up
@Test
public void manualGroovyBeanWithDynamicPointcut() throws Exception {
	TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
			new ClassPathResource("GroovyServiceImpl.grv", getClass())));

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
	testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", false);
}
 
Example 16
Source Project: spring-analysis-note   Source File: GroovyAspectTests.java    License: MIT License 5 votes vote down vote up
@Test
public void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception {
	TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
			new ClassPathResource("GroovyServiceImpl.grv", getClass())));

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
	testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
 
Example 17
public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
		Method aspectJAdviceMethod, AspectJAdvisorFactory aspectJAdvisorFactory,
		MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {

	this.declaredPointcut = declaredPointcut;
	this.declaringClass = aspectJAdviceMethod.getDeclaringClass();
	this.methodName = aspectJAdviceMethod.getName();
	this.parameterTypes = aspectJAdviceMethod.getParameterTypes();
	this.aspectJAdviceMethod = aspectJAdviceMethod;
	this.aspectJAdvisorFactory = aspectJAdvisorFactory;
	this.aspectInstanceFactory = aspectInstanceFactory;
	this.declarationOrder = declarationOrder;
	this.aspectName = aspectName;

	if (aspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
		// Static part of the pointcut is a lazy type.
		Pointcut preInstantiationPointcut = Pointcuts.union(
				aspectInstanceFactory.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);

		// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
		// If it's not a dynamic pointcut, it may be optimized out
		// by the Spring AOP infrastructure after the first evaluation.
		this.pointcut = new PerTargetInstantiationModelPointcut(
				this.declaredPointcut, preInstantiationPointcut, aspectInstanceFactory);
		this.lazy = true;
	}
	else {
		// A singleton aspect.
		this.pointcut = this.declaredPointcut;
		this.lazy = false;
		this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
	}
}
 
Example 18
public PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
		Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {

	this.declaredPointcut = declaredPointcut;
	this.preInstantiationPointcut = preInstantiationPointcut;
	if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator) {
		this.aspectInstanceFactory = (LazySingletonAspectInstanceFactoryDecorator) aspectInstanceFactory;
	}
}
 
Example 19
Source Project: java-technology-stack   Source File: ConfigBeanDefinitionParser.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a {@link BeanDefinition} for the {@link AspectJExpressionPointcut} class using
 * the supplied pointcut expression.
 */
protected AbstractBeanDefinition createPointcutDefinition(String expression) {
	RootBeanDefinition beanDefinition = new RootBeanDefinition(AspectJExpressionPointcut.class);
	beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
	beanDefinition.setSynthetic(true);
	beanDefinition.getPropertyValues().add(EXPRESSION, expression);
	return beanDefinition;
}
 
Example 20
@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
	AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
	ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

	InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
			ajexp, TestBean.class.getMethod("getAge"), af,
			new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null), "someBean"),
			1, "someBean");

	assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
	assertFalse(ajpa.isPerInstance());
}
 
Example 21
@Before
public void setUp() throws Exception {
	this.comparator = new AspectJPrecedenceComparator();
	this.anyOldMethod = getClass().getMethods()[0];
	this.anyOldPointcut = new AspectJExpressionPointcut();
	this.anyOldPointcut.setExpression("execution(* *(..))");
}
 
Example 22
Source Project: java-technology-stack   Source File: GroovyAspectTests.java    License: MIT License 5 votes vote down vote up
@Test
public void manualGroovyBeanWithStaticPointcut() throws Exception {
	TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
			new ClassPathResource("GroovyServiceImpl.grv", getClass())));

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(String.format("execution(* %s.TestService+.*(..))", ClassUtils.getPackageName(getClass())));
	testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
 
Example 23
Source Project: java-technology-stack   Source File: GroovyAspectTests.java    License: MIT License 5 votes vote down vote up
@Test
public void manualGroovyBeanWithDynamicPointcut() throws Exception {
	TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
			new ClassPathResource("GroovyServiceImpl.grv", getClass())));

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
	testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", false);
}
 
Example 24
Source Project: java-technology-stack   Source File: GroovyAspectTests.java    License: MIT License 5 votes vote down vote up
@Test
public void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception {
	TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
			new ClassPathResource("GroovyServiceImpl.grv", getClass())));

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
	testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
 
Example 25
public PerformanceMonitorAdvisor(PerformanceMonitorInterceptor performanceMonitorInterceptor) {
	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(
			"com.packt.springhighperformance.ch03.bankingapp.aspect.TransferMonitoringAspect.transfer()");
	this.setPointcut(pointcut);
	this.setAdvice(performanceMonitorInterceptor);
}
 
Example 26
public CustomPerformanceMonitorAdvisor(CustomPerformanceMonitorInterceptor performanceMonitorInterceptor) {
	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression(
			"com.packt.springhighperformance.ch03.bankingapp.aspect.TransferMonitoringAspect.transfer()");
	this.setPointcut(pointcut);
	this.setAdvice(performanceMonitorInterceptor);
}
 
Example 27
@Override
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
		int declarationOrderInAspect, String aspectName) {

	validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());

	AspectJExpressionPointcut expressionPointcut = getPointcut(
			candidateAdviceMethod, aspectInstanceFactory.getAspectMetadata().getAspectClass());
	if (expressionPointcut == null) {
		return null;
	}

	return new InstantiationModelAwarePointcutAdvisorImpl(expressionPointcut, candidateAdviceMethod,
			this, aspectInstanceFactory, declarationOrderInAspect, aspectName);
}
 
Example 28
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
	AspectJAnnotation<?> aspectJAnnotation =
			AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAdviceMethod);
	if (aspectJAnnotation == null) {
		return null;
	}

	AspectJExpressionPointcut ajexp =
			new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class<?>[0]);
	ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
	ajexp.setBeanFactory(this.beanFactory);
	return ajexp;
}
 
Example 29
public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
		Method aspectJAdviceMethod, AspectJAdvisorFactory aspectJAdvisorFactory,
		MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {

	this.declaredPointcut = declaredPointcut;
	this.declaringClass = aspectJAdviceMethod.getDeclaringClass();
	this.methodName = aspectJAdviceMethod.getName();
	this.parameterTypes = aspectJAdviceMethod.getParameterTypes();
	this.aspectJAdviceMethod = aspectJAdviceMethod;
	this.aspectJAdvisorFactory = aspectJAdvisorFactory;
	this.aspectInstanceFactory = aspectInstanceFactory;
	this.declarationOrder = declarationOrder;
	this.aspectName = aspectName;

	if (aspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
		// Static part of the pointcut is a lazy type.
		Pointcut preInstantiationPointcut = Pointcuts.union(
				aspectInstanceFactory.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);

		// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
		// If it's not a dynamic pointcut, it may be optimized out
		// by the Spring AOP infrastructure after the first evaluation.
		this.pointcut = new PerTargetInstantiationModelPointcut(
				this.declaredPointcut, preInstantiationPointcut, aspectInstanceFactory);
		this.lazy = true;
	}
	else {
		// A singleton aspect.
		this.pointcut = this.declaredPointcut;
		this.lazy = false;
		this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
	}
}
 
Example 30
private PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
		Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
	this.declaredPointcut = declaredPointcut;
	this.preInstantiationPointcut = preInstantiationPointcut;
	if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator) {
		this.aspectInstanceFactory = (LazySingletonAspectInstanceFactoryDecorator) aspectInstanceFactory;
	}
}