Example usage for org.springframework.aop.support DelegatingIntroductionInterceptor suppressInterface

List of usage examples for org.springframework.aop.support DelegatingIntroductionInterceptor suppressInterface

Introduction

In this page you can find the example usage for org.springframework.aop.support DelegatingIntroductionInterceptor suppressInterface.

Prototype

public void suppressInterface(Class<?> ifc) 

Source Link

Document

Suppress the specified interface, which may have been autodetected due to the delegate implementing it.

Usage

From source file:org.iff.infra.util.spring.script.ScriptFactoryPostProcessor.java

/**
 * 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/*from w w w .ja va 2 s . co  m*/
 * @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);
}

From source file:org.springframework.scripting.support.ScriptFactoryPostProcessor.java

/**
 * 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//  w w w  . j  a  v  a 2  s .  c o  m
 * @see RefreshableScriptTargetSource
 */
protected Object createRefreshableProxy(TargetSource ts, @Nullable Class<?>[] interfaces,
        boolean proxyTargetClass) {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTargetSource(ts);
    ClassLoader classLoader = this.beanClassLoader;

    if (interfaces != null) {
        proxyFactory.setInterfaces(interfaces);
    } else {
        Class<?> targetClass = ts.getTargetClass();
        if (targetClass != null) {
            proxyFactory.setInterfaces(ClassUtils.getAllInterfacesForClass(targetClass, this.beanClassLoader));
        }
    }

    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);
}