Find the Spring bean from WebApplicationContext in servlet context.
@param beanName
@return	the bean or null
499760
private Object findSpringBean(String beanName) {
		ServletContext servletContext = this.pageContext.getServletContext();

		Enumeration<String> attrNames = servletContext.getAttributeNames();
		while (attrNames.hasMoreElements()){
			String attrName = attrNames.nextElement();
			if (attrName.startsWith("org.springframework")){
				try{
					WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext, attrName);
					Object bean = springContext.getBean(beanName);
					return bean;
				}catch(Exception e){
					// continue if the bean cannot be found.
				}
			}
		}
		return null;
	}
736087
public static Object getSpringBean(ApplicationContext appContext, String id) {
        try {
            Object bean = appContext.getBean(id);
            return bean;
        } catch (BeansException e) {
            return null;
        }
    }
1011862
public FacesBackingBean getFacesBackingBeanForRequest( RequestContext requestContext )
    {
        HttpServletRequest request = requestContext.getHttpRequest();
        String uri = InternalUtils.getDecodedServletPath( request );
        assert uri.charAt( 0 ) == '/' : uri;
        String backingClassName = FileUtils.stripFileExtension( uri.substring( 1 ).replace( '/', '.' ) );
        FacesBackingBean currentBean = InternalUtils.getFacesBackingBean( request, getServletContext() );
        
        //
        // If there is no current backing bean, or if the current one doesn't match the desired classname, create one.
        //
        if ( currentBean == null || ! currentBean.getClass().getName().equals( backingClassName ) )
        {
            FacesBackingBean bean = null;
            
            if ( FileUtils.uriEndsWith( uri, FACES_EXTENSION ) || FileUtils.uriEndsWith( uri, JSF_EXTENSION ) )
            {
                bean = loadFacesBackingBean( requestContext, backingClassName );
                
                //
                // If we didn't create (or failed to create) a backing bean, and if this is a JSF request, then create
                // a default one.  This ensures that there will be a place for things like page inputs, that get stored
                // in the backing bean across postbacks to the same JSF.
                //
                if ( bean == null ) bean = new DefaultFacesBackingBean();
                
                //
                // If we created a backing bean, invoke its create callback, and tell it to store itself in the session.
                //
                if ( bean != null )
                {
                    HttpServletResponse response = requestContext.getHttpResponse();
                    
                    try
                    {
                        bean.create( request, response, getServletContext() );
                    }
                    catch ( Exception e )
                    {
                        _log.error( "Error while creating backing bean instance of " + backingClassName, e );
                    }
                    
                    bean.persistInSession( request, response );
                    return bean;
                }
            }
            
            //
            // We didn't create a backing bean.  If there's one in the session (an inappropriate one), remove it.
            //
            InternalUtils.removeCurrentFacesBackingBean( request, getServletContext() );
        }
        else if ( currentBean != null )
        {
            if ( _log.isDebugEnabled() )
            {
                _log.debug( "Using existing backing bean instance " + currentBean + " for request " +
                            request.getRequestURI() );
            }
            
            currentBean.reinitialize( request, requestContext.getHttpResponse(), getServletContext() );
        }
        
        return currentBean;
    }
1372656
public Object getBean(String name) {
		Bean bean = beans.get(name);
		if (null == bean) {
			return null;
		}
		return bean.object;
	}
192727
public static PropertyDescriptor getPropertyDescriptor(Object bean, String propertyName)
	{
		BeanInfo beanInfo = getBeanInfo(bean);
		
		PropertyDescriptor propertyDescriptor = getFeatureDescriptor(propertyName, beanInfo.getPropertyDescriptors());

		checkArgument(propertyDescriptor != null, "No such property '%s' on bean: %s", propertyName, bean);
		
		return propertyDescriptor;
	}
286496
public Object get(final String name) {
        Object bean = this.beans.get(name);
        if (bean != null) {
            return bean;
        }
        return resolveBeanIfAbsent(name);
    }
14456
public static Method getReadMethod(Object bean, String name) {
		return getReadMethods(bean).get(name);
	}
479708
public BeanId getBeanId() {
        if (ivBeanId == null) {
            ivBeanId = new BeanId(ivBMD.j2eeName, null, false);
        }
        return ivBeanId;
    }
1255750
@Override
  public <T> T find(Class<T> beanType, Object id) {
    methodCalls.add(MethodCall.of("find").with("beanType", beanType, "id", id));
    WhenBeanReturn match = whenFind.findMatchById(beanType, id);
    if (match != null) {
      return (T)match.val();
    }
    return find.find(beanType, id, null);
  }
231458
private void lookupBeanScopeAndName(HttpServletRequest request, ServletContext servletContext)
            throws JspException
    {
        // Look up the application module configuration information we need
        _appConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
        if (_appConfig == null) { // Backwards compatibility hack
            _appConfig = (ModuleConfig) servletContext.getAttribute(Globals.MODULE_KEY);
        }
        if (_appConfig == null) {
            registerTagError(Bundle.getString("Tags_FormNoApplicationConfig"), null);
            return;
        }
        _servlet = (ActionServlet) servletContext.getAttribute(Globals.ACTION_SERVLET_KEY);
        _flowController = PageFlowUtils.getCurrentPageFlow(request, pageContext.getServletContext());

        // check to see if this is a bad action
        
        PageFlowTagUtils.MappingAndController mac = PageFlowTagUtils.getActionMapping(request, _flowController, _state.action);
        if (mac == null) {
            FlowController globalApp = PageFlowUtils.getSharedFlow(InternalConstants.GLOBALAPP_CLASSNAME, request);
            mac = PageFlowTagUtils.getActionMapping(request, globalApp, _state.action);
        }
        if (mac == null) {
            registerTagError(Bundle.getString("Tags_BadAction", _state.action), null);
            return;
        }

        _flowController = mac.controller;
        _mapping = mac.mapping;
        assert (_mapping != null) : "Mapping not found for controller";
        _appConfig = _mapping.getModuleConfig();

        // Were the required values already specified?
        if (_beanName != null) {
            if (!_explicitBeanType) {
                registerTagError(Bundle.getString("Tags_FormNameNoType"), null);
                return;
            }
            if (_beanScope == null)
                _beanScope = "session";
            return;
        }

        // Look up the form bean definition
        FormBeanConfig formBeanConfig = _appConfig.findFormBeanConfig(_mapping.getName());
        if (formBeanConfig == null) {
            // clear any _beanType
            _beanType = null;
        }
        else {
            // Calculate the required values
            _beanName = _mapping.getAttribute();
            _beanScope = _mapping.getScope();
            _beanType = formBeanConfig.getType();
        }
    }
959374
public <T> Object getBeanKey(Contextual<T> bean)
    {
        if (passivationCapable)
        {
            // if the
            return ((PassivationCapable) bean).getId();
        }

        return bean;
    }
1335221
public static BeanManager getBeanManager(Object ctx) {
        return (BeanManager) javax.portlet.PortletContext.class.cast(ctx).getAttribute(WeldServletLifecycle.BEAN_MANAGER_ATTRIBUTE_NAME);
    }
1255631
protected ConnectionFactory retrieveConnectionFactory(String name) throws JMSException {
        if (name == null && defaultConnectionFactory != null) {
            return defaultConnectionFactory; // injected
        }
        else {
            try {
                // autowiring did not occur
                return (ConnectionFactory)SpringAppContext.getInstance().getBean(name);
            }
            catch (Exception ex) {
                logger.severeException(ex.getMessage(), ex);
                throw new JMSException("JMS ConnectionFactory not found: " + name);
            }
        }
    }
1346973
public static ObjectName getAppJawrConfigMBeanObjectName(ServletContext servletContext, String mBeanPrefix) {

		return getMBeanObjectName(getContextPath(servletContext), JAWR_APP_CONFIG_MANAGER_TYPE, mBeanPrefix, null);
	}
1370908
private BeanDefinitionRegistry getBeanDefinitionRegistry(ApplicationContext context) {
		if (context instanceof BeanDefinitionRegistry) {
			return (BeanDefinitionRegistry) context;
		}
		if (context instanceof AbstractApplicationContext) {
			return (BeanDefinitionRegistry) ((AbstractApplicationContext) context)
					.getBeanFactory();
		}
		throw new IllegalStateException("Could not locate BeanDefinitionRegistry");
	}
1281126
public Object instantiateChild(String beanName) throws IOException, ClassNotFoundException
	{
		return Beans.instantiate(getClass().getClassLoader(), beanName, getBeanContextPeer());
	}
612560
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if( bean instanceof AuthenticationAware || bean instanceof LoginAware ) {

            // If the bean isn't a singleton, then add it to our list
            if( beanName == null || !getApplicationContext().containsBean( beanName )
                    || !getApplicationContext().isSingleton( beanName ) ) {
                addToNonSingletonListeners( bean );
            }

            // Install the last known authentication token
            if( bean instanceof AuthenticationAware ) {
                if( logger.isDebugEnabled() )
                    logger.debug( "NOTIFY bean '" + bean + "' of new authorization for '" + currentAuthentication
                            + "'" );

                AuthenticationAware aab = (AuthenticationAware) bean;
                aab.setAuthenticationToken(currentAuthentication);
            }
        }
        return bean;
    }