Use the given BeanManager to lookup the set of CDI-registered beans with
the given class name.

@return the bean with the given className. It returns null if there are zero matches or if there is no umabiguous resolution (i.e. more than 1 match)
187614
@FFDCIgnore({ ClassNotFoundException.class, BatchCDIAmbiguousResolutionCheckedException.class })
    protected Bean<?> getUniqueBeanForClassName(BeanManager bm, String className) {
        // Ignore exceptions since will just failover to another loading mechanism
        try {
            Class<?> clazz = getContextClassLoader().loadClass(className);
            return findUniqueBeanForClass(bm, clazz);
        } catch (BatchCDIAmbiguousResolutionCheckedException e) {
            if (logger.isLoggable(Level.FINER)) {
                logger.finer("getBeanForClassName: BatchCDIAmbiguousResolutionCheckedException: " + e.getMessage());
            }
            return null;
        } catch (ClassNotFoundException cnfe) {
            if (logger.isLoggable(Level.FINER)) {
                logger.finer("getBeanForClassName: ClassNotFoundException for " + className + ": " + cnfe);
            }
            return null;
        }
    }
66385
public final SgClass get(final String className) {
        if (className == null) {
            throw new IllegalArgumentException("The argument 'className' cannot be null!");
        }
        return cache.get(className);
    }
395884
public Set<ObjectName> getBeanNames() throws JMException {
		checkClientConnected();
		try {
			return mbeanConn.queryNames(null, null);
		} catch (IOException e) {
			throw createJmException("Problems querying for jmx bean names: " + e, e);
		}
	}
1003407
protected Bean<?> getBeanById(BeanManager bm, String id) {

        Bean<?> match = getUniqueBeanByBeanName(bm, id);

        if (match == null) {
            match = getUniqueBeanForBatchXMLEntry(bm, id);
        }

        if (match == null) {
            match = getUniqueBeanForClassName(bm, id);
        }

        return match;
    }
1344743
public ClassDocImpl lookupClass(String name) {
        ClassSymbol c = getClassSymbol(name);
        if (c != null) {
            return getClassDoc(c);
        } else {
            return null;
        }
    }
106306
public ClassDoc findClass(String className) {
        final boolean filtered = true;
        for (ClassDocImpl c : getClasses(filtered)) {
            if (c.name().equals(className)) {
                return c;
            }
        }
        return null;
    }
159542
protected final Class findClass(final String name)
			throws ClassNotFoundException {
		try {
			if (name == null) {
				return null;
			}

			if (name.startsWith("java.") || name.startsWith("sun.reflect")) {
				return ClassLoader.getSystemClassLoader().loadClass(name);
			}

			final String searchClass = name.replace('.', '/') + ".class";
			final CThreadContext context = CThreadContext.getInstance();
			final String cpName = CClassLoader.CCLASSLOADER_NAMESPACE + name;

			List lPriorLoader = (List) context.get(cpName);

			if (lPriorLoader == null) {
				lPriorLoader = new Vector();
				context.set(cpName, lPriorLoader);
			}

			if (lPriorLoader.contains(this.toString())) {
				return null;
			}

			lPriorLoader.add(this.toString());

			if (CClassLoader.sl(CClassLoader.DEBUG)) {
				CClassLoader.log("Searching " + name + " in " + this.getPath(),
						CClassLoader.DEBUG);
			}

			final WeakReference cache = (WeakReference) this.cacheMap.get(name);
			if (cache != null) {
				final Class c = (Class) cache.get();
				if (c != null) {
					return c;
				}
			}

			// first check if this class as a mandatory loader
			if (!this.booAlone) {
				CClassLoader loader = null;

				for (final Iterator it = CClassLoader.mandatoryLoadersMap
						.entrySet().iterator(); it.hasNext();) {
					final Entry entry = (Entry) it.next();
					loader = (CClassLoader) entry.getValue();

					if (loader.classesMap.containsKey(searchClass)) {
						if (loader != this) {
							break;
						}
						loader = null;
						break;
					}
					loader = null;
				}

				if (loader != null) {
					final Class c = loader.findClass(name);
					if (c != null) {
						return c;
					}
				}
			}

			// second search in this repository
			byte buffer[] = null;

			final URL urlToResource = (URL) this.classesMap.get(searchClass);

			if (urlToResource != null) {
				buffer = CClassLoader.loadByteArray(urlToResource);
			}

			if (buffer != null) {
				if (CClassLoader.sl(CClassLoader.DEBUG)) {
					CClassLoader.log(
							"Loaded " + name + " in " + this.getPath(),
							CClassLoader.DEBUG);
				}

				Class c = null;
				c = this.findLoadedClass(name);

				if (c == null) {
					try {
						c = this.defineClass(name, buffer, 0, buffer.length);
					} catch (final LinkageError e) {
						c = this.findLoadedClass(name);

						if (c == null) {
							throw new ClassNotFoundException(name
									+ " was not found !");
						}
					}
				}

				if (c != null) {
					return c;
				}
			}

			// then search in each children
			final List tmpLoader = new ArrayList();

			for (final Iterator it = this.childrenMap.entrySet().iterator(); it
					.hasNext();) {
				final Entry entry = (Entry) it.next();
				final CClassLoader child = (CClassLoader) entry.getValue();

				if (lPriorLoader.contains(child.toString())) {
					continue;
				}

				tmpLoader.add(child);
			}

			for (final Iterator it = tmpLoader.iterator(); it.hasNext();) {
				final Object element = it.next();
				final CClassLoader child = (CClassLoader) element;
				final Class c = child.findClass(name);

				if (c != null) {
					return c;
				}
			}

			// then follow to parents
			if ((this != CClassLoader.getRootLoader())
					&& !this.booDoNotForwardToParent) {
				if (lPriorLoader.contains(this.getParent().toString())) {
					return null;
				} else {
					if (this.getParent() instanceof CClassLoader) {
						return ((CClassLoader) this.getParent())
								.findClass(name);
					} else {
						return this.getParent().loadClass(name);
					}
				}
			} else {
				try {
					ClassLoader contextLoader = CClassLoader.getContextLoader();
					if (contextLoader == null) {
						contextLoader = CClassLoader.getRootLoader()
								.getParent();
					}
					final Class c = contextLoader.loadClass(name);
					if (c != null) {
						return c;
					}
				} catch (Throwable e) {
					final Class c = CClassLoader.getRootLoader().getParent()
							.loadClass(name);
					if (c != null) {
						return c;
					}
				}
				throw new ClassNotFoundException(name);
			}
		} catch (ClassNotFoundException e) {
			throw e;
		} catch (NoClassDefFoundError e) {
			throw e;
		} catch (Throwable e) {
			throw new ClassNotFoundException(name, e);
		}
	}
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;
	}
1228995
public <T> T getBean(Class<T> beanType) throws BeansException {
        return beanType.cast(BeanFactoryUtils.beanOfTypeIncludingAncestors(this, beanType));
    }
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);
  }
1268403
public Class getClassByName(String name)
	{

		if (name.indexOf(".") != -1)
		{
			try
			{
				return Class.forName(name,true,gt.getClassLoader());
			}
			catch (ClassNotFoundException e)
			{
				return null;
			}

		}
		else
		{
			Class cls = map.get(name);
			if (cls == null)
			{
				for (String pkg : pkgList)
				{
					try
					{
						String clsName = pkg.concat(name);
						cls = Class.forName(clsName,true,gt.getClassLoader());
						map.put(name, cls);
						return cls;

					}
					catch (Exception ex)
					{
						// continue;
					}
				}
				return null;
			}
			else
			{
				return cls;
			}

		}

	}
340433
protected JClass loadClass(String name)
  {
    // JDK classes are not loaded, but javax are (e.g. for JSF)
    if (name.startsWith("java.") || name.startsWith("java/")) {
      return getStaticClassLoader().forName(name);
    }

    String classPath = name.replace('.', '/') + ".class";
    URL url = _loader.getResource(classPath);

    if (url != null) {
      JavaClass jClass = new JavaClass(this);
      jClass.setURL(url);

      jClass.setThisClass(name.replace('.', '/'));

      return jClass;
    }

    return null;
  }
286562
@SuppressWarnings("unchecked")
	public <T> T getInstance(Class<T> beanClass) {
		String[] beanNames = applicationContext.getBeanNamesForType(beanClass);
		if (beanNames.length == 0) {
			return null;
		}
		return (T) applicationContext.getBean(beanNames[0]);
	}
1247135
@Override
    public Object lookup(String name)
    {
        // Note: this context method is allowed from all bean methods,
        //       except the constructor... which has not way to access
        //       the context.  Therefore, no 'state' checking needs
        //       to be performed... just validate the parameter.
        if (name == null)
            throw new IllegalArgumentException("null 'name' parameter.");

        Object result = null;

        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "lookup: " + name);

        // Previously, this method used Naming for comp/env, which tolerated the
        // 'name' starting with 'java:comp/env/', but that is NOT part of the
        // name in our map.                                                d473811
        String lookupName = name;
        if (name.startsWith("java:comp/env/")) // F743-609 remove useless null check
        {
            lookupName = name.substring(14);
        }

        // -----------------------------------------------------------------------
        // Rather than perform a lookup using Naming, the InjectionBinding
        // that was created during populateJavaNameSpace will be located
        // and used to obtain/create the result object, just like it
        // would be done for injection.                                    d473811
        // -----------------------------------------------------------------------

        InjectionBinding<?> binding = home.beanMetaData.ivJavaColonCompEnvMap.get(lookupName);

        if (binding != null)
        {
            try
            {
                result = binding.getInjectionObject();
            } catch (InjectionException ex)
            {
                FFDCFilter.processException(ex, CLASS_NAME + ".lookup",
                                            "1342", this);
                IllegalArgumentException iae = new IllegalArgumentException
                                ("Failure occurred obtaining object for " + name +
                                 " reference defined for " + home.beanMetaData.j2eeName, ex);

                if (isTraceOn && tc.isEntryEnabled())
                    Tr.exit(tc, "lookup: " + iae);

                throw iae;
            }
        }
        else
        {
            result = container.getEJBRuntime().javaColonLookup(name, home);
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "lookup: " + result.getClass().getName());

        return result;
    }
1158527
protected static Class findClass(final String className) throws ClassNotFoundException {
        try {
            return Thread.currentThread().getContextClassLoader().loadClass(className);
        } catch (ClassNotFoundException e) {
            try {
                return Class.forName(className);
            } catch (ClassNotFoundException e1) {
                return MavenCoordHelper.class.getClassLoader().loadClass(className);
            }
        }
    }
992010
protected EntityManagerFactory lookupEntityManagerFactory(OpenEntityManager openEntityManager) {
        String emfBeanName = openEntityManager.name();
        String puName = openEntityManager.unitName();
        if (StringUtils.hasLength(emfBeanName)) {
            return this.applicationContext.getBean(emfBeanName, EntityManagerFactory.class);
        } else if (!StringUtils.hasLength(puName)
                && this.applicationContext.containsBean(
                        OpenEntityManagerInViewFilter.DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME)) {
            return this.applicationContext.getBean(
                    OpenEntityManagerInViewFilter.DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME,
                    EntityManagerFactory.class);
        } else {
            // Includes fallback search for single EntityManagerFactory bean by type.
            return EntityManagerFactoryUtils.findEntityManagerFactory(
                    this.applicationContext, puName);
        }
    }
1179403
private Object resolveBean(String name, Class<?> type)
   {
      try
      {
         return embedded.lookup(name, type);
      }
      catch (Throwable t)
      {
         return null;
      }
   }