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

推荐订阅源

H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
L
LangChain Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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