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

org.jboss.weld.bean.builtin.ContextBean Maven / Gradle / Ivy

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

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;

import javax.enterprise.context.spi.Context;
import javax.enterprise.context.spi.CreationalContext;

import org.jboss.weld.bean.BeanIdentifiers;
import org.jboss.weld.bean.StringBeanIdentifier;
import org.jboss.weld.bootstrap.ContextHolder;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.util.reflection.HierarchyDiscovery;

public class ContextBean extends AbstractBuiltInBean {


    public static  ContextBean of(ContextHolder context, BeanManagerImpl beanManager) {
        return new ContextBean(context, beanManager);
    }

    private final T context;
    private final Set types;
    private final Set qualifiers;

    public ContextBean(ContextHolder contextHolder, BeanManagerImpl beanManager) {
        super(new StringBeanIdentifier(BeanIdentifiers.forBuiltInBean(beanManager, contextHolder.getType(), null)), beanManager, contextHolder.getType());
        this.context = contextHolder.getContext();
        this.types = HierarchyDiscovery.forNormalizedType(contextHolder.getType()).getTypeClosure();
        this.qualifiers = contextHolder.getQualifiers();
    }

    public Set getTypes() {
        return types;
    }

    public T create(CreationalContext creationalContext) {
        return context;
    }

    @Override
    public Set getQualifiers() {
        return qualifiers;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy