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

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

There is a newer version: 3.0.0.Alpha1
Show newest version
package org.jboss.weld.context.bound;

import org.jboss.weld.context.AbstractBoundContext;
import org.jboss.weld.context.beanstore.MapBeanStore;
import org.jboss.weld.context.beanstore.NamingScheme;
import org.jboss.weld.context.beanstore.SimpleNamingScheme;
import org.jboss.weld.context.cache.RequestScopedBeanCache;

import javax.enterprise.context.RequestScoped;
import java.lang.annotation.Annotation;
import java.util.Map;

public class BoundRequestContextImpl extends AbstractBoundContext> implements BoundRequestContext {

    private final NamingScheme namingScheme;

    public BoundRequestContextImpl() {
        super(false);
        this.namingScheme = new SimpleNamingScheme(BoundRequestContext.class.getName());
    }

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

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

    @Override
    public void activate() {
        super.activate();
        RequestScopedBeanCache.beginRequest();
    }

    @Override
    public void deactivate() {
        try {
            RequestScopedBeanCache.endRequest();
        } finally {
            super.deactivate();
        }
    }

    @Override
    public void invalidate() {
        super.invalidate();
        getBeanStore().detach();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy