`
famoushz
  • 浏览: 2934310 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

spring transaction and interceptor

阅读更多

spring 声明性事务

java 代码
  1. "category" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">   
  2.     "transactionManager">"hibernatetransaction"/>   
  3.     "target">"categoryhelper"/>   
  4.     "transactionAttributes">   
  5.          <props></props>   
  6.             "get*">PROPAGATION_REQUIRED,readOnly   
  7.             "find*">PROPAGATION_REQUIRED,readOnly   
  8.             "save*">PROPAGATION_REQUIRED   
  9.             "del*">PROPAGATION_REQUIRED   
  10.            
  11.        
  12.   

 

spring interceptor

 

java 代码
  1.   public boolean beforeAction(Action action, ActionMapping mapping,   
  2.           ActionForm form, HttpServletRequest request,   
  3.           HttpServletResponse response)   
  4.   {   
  5. if (logger.isDebugEnabled())   
  6. {   
  7.     logger.debug("edit vote permission interceptor beforeAction called");   
  8. }   
  9.   
  10. int voteID = ParamUtils.getInteger(request , "voteid");   
  11.   
  12. try  
  13. {   
  14.     //判断是否是投票拥有者   
  15.     Vote vote = ForumNukeServiceLocatorFactory.getServiceLocator().getVoteHelper().getVote(voteID);   
  16.     HttpSession session = request.getSession();   
  17.     OnlineUser sessionUser = (OnlineUser)session.getAttribute(Constants.SESSION_ONLINEUSER_KEY);   
  18.     if (sessionUser.getUserName().equals(vote.getPoster()))   
  19.     {   
  20.         Forum forum = (Forum)ForumNukeServiceLocatorFactory.getServiceLocator().getThreadHelper().getThreadByVote(voteID).getForum();   
  21.   
  22.         //判断是否有在指定论坛内修改投票权限   
  23.         Permission perm = UserFactory.newPermission("editvote.do" , true , "forumid=" + forum.getForumID());   
  24.         return hasPermission(perm , request , response , mapping);   
  25.     }   
  26.     else  
  27.     {   
  28.         forwardNoPermission(mapping , request , response);   
  29.     }   
  30. }   
  31. catch(Exception e)   
  32. {   
  33.     e.printStackTrace();   
  34.     forwardNoPermission(mapping , request , response);   
  35. }   
  36.   
  37. return false;   
  38.   }   
  39.   
  40.   /**  
  41.    *  Called after an action is executed  
  42.    *  
  43.    *@param  action    The action that was executed  
  44.    *@param  mapping   The action mapping  
  45.    *@param  form      The action form  
  46.    *@param  request   The request object  
  47.    *@param  response  The response object  
  48.    */  
  49.   public boolean afterAction(Action action, ActionMapping mapping,   
  50.           ActionForm form, HttpServletRequest request,   
  51.           HttpServletResponse response)   
  52.   {   
  53. if (logger.isDebugEnabled())   
  54. {   
  55.     logger.debug("edit vote permission interceptor afterAction called");   
  56. }   
  57.   
  58. return true;   
  59.   }  
分享到:
评论

相关推荐

    org.springframework.transaction-3.1.2.RELEASE.zip

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Error setting property values; nested ...

    Spring在Transaction事务传播行为种类

    &lt;bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"&gt; &lt;!-- 事务拦截器bean需要依赖注入一个事务管理器 --&gt; &lt;!-- 下面定义事务传播属性 --&gt; *...

    Implementing Transaction Suspension in Spring

    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;property name="transactionManager"&gt;&lt;ref bean="transactionManager"/&gt;&lt;/property&gt; &lt;property name="target"&gt;&lt;ref bean=...

    jBPM4与Spring整合的2种方式

    2. **配置事务处理**:修改`jbpm.tx.spring.cfg.xml`文件,将`standard-transaction-interceptor`改为`spring-transaction-interceptor`,并将`transaction`和`hibernate-session`设置为`current="true"`。...

    spring.net 声明式事物管理小示例

    &lt;object id="transactionManager" type="Spring.Transaction.Interceptor.TxScopeTransactionManager, Spring.Transaction"&gt; ``` 4. **定义事务属性** 你可以使用 AOP 的特性(如 `TransactionAttribute`)...

    spring源码spring-framework-4.2.5.RELEASE

    `org.springframework.transaction`和`org.springframework.transaction.interceptor`包中的TransactionInterceptor处理事务的开始、提交和回滚。 五、其他关键模块 9. **Spring表达式语言(SpEL)**:在`org....

    spring的5中事物配置 介绍spring的5中事物配置

    &lt;bean id="userDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;!-- 配置事务管理器 --&gt; &lt;!-- 配置需要代理的方法 --&gt; &lt;!-- 配置事务属性 --&gt; *"&gt;...

    struts spring集成【下】

    &lt;bean id="myService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; *"&gt;PROPAGATION_REQUIRED, -Exception ``` 这里,`myServiceImpl`是实际的业务类,`...

    spring-framework-5.1.x-源碼解析详细注解

    `org.springframework.transaction.interceptor`包下的`TransactionInterceptor`是声明式事务管理的核心,它结合`@Transactional`注解实现事务的自动管理。 通过阅读和理解这些源码注解,开发者可以更好地掌握...

    Spring事务原理、Spring事务配置的五种方式

    &lt;bean id="userManager"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;property name="transactionManager"&gt;&lt;ref bean="transactionManager"/&gt;&lt;/property&gt; ...

    Spring框架核心源代码的分析及其感受-6

    在源代码中,`org.springframework.transaction.interceptor`包下的类实现了事务的切面处理。 总的来说,深入分析Spring框架的源代码,能够帮助我们理解其设计思想和实现原理,从而在实际开发中更好地利用这些功能...

    Spring事务配置的五种方式

    &lt;bean id="userDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;!-- 配置事务管理器 --&gt; &lt;!-- 配置事务属性 --&gt; *"&gt;PROPAGATION_REQUIRED,readOnly *"&gt;...

    mybatis 拦截器 + spring aop切面 + spring事务+ 反射工具类

    3. Spring事务管理(Spring Transaction Management): Spring提供了强大的事务管理功能,无论是编程式还是声明式的事务管理,都能帮助开发者有效地控制事务的边界。声明式事务管理通过@Transactional注解实现,...

    Spring事务配置的五种方式.doc

    &lt;bean id="userDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; ``` 在上面的配置中,我们定义了一个SessionFactory、一个TransactionManager和一个DAO对象。然后,...

    Spring配置的5种方式

    &lt;bean id="userDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;property name="proxyInterfaces" value="com.bluesky.spring.dao.GeneratorDao"/&gt; REQUIRED ...

    Spring 事务代理配置

    &lt;bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"&gt; *"&gt;PROPAGATION_REQUIRED *"&gt;PROPAGATION_REQUIRED *"&gt;PROPAGATION_REQUIRED *"&gt;...

    spring事务配置的五种方式

    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;!--配置事务管理器--&gt; &lt;property name="proxyInterfaces" value="com.bluesky.spring.dao.GeneratorDao"/&gt; &lt;!--配置...

    Spring的事务配置的五种方式

    &lt;bean id="userDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;!-- 配置事务规则 --&gt; *"&gt;PROPAGATION_REQUIRED,readOnly *"&gt;PROPAGATION_REQUIRED *"&gt;...

    spring声明式事务配置

    &lt;bean id="userDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt; &lt;property name="proxyInterfaces" value="com.bluesky.spring.dao.GeneratorDao"/&gt; *"&gt;...

Global site tag (gtag.js) - Google Analytics