All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.weld.context.bound.BoundSessionContextImpl Maven / Gradle / Ivy

The newest version!
package org.jboss.weld.context.bound;

import java.lang.annotation.Annotation;
import java.util.Map;

import javax.enterprise.context.SessionScoped;

import org.jboss.weld.context.AbstractBoundContext;
import org.jboss.weld.context.beanstore.NamingScheme;
import org.jboss.weld.context.beanstore.SessionMapBeanStore;
import org.jboss.weld.context.beanstore.SimpleBeanIdentifierIndexNamingScheme;
import org.jboss.weld.serialization.BeanIdentifierIndex;

public class BoundSessionContextImpl extends AbstractBoundContext> implements BoundSessionContext {

    // There is no need to store FQCN in a session key
    static final String NAMING_SCHEME_PREFIX = "WELD_BS";

    private final NamingScheme namingScheme;

    public BoundSessionContextImpl(String contextId, BeanIdentifierIndex index) {
        super(contextId, true);
        this.namingScheme = new SimpleBeanIdentifierIndexNamingScheme(NAMING_SCHEME_PREFIX, index);
    }

    public Class getScope() {
        return SessionScoped.class;
    }

    public boolean associate(Map storage) {
        if (getBeanStore() == null) {
            setBeanStore(new SessionMapBeanStore(namingScheme, storage));
            return true;
        } else {
            return false;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy