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


Java DelegatingIntroductionInterceptor类代码示例

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


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

示例1: create

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Helper method to create a {@link PermissionCheckedValue} from an existing <code>Object</code>.
 * 
 * @param object        the <code>Object</code> to proxy
 * @return                  a <code>Object</code> of the same type but including the
 *                          {@link PermissionCheckedValue} interface
 */
@SuppressWarnings("unchecked")
public static final <T extends Object> T create(T object)
{
    // Create the mixin
    DelegatingIntroductionInterceptor mixin = new PermissionCheckedValueMixin();
    // Create the advisor
    IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(mixin, PermissionCheckedValue.class);
    // Proxy
    ProxyFactory pf = new ProxyFactory(object);
    pf.addAdvisor(advisor);
    Object proxiedObject = pf.getProxy();
    
    // Done
    return (T) proxiedObject;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:PermissionCheckedValue.java

示例2: create

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Helper method to create a {@link PermissionCheckedCollection} from an existing <code>Collection</code>
 * 
 * @param <TT>              the type of the <code>Collection</code>
 * @param collection        the <code>Collection</code> to proxy
 * @param isCutOff          <tt>true</tt> if permission checking was cut off before completion
 * @param sizeUnchecked     number of entries from the original collection that were not checked
 * @param sizeOriginal      number of entries in the original, pre-checked collection
 * @return                  a <code>Collection</code> of the same type but including the
 *                          {@link PermissionCheckedCollection} interface
 */
@SuppressWarnings("unchecked")
public static final <TT> Collection<TT> create(
        Collection<TT> collection,
        boolean isCutOff, int sizeUnchecked, int sizeOriginal)
{
    // Create the mixin
    DelegatingIntroductionInterceptor mixin = new PermissionCheckedCollectionMixin<Integer>(
            isCutOff,
            sizeUnchecked,
            sizeOriginal
            );
    // Create the advisor
    IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(mixin, PermissionCheckedCollection.class);
    // Proxy
    ProxyFactory pf = new ProxyFactory(collection);
    pf.addAdvisor(advisor);
    Object proxiedObject = pf.getProxy();
    
    // Done
    return (Collection<TT>) proxiedObject;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:PermissionCheckedCollection.java

示例3: create

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Helper method to create a {@link PermissionCheckCollection} from an existing <code>Collection</code>
 * 
 * @param <TT>              the type of the <code>Collection</code>
 * @param collection        the <code>Collection</code> to proxy
 * @param targetResultCount the desired number of results or default to the collection size
 * @param cutOffAfterTimeMs the number of milliseconds to wait before cut-off or zero to use the system default
 *                          time-based cut-off.
 * @param cutOffAfterCount  the number of permission checks to process before cut-off or zero to use the system default
 *                          count-based cut-off.
 * @return                  a <code>Collection</code> of the same type but including the
 *                          {@link PermissionCheckCollection} interface
 */
@SuppressWarnings("unchecked")
public static final <TT> Collection<TT> create(
        Collection<TT> collection,
        int targetResultCount, long cutOffAfterTimeMs, int cutOffAfterCount)
{
    if (targetResultCount <= 0)
    {
        targetResultCount = collection.size();
    }
    // Create the mixin
    DelegatingIntroductionInterceptor mixin = new PermissionCheckCollectionMixin<Integer>(
            targetResultCount,
            cutOffAfterTimeMs,
            cutOffAfterCount);
    // Create the advisor
    IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(mixin, PermissionCheckCollection.class);
    // Proxy
    ProxyFactory pf = new ProxyFactory(collection);
    pf.addAdvisor(advisor);
    Object proxiedObject = pf.getProxy();
    
    // Done
    return (Collection<TT>) proxiedObject;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:PermissionCheckCollection.java

示例4: createRefreshableProxy

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Create a refreshable proxy for the given AOP TargetSource.
 * @param ts the refreshable TargetSource
 * @param interfaces the proxy interfaces (may be {@code null} to
 * indicate proxying of all interfaces implemented by the target class)
 * @return the generated proxy
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	ClassLoader classLoader = this.beanClassLoader;

	if (interfaces == null) {
		interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
	}
	proxyFactory.setInterfaces(interfaces);
	if (proxyTargetClass) {
		classLoader = null;  // force use of Class.getClassLoader()
		proxyFactory.setProxyTargetClass(proxyTargetClass);
	}

	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);

	return proxyFactory.getProxy(classLoader);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:ScriptFactoryPostProcessor.java

示例5: createRefreshableProxy

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
    * Create a refreshable proxy for the given AOP TargetSource.
    * 
    * @param ts
    *            the refreshable TargetSource
    * @param interfaces
    *            the proxy interfaces (may be {@code null} to indicate proxying
    *            of all interfaces implemented by the target class)
    * @return the generated proxy
    * @see RefreshableScriptTargetSource
    */
   protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.setTargetSource(ts);
ClassLoader classLoader = this.beanClassLoader;

if (interfaces == null) {
    interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
}
proxyFactory.setInterfaces(interfaces);
if (proxyTargetClass) {
    classLoader = null; // force use of Class.getClassLoader()
    proxyFactory.setProxyTargetClass(true);
}

DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
introduction.suppressInterface(TargetSource.class);
proxyFactory.addAdvice(introduction);

return proxyFactory.getProxy(classLoader);
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:32,代码来源:MyScriptFactoryPostProcessor.java

示例6: createRefreshableProxy

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Create a refreshable proxy for the given AOP TargetSource.
 * @param ts the refreshable TargetSource
 * @param interfaces the proxy interfaces (may be {@code null} to
 * indicate proxying of all interfaces implemented by the target class)
 * @return the generated proxy
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces, boolean proxyTargetClass) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	ClassLoader classLoader = this.beanClassLoader;

	if (interfaces == null) {
		interfaces = ClassUtils.getAllInterfacesForClass(ts.getTargetClass(), this.beanClassLoader);
	}
	proxyFactory.setInterfaces(interfaces);
	if (proxyTargetClass) {
		classLoader = null;  // force use of Class.getClassLoader()
		proxyFactory.setProxyTargetClass(true);
	}

	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);

	return proxyFactory.getProxy(classLoader);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ScriptFactoryPostProcessor.java

