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

org.jboss.weld.contexts.bound.BoundConversationContextImpl Maven / Gradle / Ivy

Go to download

This jar bundles all the bits of Weld and CDI required for running in a Servlet container.

There is a newer version: 6.0.0.Beta4
Show newest version
package org.jboss.weld.contexts.bound;

import java.util.Iterator;
import java.util.Map;

import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.contexts.AbstractConversationContext;
import org.jboss.weld.contexts.beanstore.BoundBeanStore;
import org.jboss.weld.contexts.beanstore.NamingScheme;
import org.jboss.weld.contexts.beanstore.SessionMapBeanStore;
import org.jboss.weld.context.bound.BoundConversationContext;
import org.jboss.weld.context.bound.BoundRequest;

public class BoundConversationContextImpl extends AbstractConversationContext> implements BoundConversationContext {

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

    public BoundConversationContextImpl(String contextId, ServiceRegistry services) {
        super(contextId, services);
    }

    @Override
    protected void setSessionAttribute(BoundRequest request, String name, Object value, boolean create) {
        request.getSessionMap(create).put(name, value);
    }

    @Override
    protected Object getSessionAttribute(BoundRequest request, String name, boolean create) {
        return request.getSessionMap(create).get(name);
    }

    @Override
    protected void removeRequestAttribute(BoundRequest request, String name) {
        request.getRequestMap().remove(name);
    }

    @Override
    protected void setRequestAttribute(BoundRequest request, String name, Object value) {
        request.getRequestMap().put(name, value);
    }

    @Override
    protected Object getRequestAttribute(BoundRequest request, String name) {
        return request.getRequestMap().get(name);
    }

    @Override
    protected BoundBeanStore createRequestBeanStore(NamingScheme namingScheme, BoundRequest request) {
        return new SessionMapBeanStore(namingScheme, request.getSessionMap(false));
    }

    @Override
    protected BoundBeanStore createSessionBeanStore(NamingScheme namingScheme, Map session) {
        return new SessionMapBeanStore(namingScheme, session);
    }

    @Override
    protected Object getSessionAttributeFromSession(Map session, String name) {
        return session.get(name);
    }

    @Override
    protected Map getSessionFromRequest(BoundRequest request, boolean create) {
        return request.getSessionMap(create);
    }

    @Override
    protected String getNamingSchemePrefix() {
        return NAMING_SCHEME_PREFIX;
    }

    @Override
    protected Iterator getSessionAttributeNames(Map session) {
        return session.keySet().iterator();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy