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

com.vaadin.cdi.internal.VaadinContextualStorage Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package com.vaadin.cdi.internal;

import javax.enterprise.context.spi.Contextual;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.PassivationCapable;

import org.apache.deltaspike.core.util.context.ContextualStorage;

/**
 * Customized version of ContextualStorage to also handle beans that are not
 * PassivationCapable. Such beans are used as their own keys, which is not ideal
 * but should work in most single-JVM environments.
 * 
 * @see ContextualStorage
 */
public class VaadinContextualStorage extends ContextualStorage {

    public VaadinContextualStorage(BeanManager beanManager, boolean concurrent) {
        super(beanManager, concurrent, true);
    }
    
    @Override
    public  Object getBeanKey(Contextual bean) {
        if(bean instanceof PassivationCapable) {
            return super.getBeanKey(bean);    
        } else {
            return bean;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy