@ SuppressWarnings ( "unchecked" ) private Object createManagedBean ( final ManagedBean managedBean , final FacesContext facesContext ) throws ELException { final ExternalContext extContext = facesContext . getExternalContext ( ) ; final Map < Object , Object > facesContextMap = facesContext . getAttributes ( ) ; final String managedBeanName = managedBean . getManagedBeanName ( ) ; // check for cyclic references List < String > beansUnderConstruction = ( List < String > ) facesContextMap . get ( BEANS_UNDER_CONSTRUCTION ) ; if ( beansUnderConstruction == null ) { beansUnderConstruction = new ArrayList < String > ( ) ; facesContextMap . put ( BEANS_UNDER_CONSTRUCTION , beansUnderConstruction ) ; } else if ( beansUnderConstruction . contains ( managedBeanName ) ) { throw new ELException ( "Detected cyclic reference to managedBean " + managedBeanName ) ; } beansUnderConstruction . add ( managedBeanName ) ; Object obj = null ; try { obj = beanBuilder . buildManagedBean ( facesContext , managedBean ) ; } finally { beansUnderConstruction . remove ( managedBeanName ) ; } putInScope ( managedBean , facesContext , extContext , obj ) ; return obj ; }
adapted from Manfred s JSF 1 . 1 VariableResolverImpl