Java Code Examples for org.springframework.aop.framework.ProxyFactoryBean#setTargetSource()

The following examples show how to use org.springframework.aop.framework.ProxyFactoryBean#setTargetSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AclJpaQuery.java    From strategy-spring-security-acl with Apache License 2.0 6 votes vote down vote up
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();
      }
    }

    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;
  }
}
 
Example 2
Source File: Spr15042Tests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public ProxyFactoryBean myObject() {
	ProxyFactoryBean pfb = new ProxyFactoryBean();
	pfb.setTargetSource(poolTargetSource());
	return pfb;
}
 
Example 3
Source File: Spr15042Tests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public ProxyFactoryBean myObject() {
	ProxyFactoryBean pfb = new ProxyFactoryBean();
	pfb.setTargetSource(poolTargetSource());
	return pfb;
}