示例7: testAdviceImplementsIntroductionInfo

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
@Test
public void testAdviceImplementsIntroductionInfo() throws Throwable {
	TestBean tb = new TestBean();
	String name = "tony";
	tb.setName(name);
	ProxyFactory pc = new ProxyFactory(tb);
	NopInterceptor di = new NopInterceptor();
	pc.addAdvice(di);
	final long ts = 37;
	pc.addAdvice(new DelegatingIntroductionInterceptor(new TimeStamped() {
		@Override
		public long getTimeStamp() {
			return ts;
		}
	}));

	ITestBean proxied = (ITestBean) createProxy(pc);
	assertEquals(name, proxied.getName());
	TimeStamped intro = (TimeStamped) proxied;
	assertEquals(ts, intro.getTimeStamp());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:AbstractAopProxyTests.java

示例8: aopAdvice

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
public static void aopAdvice() {
	// 参见:com.bdsoft.bdceo.spring.aop包下的模拟实现类

	// before-advice: ResourceSetupBeforeAdvice
	// exception-advice: ExceptionBarrierThrowsAdvice
	// after-advice: TaskexecutionAfterReturningAdvice
	// around-advice: PerformanceMethodInterceptor

	// 特殊: Introduction类advice演示
	ITester delegate = new Tester();
	DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(
			delegate);

	DelegatePerTargetObjectIntroductionInterceptor dptoii = new DelegatePerTargetObjectIntroductionInterceptor(
			Tester.class, ITester.class);
}
 
开发者ID:bdceo,项目名称:bd-codes,代码行数:17,代码来源:FXmain.java

示例9: createEndpoint

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Wrap each concrete endpoint instance with an AOP proxy,
 * exposing the message listener's interfaces as well as the
 * endpoint SPI through an AOP introduction.
 */
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
	GenericMessageEndpoint endpoint = (GenericMessageEndpoint) super.createEndpoint(xaResource);
	ProxyFactory proxyFactory = new ProxyFactory(this.messageListener);
	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(endpoint);
	introduction.suppressInterface(MethodInterceptor.class);
	proxyFactory.addAdvice(introduction);
	return (MessageEndpoint) proxyFactory.getProxy();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:GenericMessageEndpointFactory.java

示例10: setBeanFactory

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
	}
	ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;

	this.scopedTargetSource.setBeanFactory(beanFactory);

	ProxyFactory pf = new ProxyFactory();
	pf.copyFrom(this);
	pf.setTargetSource(this.scopedTargetSource);

	Class<?> beanType = beanFactory.getType(this.targetBeanName);
	if (beanType == null) {
		throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
				"': Target type could not be determined at the time of proxy creation.");
	}
	if (!isProxyTargetClass() || beanType.isInterface() || Modifier.isPrivate(beanType.getModifiers())) {
		pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
	}

	// Add an introduction that implements only the methods on ScopedObject.
	ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
	pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

	// Add the AopInfrastructureBean marker to indicate that the scoped proxy
	// itself is not subject to auto-proxying! Only its target bean is.
	pf.addInterface(AopInfrastructureBean.class);

	this.proxy = pf.getProxy(cbf.getBeanClassLoader());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:ScopedProxyFactoryBean.java

