当前位置: 首页>>代码示例>>Java>>正文


Java AspectJExpressionPointcut类代码示例

本文整理汇总了Java中org.springframework.aop.aspectj.AspectJExpressionPointcut的典型用法代码示例。如果您正苦于以下问题:Java AspectJExpressionPointcut类的具体用法?Java AspectJExpressionPointcut怎么用?Java AspectJExpressionPointcut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AspectJExpressionPointcut类属于org.springframework.aop.aspectj包,在下文中一共展示了AspectJExpressionPointcut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: defaultPointcutAdvisor

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
/**
 * 织入
 */
@Bean
public DefaultPointcutAdvisor defaultPointcutAdvisor(TransactionInterceptor interceptor) {
    // 切入点
    AspectJExpressionPointcut expression = new AspectJExpressionPointcut();
    expression.setExpression("execution(* org.sj.alexa.service.tx.I*Service.*(..))");
    return new DefaultPointcutAdvisor(expression, interceptor);
}
 
开发者ID:shijian-ws,项目名称:alexa,代码行数:11,代码来源:TransactionConfiguration.java

示例2: testPerTarget

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:AspectJPointcutAdvisorTests.java

示例3: packageTraceAdvisor

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public Advisor packageTraceAdvisor() {
    ComposablePointcut resultPointcut = new ComposablePointcut();
    {
        List<String> basePackages = findBasePackages();
        String pointcutExpression = makeExpression(basePackages);
        AspectJExpressionPointcut packagePointcut = new AspectJExpressionPointcut();
        log.info("Include package Pointcut expression : {}", pointcutExpression);
        packagePointcut.setExpression(pointcutExpression);
        resultPointcut.intersection((Pointcut) packagePointcut);
    }

    String excludeAnnotation = buildExcludeAnnotation();
    log.info("Exclude Annotation Pointcut expression : {}", excludeAnnotation);

    AspectJExpressionPointcut basePointcut = new AspectJExpressionPointcut();
    basePointcut.setExpression(excludeAnnotation);
    resultPointcut.intersection((Pointcut) basePointcut);

    DefaultPointcutAdvisor pointcutAdvisor = new DefaultPointcutAdvisor(resultPointcut, new TraceAopInterceptor(traceLogManager));
    pointcutAdvisor.setOrder(Integer.MAX_VALUE);
    return pointcutAdvisor;
}
 
开发者ID:acupple,项目名称:stormv-spring-tracer,代码行数:25,代码来源:SimpleTraceConfiguration.java

示例4: getAdvisor

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@Override
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
		int declarationOrderInAspect, String aspectName) {

	validate(aif.getAspectMetadata().getAspectClass());

	AspectJExpressionPointcut ajexp =
			getPointcut(candidateAdviceMethod, aif.getAspectMetadata().getAspectClass());
	if (ajexp == null) {
		return null;
	}
	return new InstantiationModelAwarePointcutAdvisorImpl(
			this, ajexp, aif, candidateAdviceMethod, declarationOrderInAspect, aspectName);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ReflectiveAspectJAdvisorFactory.java

示例5: getPointcut

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
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());
	return ajexp;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ReflectiveAspectJAdvisorFactory.java

示例6: createPointcutExpression

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
/**
 * The pointcut and advice annotations both have an "argNames" member which contains a
 * comma-separated list of the argument names. We use this (if non-empty) to build the
 * formal parameters for the pointcut.
 */
protected AspectJExpressionPointcut createPointcutExpression(
		Method annotatedMethod, Class<?> declarationScope, String[] pointcutParameterNames) {

	Class<?> [] pointcutParameterTypes = new Class<?>[0];
	if (pointcutParameterNames != null) {
		pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod);
	}

	AspectJExpressionPointcut ajexp =
			new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes);
	ajexp.setLocation(annotatedMethod.toString());
	return ajexp;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:AbstractAspectJAdvisorFactory.java

