`

AOP usage -- BeanNameAutoProxyCreator usage

阅读更多

1) Must use ApplicationContext, can't use BeanFactory.

Example:

ApplicationContext factory = new ClassPathXmlApplicationContext(new String[]{"spring.xml"});

 

2) BeanNameAutoProxyCreator bean must include property as below.

<property name="proxyTargetClass" value="true"/>

Example:

<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">

     <property name="proxyTargetClass" value="true"/>

     <property name="interceptorNames">

        <list><value>loggingAroundAdvisor</value></list>

    </property>

    <property name="beanNames">

        <list><value>*world</value></list>

    </property>

 </bean>

<bean id="helloworld" class="com.xqstation.test.spring.HelloWorld"/>

   

3) jar files must have (Spring 1.2.8)

lib\aopalliance\aopalliance.jar,

lib\cglib\cglib-nodep-2.1_3.jar,

 

 

 A very simple Spring AOP example is attached.

 

 BeanFactory or ApplicationContext?

Users are sometimes unsure whether a BeanFactory or an ApplicationContext is best suited for use in a particular situation. A BeanFactory pretty much just instantiates and configures beans. An ApplicationContext also does that, and it provides the supporting infrastructure to enable lots of enterprise-specific features such as transactions and AOP.

分享到:
评论
1 楼 houzhe11 2009-05-08  
<property name="proxyTargetClass" value="true"/>
是什么意思?

相关推荐

Global site tag (gtag.js) - Google Analytics