• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StaticMethodMatcherPointcutAdvisor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: controllersAdvisor

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
/**
 * @return customizableTraceInterceptor sur les méthodes public des classes du package controllers
 */
@Bean
public Advisor controllersAdvisor() {
	return new StaticMethodMatcherPointcutAdvisor(customizableTraceInterceptor()) {

		/**serialVersionUID**/
		private static final long serialVersionUID = 7956297913037928802L;

		@Override
		public boolean matches(Method method, Class<?> clazz) {
			return Modifier.isPublic(method.getModifiers()) && clazz.getPackage() != null && clazz.getPackage().getName().startsWith(UserController.class.getPackage().getName());
		}
	};
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:17,代码来源:TraceFullConfig.java


示例2: viewsEnterAdvisor

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
/**
 * @return customizableTraceInterceptor sur les méthodes enter des vues
 */
@Bean
public Advisor viewsEnterAdvisor() {
	return new StaticMethodMatcherPointcutAdvisor(customizableTraceInterceptor()) {

		/**serialVersionUID**/
		private static final long serialVersionUID = 3484525172356507679L;

		@Override
		public boolean matches(Method method, Class<?> clazz) {
			return clazz.isAnnotationPresent(SpringView.class) && "enter".equals(method.getName());
		}
	};
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:17,代码来源:TraceFullConfig.java


示例3: controllersAdvisor

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
/**
 * @return customizableTraceInterceptor sur les méthodes public des classes du package controllers
 */
@Bean
public Advisor controllersAdvisor() {
	return new StaticMethodMatcherPointcutAdvisor(customizableTraceInterceptor()) {
		
		/**serialVersionUID**/
		private static final long serialVersionUID = -6220123343664238769L;

		@Override
		public boolean matches(Method method, Class<?> clazz) {
			return Modifier.isPublic(method.getModifiers()) && clazz.getPackage() != null && clazz.getPackage().getName().startsWith(UserController.class.getPackage().getName());
		}
	};
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:17,代码来源:TraceConfig.java


示例4: viewsEnterAdvisor

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
/**
 * @return customizableTraceInterceptor sur les méthodes enter des vues
 */
@Bean
public Advisor viewsEnterAdvisor() {
	return new StaticMethodMatcherPointcutAdvisor(customizableTraceInterceptor()) {
		

		/**serialVersionUID**/
		private static final long serialVersionUID = -1111119064011020300L;

		@Override
		public boolean matches(Method method, Class<?> clazz) {
			return clazz.isAnnotationPresent(SpringView.class) && "enter".equals(method.getName());
		}
	};
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:18,代码来源:TraceConfig.java


示例5: testCloneInvocationToProceedThreeTimes

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
/**
 * There are times when we want to call proceed() twice.
 * We can do this if we clone the invocation.
 */
@Test
public void testCloneInvocationToProceedThreeTimes() throws Throwable {
	TestBean tb = new TestBean();
	ProxyFactory pc = new ProxyFactory(tb);
	pc.addInterface(ITestBean.class);

	MethodInterceptor twoBirthdayInterceptor = new MethodInterceptor() {
		@Override
		public Object invoke(MethodInvocation mi) throws Throwable {
			// Clone the invocation to proceed three times
			// "The Moor's Last Sigh": this technology can cause premature aging
			MethodInvocation clone1 = ((ReflectiveMethodInvocation) mi).invocableClone();
			MethodInvocation clone2 = ((ReflectiveMethodInvocation) mi).invocableClone();
			clone1.proceed();
			clone2.proceed();
			return mi.proceed();
		}
	};
	@SuppressWarnings("serial")
	StaticMethodMatcherPointcutAdvisor advisor = new StaticMethodMatcherPointcutAdvisor(twoBirthdayInterceptor) {
		@Override
		public boolean matches(Method m, Class<?> targetClass) {
			return "haveBirthday".equals(m.getName());
		}
	};
	pc.addAdvisor(advisor);
	ITestBean it = (ITestBean) createProxy(pc);

	final int age = 20;
	it.setAge(age);
	assertEquals(age, it.getAge());
	// Should return the age before the third, AOP-induced birthday
	assertEquals(age + 2, it.haveBirthday());
	// Return the final age produced by 3 birthdays
	assertEquals(age + 3, it.getAge());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:41,代码来源:AbstractAopProxyTests.java


示例6: testBeforeAdvisorIsInvoked

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
@Test
public void testBeforeAdvisorIsInvoked() {
	CountingBeforeAdvice cba = new CountingBeforeAdvice();
	@SuppressWarnings("serial")
	Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
		@Override
		public boolean matches(Method m, Class<?> targetClass) {
			return m.getParameterTypes().length == 0;
		}
	};
	TestBean target = new TestBean();
	target.setAge(80);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvice(new NopInterceptor());
	pf.addAdvisor(matchesNoArgs);
	assertEquals("Advisor was added", matchesNoArgs, pf.getAdvisors()[1]);
	ITestBean proxied = (ITestBean) createProxy(pf);
	assertEquals(0, cba.getCalls());
	assertEquals(0, cba.getCalls("getAge"));
	assertEquals(target.getAge(), proxied.getAge());
	assertEquals(1, cba.getCalls());
	assertEquals(1, cba.getCalls("getAge"));
	assertEquals(0, cba.getCalls("setAge"));
	// Won't be advised
	proxied.setAge(26);
	assertEquals(1, cba.getCalls());
	assertEquals(26, proxied.getAge());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:AbstractAopProxyTests.java


示例7: testMultiAdvice

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; //导入依赖的package包/类
@Test
public void testMultiAdvice() throws Throwable {
	CountingMultiAdvice cca = new CountingMultiAdvice();
	@SuppressWarnings("serial")
	Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
		@Override
		public boolean matches(Method m, Class<?> targetClass) {
			return m.getParameterTypes().length == 0 || "exceptional".equals(m.getName());
		}
	};
	TestBean target = new TestBean();
	target.setAge(80);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvice(new NopInterceptor());
	pf.addAdvisor(matchesNoArgs);
	assertEquals("Advisor was added", matchesNoArgs, pf.getAdvisors()[1]);
	ITestBean proxied = (ITestBean) createProxy(pf);

	assertEquals(0, cca.getCalls());
	assertEquals(0, cca.getCalls("getAge"));
	assertEquals(target.getAge(), proxied.getAge());
	assertEquals(2, cca.getCalls());
	assertEquals(2, cca.getCalls("getAge"));
	assertEquals(0, cca.getCalls("setAge"));
	// Won't be advised
	proxied.setAge(26);
	assertEquals(2, cca.getCalls());
	assertEquals(26, proxied.getAge());
	assertEquals(4, cca.getCalls());
	try {
		proxied.exceptional(new SpecializedUncheckedException("foo", (SQLException)null));
		fail("Should have thrown CannotGetJdbcConnectionException");
	}
	catch (SpecializedUncheckedException ex) {
		// expected
	}
	assertEquals(6, cca.getCalls());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:AbstractAopProxyTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ErrorCodes类代码示例发布时间:2022-05-22
下一篇:
Java BitArray类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap