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

推荐订阅源

博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
罗磊的独立博客
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
B
Blog RSS Feed

博客园 - 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 ;
    }
}