spring aop

通知:辅助工做(故事)advice java

切点:故事发生的地点(pointcut) sql

advisor:通知者(把通知和切入点结合起来) session

代理:产生代理对象把目标和advisor结合 app

 

一、建立通知 代理

二、定义切入点和通知 对象

三、用proxyFactroyBean生成代理 get

<!-- 审计字段注入 -->
 <bean id="sessionContextAwareAfterReturningAdvice"
  class="*.SessionContextAwareAfterReturningAdvice">
  <property name="awareStatement">
   <value>begin nets_common_authority.p_set_current_um_id(?); end;</value>
  </property>
 </bean> it

<bean id="sessionContextAwareInteceptorAdvisor"
  class="*.core.aop.support.NameMatchMethodPointcutAdvisor">
  <property name="advice">
   <ref local="sessionContextAwareAfterReturningAdvice" />
  </property>
  <property name="mappedName">
   <value>getConnection</value>
  </property>
 </bean> io

 

<bean id="securityDS" class="*.core.aop.framework.ProxyFactoryBean">
  <property name="interceptorNames">
   <list>
    <value>sessionContextAwareInteceptorAdvisor</value>
   </list>
  </property>
  <property name="target">
   <ref local="securityDataSource" />
  </property>
  <property name="proxyInterfaces">
   <value>javax.sql.DataSource</value>
  </property>
 </bean> class

相关文章
相关标签/搜索