Spring Cross-sectional (advice), Enhanced (advisor), Pointcut (PointCut) (RPM)

Source: Internet
Author: User
Tags aop

Spring Cross-sectional (advice), Enhanced (advisor), Pointcut (PointCut) A little understanding:

There are 2 types of 1.Spring management transactions, one of which is Hibernatetransactionmanager management

<bean id= "Txmanager"
class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name= "Sessionfactory" >
<ref bean= "Sessionfactory"/>

This allows the session factory properties to be injected when defining the facets as follows:

<!--Configure a transaction-processing bean, define a facet (advice)--
<tx:advice id= "Txadvice" transaction-manager= "Txmanager" >
<tx:method name= "get*" read-only= "true"/>
<tx:method name= "query*" read-only= "true"/>
<tx:method name= "find*" read-only= "true"/>
<tx:method name= "save*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "add*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "del*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "update*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "*" propagation= "REQUIRED" rollback-for= "Exception"/>

2. Operations on the database are transactions, while the database defaults to read committed read-only= "true" form

The DAO method is called when read and write operations, while the core business of manipulating DAO is service, spring, however spring

To control the method that invokes DAO, it produces a facet (advice)//which is equivalent to a guard door.

3. Section (advice), spring itself will find out which DAO methods should be executed (because the DAO has been injected into spring; that is, the service layer refers to the DAO layer)

As a result, the protection becomes complex, so it needs to be tightly coupled and naturally enhanced. As follows:

<!--configuring AOP--
<aop:pointcut id= "Daomethod" expression= "Execution (public * com.dvp.module.*.*.*.dao.impl). *.*(..))" />
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Daomethod"/>

<aop:pointcut id= "daoMethod2" expression= "Execution (public * com.dvp.base.dao.impl). *.*(..))" />
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "DaoMethod2"/>

Ok so one Spring enhancement (advisor) = tangent (advice) + pointcut (PointCut)

Spring Cross-sectional (advice), Enhanced (advisor), Pointcut (PointCut) (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.