惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
A
About on SuperTechFans
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
博客园 - Franky
D
Docker
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
Last Week in AI
Last Week in AI
U
Unit 42
F
Fortinet All Blogs
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
P
Proofpoint News Feed
月光博客
月光博客
G
Google Developers Blog

博客园 - sunliho

Java ClassLoader and Context ClassLoader Building Liferay on Tomcat Debugging Liferay in Eclipse ssl 服务器证书,客户端信任证书 相对路径与绝对路径 - sunliho - 博客园 db2 command 标准sql Linux系统下架设APACHE SVN服务器全过程 修改ip地址 mysql in linux network configuration in linux Linux系统信息查看命令大全 linux常用命令 Permission denied in linux install jdk in linux generic dao hibernate.cfg.xml 配置(摘录) - sunliho - 博客园 hibernate 配置文件(摘录) - sunliho - 博客园 web.xml配置详解(摘录)
find flow scope varibles in spring web flow
sunliho · 2011-10-12 · via 博客园 - sunliho

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.webflow.context.ExternalContext;
import org.springframework.webflow.context.ExternalContextHolder;
import org.springframework.webflow.context.servlet.ServletExternalContext;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.execution.FlowExecution;
import org.springframework.webflow.execution.FlowExecutionKey;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.repository.FlowExecutionLock;
import org.springframework.webflow.execution.repository.FlowExecutionRepository;
import org.springframework.webflow.executor.FlowExecutorImpl;
import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter;
/**
 * Util class to find flow scope variables in SWF
 *
 */
public class WebflowUtil {
   
    private static FlowHandlerAdapter flowHandler = null ;

    public void setFlowHandler(FlowHandlerAdapter flowHandler) {
        this.flowHandler = flowHandler;
    }
    
    /**
     * Find the flow scope variables
     * @param request
     * @param response
     * @param excutionKey
     * @param variableName
     * @return
     */
    public static Object findFlowScopeVariable(HttpServletRequest request,HttpServletResponse response,
            String excutionKey,String variableName){
        
        if (flowHandler != null)
        {
            ExternalContext externalContext = new ServletExternalContext(request.getSession().getServletContext(),
                    request, response);
            ExternalContextHolder.setExternalContext(externalContext);
            FlowExecutionRepository repository =
                ((FlowExecutorImpl)flowHandler.getFlowExecutor()).getExecutionRepository() ;
            FlowExecutionKey flowExecutionKey =
                repository.parseFlowExecutionKey(excutionKey) ;
            
            FlowExecutionLock lock = repository.getLock(flowExecutionKey);
             lock.lock();
             try {
                 FlowExecution execution = repository.getFlowExecution(flowExecutionKey);
                 FlowSession flowSession = execution.getActiveSession();
                MutableAttributeMap map = flowSession.getScope() ;
                Object obj = map.get(variableName);
                return obj ;
             } finally {
                 lock.unlock();
             }
        }
        return null ;
    }
}