package org.smartx.fast.session;

import org.smartx.fast.exception.InvalidConfigException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

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

import javax.annotation.PostConstruct;

/**
 * <p>
 *
 * </p>
 *
 * @author kext
 * @since 1.0
 */
@Component
public class SessionContextSupport {

    private final Map<String, SessionContext> sessionContextMap = new HashMap<>();

    @Value("${fast.api.session:redis}")
    private String key;

    @PostConstruct
    private void init() {
        this.sessionContextMap.put("redis", new RedisSessionContext());
    }

    public SessionContext get() {
        if (!sessionContextMap.containsKey(key)) {
            throw new InvalidConfigException("Invalid fast.api.session, only support none, map, redis");
        }
        return this.sessionContextMap.get(key);
    }
}

@@ -27,16 +27,69 @@
 ssion;%0A%0A
+import org.smartx.commons.utils.SpringContextHolder;%0A
 import o
@@ -199,57 +199,8 @@
 lue;
-%0Aimport org.springframework.stereotype.Component;
 %0A%0Aim
@@ -349,19 +349,8 @@
  */%0A
-@Component%0A
 publ
@@ -625,13 +625,38 @@
 s%22, 
-new R
+SpringContextHolder.getBean(%22r
 edis
@@ -669,17 +669,17 @@
 nContext
-(
+%22
 ));%0A    
@@ -836,16 +836,22 @@
 .session
+ value
 , only s
@@ -857,16 +857,17 @@
 support 
+%5B
 none, ma
@@ -871,15 +871,18 @@
  map
-,
+ or
  redis
+%5D
 %22);%0A

fix to get bean from spring context holder instead of new