Package com.sun.faces.spi

Examples of com.sun.faces.spi.ManagedBeanFactory


     * @param scope the managed bean scope in which to look for the bean
     * or beans.
     */

    public void handlePreDestroy(String beanName, Object bean, Scope scope) {
        ManagedBeanFactory factory = managedBeanFactoriesMap.get(beanName);
        if (factory != null && factory.isInjectable()) {
            try {
                injectionProvider.invokePreDestroy(bean);
            } catch (InjectionProviderException ipe) {
                if (LOGGER.isLoggable(Level.SEVERE)) {
                    LOGGER.log(Level.SEVERE, ipe.getMessage(), ipe);
View Full Code Here


     * @throws FacesException if the managed bean
     *                                   could not be created.
     */
    public Object createAndMaybeStoreManagedBeans(FacesContext context,
                                                  String managedBeanName) throws FacesException {
        ManagedBeanFactory managedBean = managedBeanFactoriesMap.get(managedBeanName);
        if (managedBean == null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Couldn't find a factory for " + managedBeanName);
            }
            return null;
        }

        Object bean;
        Scope scope = managedBean.getScope();

        boolean scopeIsApplication;
        boolean scopeIsRequest;
        ExternalContext extContext = context.getExternalContext();
        if ((scopeIsApplication = (scope == Scope.APPLICATION)) ||
            ((scope == Scope.SESSION))) {
            if (scopeIsApplication) {
                synchronized (extContext.getContext()) {
                    try {
                        bean = managedBean.newInstance(context);
                        if (LOGGER.isLoggable(Level.FINE)) {
                            LOGGER.fine(MessageFormat.format("Created application scoped bean {0} successfully ", managedBeanName));
                        }
                    } catch (Exception ex) {
                        Object[] params = {managedBeanName};
                        if (LOGGER.isLoggable(Level.SEVERE)) {
                            LOGGER.log(Level.SEVERE,
                                       "jsf.managed_bean_creation_error", params);
                        }
                        throw new FacesException(ex);
                    }
                    //add bean to appropriate scope
                    extContext.getApplicationMap().put(managedBeanName, bean);
                }
            } else {
                synchronized (extContext.getSession(true)) {
                    try {
                        bean = managedBean.newInstance(context);
                        if (LOGGER.isLoggable(Level.FINE)) {
                            LOGGER.fine(MessageFormat.format("Created session scoped bean {0} successfully ", managedBeanName));
                        }
                    } catch (Exception ex) {
                        Object[] params = {managedBeanName};
                        if (LOGGER.isLoggable(Level.SEVERE)) {
                            LOGGER.log(Level.SEVERE,
                                       "jsf.managed_bean_creation_error", params);
                        }
                        throw new FacesException(ex);
                    }
                    //add bean to appropriate scope
                    extContext.getSessionMap().put(managedBeanName, bean);
                }
            }
        } else {
            scopeIsRequest = (scope == Scope.REQUEST);
            try {
                bean = managedBean.newInstance(context);
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.log(Level.FINE, MessageFormat.format("Created bean {0} successfully ", managedBeanName));
                }
            } catch (Exception ex) {
                Object[] params = {managedBeanName};
View Full Code Here

            if (LOGGER.isLoggable(Level.FINER)) {
                LOGGER.finer(MessageFormat.format("addManagedBean(managedBeanName={0},managedBeanClass={1})",
                                                  config[i].getManagedBeanName(),
                                                  config[i].getManagedBeanClass()));
            }
            ManagedBeanFactory mbf = new ManagedBeanFactoryImpl(config[i]);
           
            // See if the RI specific MANAGED_BEAN_FACTORY_DECORATOR is available
            String mbfdClassName =
                  webConfig.getContextInitParameter(
                        WebContextInitParameter.ManagedBeanFactoryDecorator);
            if (mbfdClassName != null) {
                ManagedBeanFactory newMbf =
                        (ManagedBeanFactory) Util.createInstance(mbfdClassName,
                            ManagedBeanFactory.class, mbf);
                if (null != newMbf) {
                    mbf = newMbf;
                }
View Full Code Here

TOP

Related Classes of com.sun.faces.spi.ManagedBeanFactory

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.