示例7: InstantiationModelAwarePointcutAdvisorImpl

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
public InstantiationModelAwarePointcutAdvisorImpl(AspectJAdvisorFactory af, AspectJExpressionPointcut ajexp,
		MetadataAwareAspectInstanceFactory aif, Method method, int declarationOrderInAspect, String aspectName) {

	this.declaredPointcut = ajexp;
	this.method = method;
	this.atAspectJAdvisorFactory = af;
	this.aspectInstanceFactory = aif;
	this.declarationOrder = declarationOrderInAspect;
	this.aspectName = aspectName;

	if (aif.getAspectMetadata().isLazilyInstantiated()) {
		// Static part of the pointcut is a lazy type.
		Pointcut preInstantiationPointcut =
				Pointcuts.union(aif.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, aif);
		this.lazy = true;
	}
	else {
		// A singleton aspect.
		this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
		this.pointcut = declaredPointcut;
		this.lazy = false;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:InstantiationModelAwarePointcutAdvisorImpl.java

示例8: PerTargetInstantiationModelPointcut

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
private PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
		Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
	this.declaredPointcut = declaredPointcut;
	this.preInstantiationPointcut = preInstantiationPointcut;
	if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator) {
		this.aspectInstanceFactory = (LazySingletonAspectInstanceFactoryDecorator) aspectInstanceFactory;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:InstantiationModelAwarePointcutAdvisorImpl.java

示例9: createPointcutDefinition

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ConfigBeanDefinitionParser.java

示例10: testSingleton

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
	AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
	ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);

	InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
			new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"),
			TestBean.class.getMethod("getAge", (Class[]) null),1,"someBean");
	assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
	assertFalse(ajpa.isPerInstance());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:AspectJPointcutAdvisorTests.java

示例11: setUp

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.comparator = new AspectJPrecedenceComparator();
	this.anyOldMethod = getClass().getMethods()[0];
	this.anyOldPointcut = new AspectJExpressionPointcut();
	this.anyOldPointcut.setExpression("execution(* *(..))");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:AspectJPrecedenceComparatorTests.java

示例12: manualGroovyBeanWithStaticPointcut

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:GroovyAspectTests.java

示例13: manualGroovyBeanWithDynamicPointcut

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:GroovyAspectTests.java

示例14: manualGroovyBeanWithDynamicPointcutProxyTargetClass

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
@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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:GroovyAspectTests.java

示例15: createDbShardInterceptor

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入依赖的package包/类
public static DefaultPointcutAdvisor createDbShardInterceptor(String springAop) {
    DefaultPointcutAdvisor re = new DefaultPointcutAdvisor();
    AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut();
    aspectJExpressionPointcut.setExpression(springAop);
    re.setPointcut(aspectJExpressionPointcut);

    re.setAdvice(new MethodInterceptor() {
        public Object invoke(MethodInvocation methodInvocation) throws Throwable {
            Object clz = methodInvocation.getThis();
            DbRouter annotation = clz.getClass().getAnnotation(DbRouter.class);
            if (annotation != null) {
                DynamicDataSource.setDb(annotation.value());
                Transfer.setForceUseTable(annotation.useTable());
            } else {
                DbRouter dbRouter = methodInvocation.getMethod().getAnnotation(DbRouter.class);
                if (dbRouter != null) {
                    DynamicDataSource.setDb(dbRouter.value());
                    Transfer.setForceUseTable(dbRouter.useTable());
                }
            }
            System.out.println("DB----> " + DynamicDataSource.getDb());
            try {
                return methodInvocation.proceed();
            } finally {
                DynamicDataSource.clearDb();
                Transfer.clear();
            }
        }
    });
    return re;
}
 
开发者ID:maniaclee,项目名称:shardy,代码行数:32,代码来源:DbShardFactory.java


注:本文中的org.springframework.aop.aspectj.AspectJExpressionPointcut类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。