Package javax.enterprise.inject.spi

Examples of javax.enterprise.inject.spi.BeanManager


    @Override
    public Application getApplication() {

        // retrieve SeamApplicationWrapper and set parent correctly
        if (applicationWrapper == null) {
            BeanManager beanManager = new BeanManagerLocator().getBeanManager();
            applicationWrapper = BeanManagerUtils.getContextualInstance(beanManager, SeamApplicationWrapper.class);
            applicationWrapper.setParent(delegate.getApplication());
        }

        return applicationWrapper;
View Full Code Here


    }

    @Override
    public void validate(final FacesContext context) {
        context.getApplication().publishEvent(context, PreValidateEvent.class, UIValidateForm.class, this);
        BeanManager manager = new BeanManagerLocator().getBeanManager();
        manager.fireEvent(this, BEFORE);

        Validator validator = null;
        try {
            validator = context.getApplication().createValidator(getValidatorId());
            if (validator == null) {
                throw new IllegalArgumentException("Seam UIValidateForm - Could not create Validator with id: ["
                        + getValidatorId() + "]");
            }
        } catch (Exception e) {
            throw new IllegalStateException("Seam UIValidateForm - Could not create validator with id [" + getValidatorId()
                    + "] because: nested exception is:" + e.getMessage(), e);
        }

        Map<String, UIInput> components = getComponents();
        try {
            UIComponent parent = this.getParent();
            validator.validate(context, parent, components);
        } catch (ValidatorException e) {
            setValid(false);
            for (UIInput comp : components.values()) {
                comp.setValid(false);
                if (isShowFieldMessages()) {
                    context.addMessage(comp.getClientId(), e.getFacesMessage());
                }
            }
            if (isShowGlobalMessages()) {
                context.addMessage(null, e.getFacesMessage());
            }
            if(!isShowGlobalMessages() && !isShowFieldMessages()) {
                log.warn("The form validation failed but neither 'showFieldMessages' nor 'showGlobalMessages' " +
                        "is true. The validation messages will be dropped.");
            }
        }

        manager.fireEvent(this, AFTER);
        context.getApplication().publishEvent(context, PostValidateEvent.class, UIValidateForm.class, this);
    }
View Full Code Here

        ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
        return getBeanManager(servletContext);
    }

    private BeanManager getBeanManager(ServletContext servletContext) {
        BeanManager beanManager = null;
        for (String key : SERVLET_CONTEXT_KEYS) {
            beanManager = (BeanManager) servletContext.getAttribute(key);
            if (beanManager != null) {
                break;
            }
View Full Code Here

*
* @author Marcel Kolsteren
*/
public class DialogueBeanProvider {
    public static Dialogue dialogue(ServletContext servletContext) {
        BeanManager beanManager = new BeanManagerLocator().getBeanManager();
        Bean<?> bean = beanManager.resolve(beanManager.getBeans(Dialogue.class));
        return (Dialogue) beanManager.getReference(bean, Dialogue.class, beanManager.createCreationalContext(bean));
    }
View Full Code Here

        Bean<?> bean = beanManager.resolve(beanManager.getBeans(Dialogue.class));
        return (Dialogue) beanManager.getReference(bean, Dialogue.class, beanManager.createCreationalContext(bean));
    }

    public static DialogueManager dialogueManager(ServletContext servletContext) {
        BeanManager beanManager = new BeanManagerLocator().getBeanManager();
        Bean<?> bean = beanManager.resolve(beanManager.getBeans(DialogueManager.class));
        return (DialogueManager) beanManager.getReference(bean, DialogueManager.class, beanManager.createCreationalContext(bean));
    }
View Full Code Here

        }

        Authenticator selectedAuth = null;

        // Hack to workaround glassfish visibility issue
        BeanManager bm = new BeanManagerLocator().getBeanManager();

//    for (Authenticator auth : authenticators)
        for (Authenticator auth : getReferences(bm, Authenticator.class)) {
            // If the user has provided their own custom authenticator then use it -
            // a custom authenticator is one that isn't one of the known authenticators;
View Full Code Here

    @Override
    protected void init() {
        super.init();

        // Enable CDI
        BeanManager bm;
        try {
            bm = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
        } catch (NamingException e) {
            throw new IllegalStateException("Unable to obtain CDI BeanManager", e);
        }
View Full Code Here

    @Override
    protected void init() {
        super.init();

        // Enable CDI
        BeanManager bm;
        try {
            bm = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
        } catch (NamingException e) {
            throw new IllegalStateException("Unable to obtain CDI BeanManager", e);
        }
View Full Code Here

@RequestScoped
@FacesConverter("albumConverter")
public class AlbumConverter implements Converter {

    public BeanManager getBeanManager() {
        BeanManager beanManager = null;
        try {
            InitialContext initialContext = new InitialContext();
            beanManager = (BeanManager) initialContext.lookup("java:comp/BeanManager");
        } catch (NamingException e) {
            Logger.getLogger("AlbumConverter").log(Level.SEVERE, "Couldn't get BeanManager through JNDI", e);
View Full Code Here

        return beanManager;
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        BeanManager bm = getBeanManager();
        Bean<UserBean> bean = (Bean<UserBean>) bm.getBeans(UserBean.class).iterator().next();
        CreationalContext<UserBean> ctx = bm.createCreationalContext(bean);
        UserBean userBean = (UserBean) bm.getReference(bean, UserBean.class, ctx); // this could be inlined, but intentionally
                                                                                   // left this way

        for (Album a : userBean.getUser().getAlbums()) {
            if (a.getName().equals(value)) {
                return a;
View Full Code Here

TOP

Related Classes of javax.enterprise.inject.spi.BeanManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.