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


Java AspectJExpressionPointcut.setExpression方法代码示例

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


在下文中一共展示了AspectJExpressionPointcut.setExpression方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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:txazo,项目名称:spring,代码行数:13,代码来源:ReflectiveAspectJAdvisorFactory.java

示例11: traceAdvisor

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入方法依赖的package包/类
@Bean
public Advisor traceAdvisor() {

	AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
	pointcut.setExpression("execution(public * org.springframework.data.repository.Repository+.*(..))");

	return new DefaultPointcutAdvisor(pointcut, interceptor());
}
 
开发者ID:przodownikR1,项目名称:springJpaKata,代码行数:9,代码来源:AopProfiler.java

示例12: 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:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:ReflectiveAspectJAdvisorFactory.java

示例13: testManualGroovyBeanWithStaticPointcut

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入方法依赖的package包/类
@Test
public void testManualGroovyBeanWithStaticPointcut() throws Exception {
	LogUserAdvice logAdvice = new LogUserAdvice();

	GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
	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:deathspeeder,项目名称:class-guard,代码行数:13,代码来源:GroovyAspectTests.java

示例14: testManualGroovyBeanWithDynamicPointcut

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入方法依赖的package包/类
@Test
public void testManualGroovyBeanWithDynamicPointcut() throws Exception {
	LogUserAdvice logAdvice = new LogUserAdvice();

	GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
	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:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:GroovyAspectTests.java

示例15: testManualGroovyBeanWithDynamicPointcutProxyTargetClass

import org.springframework.aop.aspectj.AspectJExpressionPointcut; //导入方法依赖的package包/类
@Test
public void testManualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception {
	LogUserAdvice logAdvice = new LogUserAdvice();

	GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
	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:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:GroovyAspectTests.java


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