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"/>
</property>
</bean>
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:attributes>
<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"/>
</tx:attributes>
</tx:advice>
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:config>
<aop:pointcut id= "Daomethod" expression= "Execution (public * com.dvp.module.*.*.*.dao.impl). *.*(..))" />
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Daomethod"/>
</aop:config>
<aop:config>
<aop:pointcut id= "daoMethod2" expression= "Execution (public * com.dvp.base.dao.impl). *.*(..))" />
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "DaoMethod2"/>
</aop:config>
Ok so one Spring enhancement (advisor) = tangent (advice) + pointcut (PointCut)