com.freebox.engeneering.application.system.configuration.WebFlowContext.java Source code

Java tutorial

Introduction

Here is the source code for com.freebox.engeneering.application.system.configuration.WebFlowContext.java

Source

/*
 * Copyright 2012 Lexaden.com
 *
 *   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 com.freebox.engeneering.application.system.configuration;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.config.CustomScopeConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import com.freebox.engeneering.application.system.ApplicationContextLocator;
import com.freebox.engeneering.application.system.ApplicationScope;
import com.freebox.engeneering.application.system.webflow.spring.SpringFlowControllerContext;
import com.freebox.engeneering.application.system.webflow.spring.SpringFlowControllerContextImpl;
import com.freebox.engeneering.application.system.webflow.spring.SpringFlowControllerContextLoader;
import com.lexaden.webflow.EventProcessor;
import com.lexaden.webflow.EventProcessorImpl;
import com.lexaden.webflow.FlowConfigurationLoader;
import com.lexaden.webflow.FlowController;
import com.lexaden.webflow.FlowControllerImpl;

@Configuration
public class WebFlowContext {
    @Bean
    public FlowConfigurationLoader flowConfigurationLoader() {
        return new FlowConfigurationLoader();
    }

    @Bean
    public CustomScopeConfigurer customScopeConfigurer() {
        final CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer();
        final Map<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put(ApplicationScope.NAME, new ApplicationScope());
        customScopeConfigurer.setScopes(hashMap);
        return customScopeConfigurer;
    }

    @Bean
    @Scope(ApplicationScope.NAME)
    public SpringFlowControllerContextLoader stateControllerContextLoader() {
        return new SpringFlowControllerContextLoader(stateControllerContext());
    }

    @Bean
    @Scope(ApplicationScope.NAME)
    public FlowController stateController() {
        return new FlowControllerImpl();
    }

    @Bean
    @Scope(ApplicationScope.NAME)
    public SpringFlowControllerContext stateControllerContext() {
        return new SpringFlowControllerContextImpl(ApplicationContextLocator.getApplicationContext());
    }

    @Bean
    @Scope(ApplicationScope.NAME)
    public EventProcessor eventProcessor() {
        return new EventProcessorImpl(stateControllerContext());
    }
}