spring 声明性事务
java 代码
- "category" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
- "transactionManager">"hibernatetransaction"/>
- "target">"categoryhelper"/>
- "transactionAttributes">
- <props></props>
- "get*">PROPAGATION_REQUIRED,readOnly
- "find*">PROPAGATION_REQUIRED,readOnly
- "save*">PROPAGATION_REQUIRED
- "del*">PROPAGATION_REQUIRED
spring interceptor
java 代码
- public boolean beforeAction(Action action, ActionMapping mapping,
- ActionForm form, HttpServletRequest request,
- HttpServletResponse response)
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("edit vote permission interceptor beforeAction called");
- }
- int voteID = ParamUtils.getInteger(request , "voteid");
- try
- {
- //判断是否是投票拥有者
- Vote vote = ForumNukeServiceLocatorFactory.getServiceLocator().getVoteHelper().getVote(voteID);
- HttpSession session = request.getSession();
- OnlineUser sessionUser = (OnlineUser)session.getAttribute(Constants.SESSION_ONLINEUSER_KEY);
- if (sessionUser.getUserName().equals(vote.getPoster()))
- {
- Forum forum = (Forum)ForumNukeServiceLocatorFactory.getServiceLocator().getThreadHelper().getThreadByVote(voteID).getForum();
- //判断是否有在指定论坛内修改投票权限
- Permission perm = UserFactory.newPermission("editvote.do" , true , "forumid=" + forum.getForumID());
- return hasPermission(perm , request , response , mapping);
- }
- else
- {
- forwardNoPermission(mapping , request , response);
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- forwardNoPermission(mapping , request , response);
- }
- return false;
- }
- /**
- * Called after an action is executed
- *
- *@param action The action that was executed
- *@param mapping The action mapping
- *@param form The action form
- *@param request The request object
- *@param response The response object
- */
- public boolean afterAction(Action action, ActionMapping mapping,
- ActionForm form, HttpServletRequest request,
- HttpServletResponse response)
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("edit vote permission interceptor afterAction called");
- }
- return true;
- }