Package org.apache.myfaces.config.element

Examples of org.apache.myfaces.config.element.ManagedBean


        if (!(property instanceof String))
            return null;

        final String strProperty = (String)property;

        final ManagedBean managedBean = runtimeConfig(context).getManagedBean(strProperty);
        Object beanInstance = null;
        if (managedBean != null)
        {
            context.setPropertyResolved(true);
           
            // managed-bean-scope could be a ValueExpression pointing to a Map (since 2.0)
            if (managedBean.isManagedBeanScopeValueExpression())
            {
                // check for cyclic references in custom scopes, if we are not in Production stage
                boolean checkCyclicReferences =
                        facesContext.getApplication().getProjectStage() != ProjectStage.Production;
                List<String> cyclicReferences = null;
               
                if (checkCyclicReferences)
                {
                    final Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
                    final String managedBeanName = managedBean.getManagedBeanName();
                   
                    cyclicReferences = (List<String>) requestMap.get(CUSTOM_SCOPE_CYCLIC_REFERENCE_DETECTION);
                    if (cyclicReferences == null)
                    {
                        cyclicReferences = new ArrayList<String>();
                        requestMap.put(CUSTOM_SCOPE_CYCLIC_REFERENCE_DETECTION, cyclicReferences);
                    }
                    else if (cyclicReferences.contains(managedBeanName))
                    {
                        throw new ELException("Detected cyclic reference to managedBean " + managedBeanName);
                    }

                    cyclicReferences.add(managedBeanName);
                }
                try
                {
                    Object customScope = managedBean.getManagedBeanScopeValueExpression(facesContext)
                                                .getValue(facesContext.getELContext());
                    if (customScope instanceof Map)
                    {
                        beanInstance = ((Map) customScope).get(managedBean.getManagedBeanName());
                    }
                    else if (customScope != null)
                    {
                        throw new FacesException("The expression '" + managedBean.getManagedBeanScope() +
                                "' does not evaluate to java.util.Map. It evaluates to '" + customScope +
                                "' of type " + customScope.getClass().getName());
                    }
                    else
                    {
                        log.warning("Custom scope '" + managedBean.getManagedBeanScope() +
                                "' evaluated to null. Unable to determine if managed bean '" +
                                managedBean.getManagedBeanName() + "' exists.");
                    }
                }
                finally
                {
                    if (checkCyclicReferences)
                    {
                        cyclicReferences.remove(managedBean.getManagedBeanName());
                    }
                }
            }
           
            if (beanInstance == null)
View Full Code Here


        Map<String, ManagedBean> oldManagedBeans = runtimeConfig.getManagedBeansNotReaddedAfterPurge();
        if (oldManagedBeans != null)
        {
            for (Map.Entry<String, ManagedBean> entry : oldManagedBeans.entrySet())
            {
                ManagedBean bean = entry.getValue();

                String scope = bean.getManagedBeanScope();

                if (scope != null && scope.equalsIgnoreCase("session"))
                {
                    _externalContext.getSessionMap().remove(entry.getKey());
                }
View Full Code Here

        Map<String, ManagedBean> oldManagedBeans = runtimeConfig.getManagedBeansNotReaddedAfterPurge();
        if (oldManagedBeans != null)
        {
            for (Map.Entry<String, ManagedBean> entry : oldManagedBeans.entrySet())
            {
                ManagedBean bean = entry.getValue();

                String scope = bean.getManagedBeanScope();

                if (scope != null && scope.equalsIgnoreCase("session"))
                {
                    _externalContext.getSessionMap().remove(entry.getKey());
                }
View Full Code Here

          ectx.getRequestMap().containsKey(property) ||
          ectx.getSessionMap().containsKey(property) ||
          ectx.getApplicationMap().containsKey(property) )
          return null;
       
        ManagedBean managedBean = runtimeConfig(ctx).getManagedBean((String)property);
       
        return managedBean == null ? null : getValue(ctx, ectx, managedBean.getManagedBeanClass());
  }
View Full Code Here

        {
            return VIEW;
        }

        //not found - check mangaged bean config
        ManagedBean mbc = getRuntimeConfig(facesContext).getManagedBean(beanName);
        if (mbc != null)
        {
            // managed-bean-scope could be a EL ValueExpression (since 2.0)
            if (mbc.isManagedBeanScopeValueExpression())
            {  
                // the scope is a custom scope
                // Spec says, that the developer has to take care about the references
                // to and from managed-beans in custom scopes.
                // However, we do check the references, if we are not in Production stage
                if (facesContext.isProjectStage(ProjectStage.Production))
                {
                    return null;
                }
                else
                {
                    String scopeExpression = mbc.getManagedBeanScopeValueExpression(facesContext).getExpressionString();
                    return getNarrowestScope(facesContext, scopeExpression);
                }
            }
            else
            {
                return mbc.getManagedBeanScope();
            }
        }

        return null;
    }
View Full Code Here

        Map<String, ManagedBean> oldManagedBeans = runtimeConfig.getManagedBeansNotReaddedAfterPurge();
        if (oldManagedBeans != null)
        {
            for (Map.Entry<String, ManagedBean> entry : oldManagedBeans.entrySet())
            {
                ManagedBean bean = entry.getValue();

                String scope = bean.getManagedBeanScope();

                if (scope != null && scope.equalsIgnoreCase("session"))
                {
                    _externalContext.getSessionMap().remove(entry.getKey());
                }
View Full Code Here

        Map<String, ManagedBean> oldManagedBeans = runtimeConfig.getManagedBeansNotReaddedAfterPurge();
        if (oldManagedBeans != null)
        {
            for (Map.Entry<String, ManagedBean> entry : oldManagedBeans.entrySet())
            {
                ManagedBean bean = entry.getValue();

                String scope = bean.getManagedBeanScope();

                if (scope != null && scope.equalsIgnoreCase("session"))
                {
                    _externalContext.getSessionMap().remove(entry.getKey());
                }
View Full Code Here

        {
            return VIEW;
        }

        //not found - check mangaged bean config
        ManagedBean mbc = getRuntimeConfig(facesContext).getManagedBean(beanName);
        if (mbc != null)
        {
            // managed-bean-scope could be a EL ValueExpression (since 2.0)
            if (mbc.isManagedBeanScopeValueExpression())
            {  
                // the scope is a custom scope
                // Spec says, that the developer has to take care about the references
                // to and from managed-beans in custom scopes.
                // However, we do check the references, if we are not in Production stage
                if (facesContext.isProjectStage(ProjectStage.Production))
                {
                    return null;
                }
                else
                {
                    String scopeExpression = mbc.getManagedBeanScopeValueExpression(facesContext).getExpressionString();
                    return getNarrowestScope(facesContext, scopeExpression);
                }
            }
            else
            {
                return mbc.getManagedBeanScope();
            }
        }

        return null;
    }
View Full Code Here

        {
            return obj;
        }

        // ManagedBean
        ManagedBean mbc = getRuntimeConfig(facesContext).getManagedBean(name);

        if (mbc != null)
        {

            // check for cyclic references
            List beansUnderConstruction = (List)requestMap.get(BEANS_UNDER_CONSTRUCTION);
            if (beansUnderConstruction == null) {
                beansUnderConstruction = new ArrayList();
                requestMap.put(BEANS_UNDER_CONSTRUCTION, beansUnderConstruction);
            }

            String managedBeanName = mbc.getManagedBeanName();
            if (beansUnderConstruction.contains(managedBeanName)) {
                throw new FacesException( "Detected cyclic reference to managedBean " + mbc.getManagedBeanName());
            }

            beansUnderConstruction.add(managedBeanName);
            try {
                obj = beanBuilder.buildManagedBean(facesContext, mbc);
            } finally {
                beansUnderConstruction.remove(managedBeanName);
            }

            // put in scope
            String scopeKey = mbc.getManagedBeanScope();

            // find the scope handler object
            Scope scope = (Scope) _scopes.get(scopeKey);
            if (scope == null)
            {
View Full Code Here

    {
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);

        for (Iterator iterator = _dispenser.getManagedBeans(); iterator.hasNext();)
        {
            ManagedBean bean = (ManagedBean) iterator.next();
            ManagedBean oldBean = runtimeConfig.getManagedBean(bean.getManagedBeanName());

            if(log.isWarnEnabled() && oldBean != null)
                log.warn("More than one managed bean w/ the name of '"
                        + bean.getManagedBeanName() + "' registered. First managed bean was registered in :" +
                            oldBean.getConfigLocation()+", new managed bean was registered in : "+
                            bean.getConfigLocation()+". The first definition of the managed-bean will be ignored by the standard MyFaces variable resolver!");

            runtimeConfig.addManagedBean(bean.getManagedBeanName(), bean);

        }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.config.element.ManagedBean

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.