code_junkie

The Spring AOP Proxy that isn't

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <bean id="simpleBean" class="org.springframework.aop.framework.ProxyFactoryBean">
  2. <property name="target">
  3. <ref local="simpleBeanTarget"/>
  4. </property>
  5. <property name="interceptorNames">
  6. <list>
  7. <value>cacheInterceptor</value>
  8. </list>
  9. </property>
  10. </bean>
  11.  
  12.  
  13.  
  14. <bean id="springDao" class="org.springframework.aop.framework.ProxyFactoryBean">
  15. <property name="target" ref="springDaoTarget"/>
  16. <property name="interceptorNames">
  17. <list>
  18. <value>daoInterceptor</value>
  19. </list>
  20. </property>
  21.  
  22. </bean>
  23.  
  24. public class SpringDao extends JdbcDaoSupport {
  25.  
  26. private SimpleJdbcTemplate simpleJdbcTemplate;
  27.  
  28. public SimpleJdbcTemplate getSimpleJdbcTemplate() {
  29.  
  30. if (simpleJdbcTemplate==null) {
  31. simpleJdbcTemplate= new SimpleJdbcTemplate(getDataSource());
  32. }
  33. return simpleJdbcTemplate;
  34. }
  35. ...
  36.  
  37. @Autowired
  38. @Qualifier("springDao")
  39. protected SpringDao springDao;
  40.  
  41. @Autowired
  42. @Qualifier("springDaoTarget")
  43. protected SpringCustomerCapacityDao springDao;
  44.  
  45. Object proxy = applicationContext.getBean("springDao");
  46.  
  47. Assert.assertNotNull(proxy);
  48. Assert.assertTrue(proxy instanceof SpringDao);
  49.  
  50. <bean id="springDaoTarget" class="com.company.SpringDao">
Add Comment
Please, Sign In to add comment