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


Java IntroductionInterceptor类代码示例

本文整理汇总了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;未经允许,请勿转载。