Java Code Examples for org.springframework.aop.framework.Advised#getTargetSource()

The following examples show how to use org.springframework.aop.framework.Advised#getTargetSource() . 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: ScriptingDefaultsTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void defaultRefreshCheckDelay() throws Exception {
	ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG);
	Advised advised = (Advised) context.getBean("testBean");
	AbstractRefreshableTargetSource targetSource =
			((AbstractRefreshableTargetSource) advised.getTargetSource());
	Field field = AbstractRefreshableTargetSource.class.getDeclaredField("refreshCheckDelay");
	field.setAccessible(true);
	long delay = ((Long) field.get(targetSource)).longValue();
	assertEquals(5000L, delay);
}
 
Example 3
Source File: ScriptingDefaultsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void defaultRefreshCheckDelay() throws Exception {
	ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG);
	Advised advised = (Advised) context.getBean("testBean");
	AbstractRefreshableTargetSource targetSource =
			((AbstractRefreshableTargetSource) advised.getTargetSource());
	Field field = AbstractRefreshableTargetSource.class.getDeclaredField("refreshCheckDelay");
	field.setAccessible(true);
	long delay = ((Long) field.get(targetSource)).longValue();
	assertEquals(5000L, delay);
}
 
Example 4
Source File: ScriptingDefaultsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void defaultRefreshCheckDelay() throws Exception {
	ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG);
	Advised advised = (Advised) context.getBean("testBean");
	AbstractRefreshableTargetSource targetSource =
			((AbstractRefreshableTargetSource) advised.getTargetSource());
	Field field = AbstractRefreshableTargetSource.class.getDeclaredField("refreshCheckDelay");
	field.setAccessible(true);
	long delay = ((Long) field.get(targetSource)).longValue();
	assertEquals(5000L, delay);
}