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

Java IntroductionInterceptor类代码示例

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

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



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

示例1: DelegatePerTargetObjectIntroductionInterceptor

import org.springframework.aop.IntroductionInterceptor; //导入依赖的package包/类
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
	this.defaultImplType = defaultImplType;
	this.interfaceType = interfaceType;
	// Create a new delegate now (but don't store it in the map).
	// We do this for two reasons:
	// 1) to fail early if there is a problem instantiating delegates
	// 2) to populate the interface map once and once only
	Object delegate = createNewDelegate();
	implementInterfacesOnObject(delegate);
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DelegatePerTargetObjectIntroductionInterceptor.java


示例2: init

import org.springframework.aop.IntroductionInterceptor; //导入依赖的package包/类
/**
 * Both constructors use this init method, as it is impossible to pass
 * a "this" reference from one constructor to another.
 * @param delegate the delegate object
 */
private void init(Object delegate) {
	Assert.notNull(delegate, "Delegate must not be null");
	this.delegate = delegate;
	implementInterfacesOnObject(delegate);

	// We don't want to expose the control interface
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:DelegatingIntroductionInterceptor.java


示例3: DelegatePerTargetObjectIntroductionInterceptor

import org.springframework.aop.IntroductionInterceptor; //导入依赖的package包/类
public DelegatePerTargetObjectIntroductionInterceptor(Class defaultImplType, Class interfaceType) {
	this.defaultImplType = defaultImplType;
	this.interfaceType = interfaceType;
	// cCeate a new delegate now (but don't store it in the map).
	// We do this for two reasons:
	// 1) to fail early if there is a problem instantiating delegates
	// 2) to populate the interface map once and once only
	Object delegate = createNewDelegate();
	implementInterfacesOnObject(delegate);
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:13,代码来源:DelegatePerTargetObjectIntroductionInterceptor.java


示例4: testAutomaticInterfaceRecognitionInSubclass

import org.springframework.aop.IntroductionInterceptor; //导入依赖的package包/类
@Test
public void testAutomaticInterfaceRecognitionInSubclass() throws Exception {
	final long t = 1001L;
	@SuppressWarnings("serial")
	class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
		@Override
		public void foo() throws Exception {
		}
		@Override
		public long getTimeStamp() {
			return t;
		}
	}

	DelegatingIntroductionInterceptor ii = new TestII();

	TestBean target = new TestBean();

	ProxyFactory pf = new ProxyFactory(target);
	IntroductionAdvisor ia = new DefaultIntroductionAdvisor(ii);
	assertTrue(ia.isPerInstance());
	pf.addAdvisor(0, ia);

	//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
	TimeStamped ts = (TimeStamped) pf.getProxy();

	assertThat(ts, instanceOf(TimeStamped.class));
	// Shoulnd't proxy framework interfaces
	assertTrue(!(ts instanceof MethodInterceptor));
	assertTrue(!(ts instanceof IntroductionInterceptor));

	assertTrue(ts.getTimeStamp() == t);
	((ITester) ts).foo();
	((ITestBean) ts).getAge();

	// Test removal
	ii.suppressInterface(TimeStamped.class);
	// Note that we need to construct a new proxy factory,
	// or suppress the interface on the proxy factory
	pf = new ProxyFactory(target);
	pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
	Object o = pf.getProxy();
	assertTrue(!(o instanceof TimeStamped));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:45,代码来源:DelegatingIntroductionInterceptorTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java BlockWorkbench类代码示例发布时间:2022-05-22
下一篇:
Java GraphLayout类代码示例发布时间: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