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

推荐订阅源

A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
N
News and Events Feed by Topic
C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
量子位
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
AWS News Blog
AWS News Blog
爱范儿
爱范儿
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
Security Archives - TechRepublic
Security Archives - TechRepublic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
Cloudbric
Cloudbric
aimingoo的专栏
aimingoo的专栏
L
Lohrmann on Cybersecurity
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hacker News: Ask HN
Hacker News: Ask HN
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
S
Security @ Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
P
Proofpoint News Feed
V
V2EX
Martin Fowler
Martin Fowler
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
SecWiki News
SecWiki News
罗磊的独立博客
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
The Last Watchdog
The Last Watchdog

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