Example usage for org.springframework.aop.framework ProxyFactoryBean setAutodetectInterfaces

List of usage examples for org.springframework.aop.framework ProxyFactoryBean setAutodetectInterfaces

Introduction

In this page you can find the example usage for org.springframework.aop.framework ProxyFactoryBean setAutodetectInterfaces.

Prototype

public void setAutodetectInterfaces(boolean autodetectInterfaces) 

Source Link

Document

Set whether to autodetect proxy interfaces if none specified.

Usage

From source file:com.github.lothar.security.acl.jpa.query.AclJpaQuery.java

private AclPredicateTargetSource installAclPredicateTargetSource() {
    synchronized (cachedCriteriaQuery) {
        Predicate restriction = cachedCriteriaQuery.getRestriction();

        if (restriction instanceof Advised) {
            Advised advised = (Advised) restriction;
            if (advised.getTargetSource() instanceof AclPredicateTargetSource) {
                return (AclPredicateTargetSource) advised.getTargetSource();
            }//from  w w w .j  av  a 2 s .c  o m
        }

        AclPredicateTargetSource targetSource = new AclPredicateTargetSource(em.getCriteriaBuilder(),
                restriction);
        ProxyFactoryBean factoryBean = new ProxyFactoryBean();
        factoryBean.setTargetSource(targetSource);
        factoryBean.setAutodetectInterfaces(true);
        Predicate enhancedPredicate = (Predicate) factoryBean.getObject();
        logger.debug("ACL Jpa Specification target source initialized for criteria {}", cachedCriteriaQuery);

        // install proxy inside criteria
        cachedCriteriaQuery.where(enhancedPredicate);
        return targetSource;
    }
}

From source file:org.codehaus.mojo.hibernate3.HibernateExporterMojo.java

/**
 * Builds a proxy that will respect any configured processor instance if configured. This should only be called on subclasses that end up generated java classes.
 *
 * @param delegate the original Exporter
 * @return an Exporter proxy that will correctly give the processor objects a chance to run after the delegate exporters' start() method's been called.
 *///w  w  w.j a  v  a2s .  c  om
protected Exporter buildProcessorAwareExporter(final Exporter delegate) {

    MethodInterceptor interceptor = new MethodInterceptor() {
        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            Method method = invocation.getMethod();
            Object[] objects = invocation.getArguments();

            Object result;
            try {
                result = method.invoke(delegate, objects);
                if (method.getName().contains("start")) {
                    handleComposites();
                    handleProcessor();
                }
                return result;
            } catch (Throwable throwable) {
                getLog().error(throwable);
            }
            return null;

        }
    };

    ProxyFactoryBean bean = new ProxyFactoryBean();
    bean.addAdvice(interceptor);
    bean.setProxyTargetClass(true);
    bean.setBeanClassLoader(delegate.getClass().getClassLoader());
    bean.setAutodetectInterfaces(true);
    bean.setTarget(delegate);
    return (Exporter) bean.getObject();
}