Announcement Announcement Module
Collapse
No announcement yet.
Why ExternalContextHolder.setExternalContext? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why ExternalContextHolder.setExternalContext?

    Hi community,
    I have the follow code for retrieving data from Flowscope (which works fine) used in an MVC Controller:
    Code:
    protected Object getElementFromFlowScope(String flowKey, HttpServletRequest req, String elementKey) {
            ExternalContextHolder.setExternalContext(new ServletExternalContext(getServletContext(), req, null));
            FlowExecutionRepository executionRepository = ((FlowExecutorImpl) getFlowExecutor()).getExecutionRepository();
            FlowExecution flowExecution = executionRepository.getFlowExecution(executionRepository.parseFlowExecutionKey(flowKey));
            FlowSession flowSession = flowExecution.getActiveSession();
            Object element = flowSession.getScope().get(elementKey);
            ExternalContextHolder.setExternalContext(null);
            return element;
        }
    My question is: Why do I need to set ExternalContextHolder (not using it throws NPE)? Is it safe knowing that a controller instance can attend many requests simultaneously? what are the implications of those lines of code setting a context?

    I use SWF 2.0.5
    Thanks.
Working...
X