示例11: testIntroductionThrowsUncheckedException

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Note that an introduction can't throw an unexpected checked exception,
 * as it's constained by the interface.
 */
@Test
public void testIntroductionThrowsUncheckedException() throws Throwable {
	TestBean target = new TestBean();
	target.setAge(21);
	ProxyFactory pc = new ProxyFactory(target);

	@SuppressWarnings("serial")
	class MyDi extends DelegatingIntroductionInterceptor implements TimeStamped {
		/**
		 * @see test.util.TimeStamped#getTimeStamp()
		 */
		@Override
		public long getTimeStamp() {
			throw new UnsupportedOperationException();
		}
	}
	pc.addAdvisor(new DefaultIntroductionAdvisor(new MyDi()));

	TimeStamped ts = (TimeStamped) createProxy(pc);
	try {
		ts.getTimeStamp();
		fail("Should throw UnsupportedOperationException");
	}
	catch (UnsupportedOperationException ex) {
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:AbstractAopProxyTests.java

示例12: setBeanFactory

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
public void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
	}
	ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;

	this.scopedTargetSource.setBeanFactory(beanFactory);

	ProxyFactory pf = new ProxyFactory();
	pf.copyFrom(this);
	pf.setTargetSource(this.scopedTargetSource);

	Class<?> beanType = beanFactory.getType(this.targetBeanName);
	if (beanType == null) {
		throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
				"': Target type could not be determined at the time of proxy creation.");
	}
	if (!isProxyTargetClass() || beanType.isInterface() || Modifier.isPrivate(beanType.getModifiers())) {
		pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
	}

	// Add an introduction that implements only the methods on ScopedObject.
	ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
	pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

	// Add the AopInfrastructureBean marker to indicate that the scoped proxy
	// itself is not subject to auto-proxying! Only its target bean is.
	pf.addInterface(AopInfrastructureBean.class);

	this.proxy = pf.getProxy(cbf.getBeanClassLoader());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:32,代码来源:ScopedProxyFactoryBean.java

示例13: createProxyFactory

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
private void createProxyFactory(RefreshableScriptTargetSource ts, 
		Class<?>[] interfaces, ClassLoader loader) {
	ProxyFactory proxyFactory = new ProxyFactory();
	proxyFactory.setTargetSource(ts);
	proxyFactory.setInterfaces(interfaces);
	DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
	introduction.suppressInterface(TargetSource.class);
	proxyFactory.addAdvice(introduction);
	proxyFactory.getProxy(loader);
	
}
 
开发者ID:valliappanr,项目名称:refreshable-beans,代码行数:12,代码来源:SpringContextWrapper.java

示例14: getPoolingConfigMixin

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Return an IntroductionAdvisor that providing a mixin
 * exposing statistics about the pool maintained by this object.
 */
public DefaultIntroductionAdvisor getPoolingConfigMixin() {
	DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this);
	return new DefaultIntroductionAdvisor(dii, PoolingConfig.class);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AbstractPoolingTargetSource.java

示例15: getStatsMixin

import org.springframework.aop.support.DelegatingIntroductionInterceptor; //导入依赖的package包/类
/**
 * Return an introduction advisor mixin that allows the AOP proxy to be
 * cast to ThreadLocalInvokerStats.
 */
public IntroductionAdvisor getStatsMixin() {
	DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this);
	return new DefaultIntroductionAdvisor(dii, ThreadLocalTargetSourceStats.class);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ThreadLocalTargetSource.java


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