Package org.internna.iwebmvc.spring.swf.dwr

Source Code of org.internna.iwebmvc.spring.swf.dwr.AJAXFlowManagerImpl

/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache license, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.internna.iwebmvc.spring.swf.dwr;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.ServletContextAware;
import org.springframework.webflow.context.ExternalContextHolder;
import org.springframework.webflow.context.servlet.ServletExternalContext;
import org.springframework.webflow.execution.FlowExecution;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.repository.FlowExecutionRepository;
import org.springframework.webflow.executor.FlowExecutor;
import org.springframework.webflow.executor.FlowExecutorImpl;

/**
* Allows remote AJAX operations on flows
*
* @author Jose Noheda
*/
public class AJAXFlowManagerImpl implements AJAXFlowManager, ServletContextAware {

    private static Log log = LogFactory.getLog(AJAXFlowManagerImpl.class);

    private ServletContext servletContext;

    @Autowired protected FlowExecutor flowExecutor;

    @Override
    public void setServletContext(ServletContext servletContext) {
        this.servletContext = servletContext;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Object getReferenceInFlowScope(String flowExecutionKey, String referenceName, HttpServletRequest request) {
        ExternalContextHolder.setExternalContext(new ServletExternalContext(servletContext, request, null));
        FlowExecutionRepository executionRepository =  ((FlowExecutorImpl) flowExecutor).getExecutionRepository();
        FlowExecution flowExecution = executionRepository.getFlowExecution(executionRepository.parseFlowExecutionKey(flowExecutionKey));
        FlowSession flowSession = flowExecution.getActiveSession();
        return flowSession.getScope().get(referenceName);
    }

}
TOP

Related Classes of org.internna.iwebmvc.spring.swf.dwr.AJAXFlowManagerImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.