Read Bean annotations to build a BeanBox instance
504364
private static BeanBox doCreateBeanBox(BeanBoxContext ctx, Class<?> clazz) {// NOSONAR
		BeanBox box = new BeanBox();
		box.setBeanClass(clazz);
		box.setSingleton(true);// Annotated class, default is singleton

		if (!ctx.isAllowAnnotation())
			return box;
		boolean allowSpringJsrAnno = ctx.allowSpringJsrAnnotation;

		// ========= singleton or prototype
		if (checkAnnoExist(clazz, PROTOTYPE.class))
			box.setSingleton(false);
		else if (allowSpringJsrAnno) {
			Map<String, Object> m = getAnnoAsMap(clazz, "org.springframework.context.annotation.Scope");
			if (m != null)
				for (Entry<String, Object> entry : m.entrySet())
					if ("value".equals(entry.getKey())) {
						if ("prototype".equalsIgnoreCase(String.valueOf(entry.getValue())))
							box.setSingleton(false);
						else if ("singleton".equalsIgnoreCase(String.valueOf(entry.getValue())))
							box.setSingleton(true);
						else
							BeanBoxException.throwEX("'prototype' or 'singleton' required in @Scope annotation");
					}
		}

		// ======== Class inject, if @INJECT, @PARAM put on class
		Object[] v = getInjectAnnotationAsArray(clazz, allowSpringJsrAnno);
		if (v != null) {
			box.setTarget(v[0]);
			box.setPureValue((Boolean) v[1]);
			box.setRequired((Boolean) v[2]);
		}

		// ======== AOP annotated annotations on class
		Annotation[] annos = clazz.getAnnotations();
		for (Annotation anno : annos) {
			if (anno.annotationType().isAnnotationPresent(AOP.class)) {
				Map<String, Object> annoMap = changeAnnotationValuesToMap(anno);
				Object aop = annoMap.get("value");
				String methodNameRule = (String) annoMap.get("method");// name must be method
				if (methodNameRule != null && methodNameRule.length() > 0 && aop != null)
					box.addBeanAop(aop, methodNameRule);
			}
		}

		// ========== Constructor inject
		Constructor<?>[] constrs = clazz.getConstructors();
		for (Constructor<?> constr : constrs) {
			v = getInjectAnnotationAsArray(constr, allowSpringJsrAnno);
			if (v != null) {
				box.setBeanClass(clazz);// anyway set beanClass first
				if (v[0] != null && EMPTY.class != v[0]) {// 1 parameter only
					BeanBox inject = new BeanBox();
					inject.setTarget(v[0]);
					inject.setPureValue((Boolean) v[1]);
					inject.setRequired((Boolean) v[2]);
					inject.setType(constr.getParameterTypes()[0]);
					box.setConstructor(constr);
					box.setConstructorParams(new BeanBox[] { inject });
				} else { // no or many parameter
					BeanBox[] paramInjects = getParameterInjectAsBeanBoxArray(constr, allowSpringJsrAnno);
					box.setConstructor(constr);
					box.setConstructorParams(paramInjects);
				}
			}
		}

		// =================Field inject=================
		// @INJECT annotations on fields include super class's
		for (Field f : ReflectionUtils.getSelfAndSuperClassFields(clazz)) {
			v = getInjectAnnotationAsArray(f, allowSpringJsrAnno);
			if (v != null) {
				box.checkOrCreateFieldInjects();
				BeanBox inject = new BeanBox();
				inject.setTarget(v[0]);
				inject.setPureValue((Boolean) v[1]);
				inject.setRequired((Boolean) v[2]);
				inject.setType(f.getType());
				ReflectionUtils.makeAccessible(f);
				box.getFieldInjects().put(f, inject);
			}
		}

		// @INJECT annotations on methods include super class's
		Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz); 
		for (Method m : methods) { 
			// ========== @PostConstruct and @PreDestory
			if (m.getAnnotation(POSTCONSTRUCT.class) != null || m.getAnnotation(PostConstruct.class) != null) {
				if (m.getParameterTypes().length > 0)
					BeanBoxException.throwEX("In jBeanBox, PostConstruct should have no parameter.");
				ReflectionUtils.makeAccessible(m);
				box.setPostConstruct(m);
			}
			if (m.getAnnotation(PREDESTROY.class) != null || m.getAnnotation(PreDestroy.class) != null) {
				if (m.getParameterTypes().length > 0)
					BeanBoxException.throwEX("In jBeanBox, PostConstruct should have no parameter.");
				ReflectionUtils.makeAccessible(m);
				box.setPreDestroy(m);
			}

			// ========== AOP about annotation =========
			Annotation[] mtdAnnos = m.getAnnotations();
			for (Annotation anno : mtdAnnos)
				if (anno.annotationType().isAnnotationPresent(AOP.class)) {
					Map<String, Object> annoMap = changeAnnotationValuesToMap(anno);
					Object aop = annoMap.get("value");
					if (aop != null)
						box.addMethodAop(aop, m);
				}

			// =========== method inject annotation ==============
			v = getInjectAnnotationAsArray(m, allowSpringJsrAnno);
			if (v != null) {
				ReflectionUtils.makeAccessible(m);
				BeanBox oneParam = new BeanBox();
				oneParam.setTarget(v[0]);
				oneParam.setPureValue((Boolean) v[1]);
				oneParam.setRequired((Boolean) v[2]);
				boolean haveOneParameter = v[0] != null && EMPTY.class != v[0];
				if (haveOneParameter)
					oneParam.setType(m.getParameterTypes()[0]); // set parameter type for 1 parameter
				// @INJECT or @Inject or @Autowired normal method inject
				box.checkOrCreateMethodInjects();
				if (haveOneParameter) // 1 parameter only
					box.getMethodInjects().put(m, new BeanBox[] { oneParam });
				else { // no or many parameter
					BeanBox[] paramInjects = getParameterInjectAsBeanBoxArray(m, allowSpringJsrAnno);
					box.getMethodInjects().put(m, paramInjects);
				}
			}
		}
		return box;

	}
129845
private static Map<String, String> findServiceBeanDefinitions(ConfigurableListableBeanFactory beanFactory) {
		final Map<String, String> serviceBeanNames = new HashMap<>();
		
		for (String beanName : beanFactory.getBeanDefinitionNames()) {
			AutoJsonRpcServiceImpl autoJsonRpcServiceImplAnnotation = beanFactory.findAnnotationOnBean(beanName, AutoJsonRpcServiceImpl.class);
			JsonRpcService jsonRpcServiceAnnotation = beanFactory.findAnnotationOnBean(beanName, JsonRpcService.class);
			
			if (null != autoJsonRpcServiceImplAnnotation) {
				
				if (null == jsonRpcServiceAnnotation) {
					throw new IllegalStateException("on the bean [" + beanName + "], @" +
							AutoJsonRpcServiceImpl.class.getSimpleName() + " was found, but not @" +
							JsonRpcService.class.getSimpleName() + " -- both are required");
				}
				
				List<String> paths = new ArrayList<>();
				Collections.addAll(paths, autoJsonRpcServiceImplAnnotation.additionalPaths());
				paths.add(jsonRpcServiceAnnotation.value());
				
				for (String path : paths) {
					if (!PATTERN_JSONRPC_PATH.matcher(path).matches()) {
						throw new RuntimeException("the path [" + path + "] for the bean [" + beanName + "] is not valid");
					}
					
					logger.info("exporting bean [{}] ---> [{}]", beanName, path);
					if (isNotDuplicateService(serviceBeanNames, beanName, path)) {
                        serviceBeanNames.put(path, beanName);
                    }
				}
				
			}
		}
		
		collectFromParentBeans(beanFactory, serviceBeanNames);
		return serviceBeanNames;
	}
169771
public void initBeans(Object[] beans) {
        this.controllers = Arrays.stream(beans).filter(bean -> this.getController(bean) != null).map(bean -> this.getController(bean)).collect(Collectors.toList());
    }
612
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out)
    {
        //
        // Get the bean and associated beanInfo for the source instance
        //
        ControlBean control = (ControlBean)oldInstance;
        BeanInfo beanInfo;
        try
        {
            beanInfo = Introspector.getBeanInfo(control.getClass());
        }
        catch (IntrospectionException ie)
        {
            throw new ControlException("Unable to locate BeanInfo", ie);
        }

        //
        // Cast the encoding stream to an XMLEncoder (only encoding supported) and then set
        // the stream owner to the bean being persisted
        //
        XMLEncoder xmlOut = (XMLEncoder)out;
        Object owner = xmlOut.getOwner();
        xmlOut.setOwner(control);
        try
        {

            //
            // The default implementation of property persistence will use BeanInfo to 
            // incrementally compare oldInstance property values to newInstance property values.   
            // Because the bean instance PropertyMap holds only the values that have been 
            // modified, this process can be optimized by directly writing out only the properties 
            // found in the map.
            //
            BeanPropertyMap beanMap = control.getPropertyMap();
            PropertyDescriptor [] propDescriptors = beanInfo.getPropertyDescriptors();
            for (PropertyKey pk : beanMap.getPropertyKeys())
            {
                //
                // Locate the PropertyDescriptor for the modified property, and use it to write
                // the property value to the encoder stream
                //
                String propName = pk.getPropertyName();
                boolean found = false;
                for (int i = 0; i < propDescriptors.length; i++)
                {
                    if (propName.equals(propDescriptors[i].getName()))
                    {
                        found = true;

                        // Only write the property if it is not flagged as transient
                        Object transientVal = propDescriptors[i].getValue("transient");
                        if (transientVal == null || transientVal.equals(Boolean.FALSE))
                        {
                            xmlOut.writeStatement(
                                new Statement(oldInstance, 
                                      propDescriptors[i].getWriteMethod().getName(),
                                      new Object [] {beanMap.getProperty(pk)}));
                        }
                    }
                }
                if (found == false)
                {
                    throw new ControlException("Unknown property in bean PropertyMap: " + pk);
                }
            }

            //
            // Get the bean context associated with the bean, and persist any nested controls
            //
            ControlBeanContext cbc = control.getControlBeanContext();
            if (cbc.size() != 0)
            {
                xmlOut.setPersistenceDelegate(ControlBeanContext.class, 
                                              new ContextPersistenceDelegate());

                Iterator nestedIter = cbc.iterator();
                while (nestedIter.hasNext())
                {
                    Object bean = nestedIter.next();
                    if (bean instanceof ControlBean)
                    {
                        xmlOut.writeStatement(
                            new Statement(cbc, "add", new Object [] { bean } ));
                    }
                }
            }

            //
            // Restore any listeners associated with the control
            //
            EventSetDescriptor [] eventSetDescriptors = beanInfo.getEventSetDescriptors();
            for (int i = 0; i < eventSetDescriptors.length; i++)
            {
                EventSetDescriptor esd = eventSetDescriptors[i];
                Method listenersMethod = esd.getGetListenerMethod();
                String addListenerName = esd.getAddListenerMethod().getName();
                if (listenersMethod != null)
                {
                    //
                    // Get the list of listeners, and then add statements to incrementally
                    // add them in the same order
                    //
                    try
                    {
                        Object [] lstnrs = (Object [])listenersMethod.invoke(control, 
                                                                             new Object []{});
                        for (int j = 0; j < lstnrs.length; j++)
                        {
                            //
                            // If this is a generated EventAdaptor class, then set the delegate
                            // explicitly
                            //
                            if (lstnrs[j] instanceof EventAdaptor)
                                xmlOut.setPersistenceDelegate(lstnrs[j].getClass(), 
                                                              new AdaptorPersistenceDelegate());
                            xmlOut.writeStatement(
                                new Statement(control, addListenerName, new Object [] {lstnrs[j]}));
                        }
                    }
                    catch (Exception iae)
                    {
                        throw new ControlException("Unable to initialize listeners", iae);
                    } 
                }
            }

            //
            // See if the control holds an implementation instance, if so, we need to include
            // it (and any nested controls or state) in the encoding stream
            //
            Object impl = control.getImplementation();
            if (impl != null)
            {

                //
                // Set the persistence delegate for the impl class to the Impl delegate,
                // set the current stream owner to the bean, and then write the implementation
                //
                Class implClass = impl.getClass(); 
                if (xmlOut.getPersistenceDelegate(implClass) instanceof DefaultPersistenceDelegate) 
                    xmlOut.setPersistenceDelegate(implClass, new ImplPersistenceDelegate());

                //
                // HACK: This bit of hackery pushes the impl into the persistence stream
                // w/out actually requiring it be used as an argument elsewhere, since there
                // is no public API on the bean that takes an impl instance as an argument.
                //
                xmlOut.writeStatement(
                    new Statement(impl, "toString", null));
            }
        }
        finally
        {
            // Restore the previous encoding stream owner
            xmlOut.setOwner(owner);
        }
    }
1306430
private static String[] fieldNames(Class<?> beanType) {
        Field[] fields = Stream.of(beanType.getDeclaredFields())
                .filter(f -> !Modifier.isStatic(f.getModifiers()) && f.getAnnotation(PropertyDefinition.class) != null)
                .toArray(Field[]::new);
        List<String> fieldNames = new ArrayList<>();
        for (int i = 0; i < fields.length; i++) {
            fieldNames.add(fields[i].getName());
        }
        return fieldNames.toArray(new String[fieldNames.size()]);
    }
317330
BeanGen parse() {
        BeanData data = new BeanData();
        beanDefIndex = parseBeanDefinition();
        data.getCurrentImports().addAll(parseImports(beanDefIndex));
        data.setImportInsertLocation(parseImportLocation(beanDefIndex));
        if (beanDefIndex < 0) {
            return new BeanGen(file, content, config, data);
        }
        data.setBeanStyle(parseBeanStyle(beanDefIndex));
        data.resolveBeanStyle(config.getDefaultStyle());
        if (data.isBeanStyleValid() == false) {
            throw new BeanCodeGenException("Invalid bean style: " + data.getBeanStyle(), file, beanDefIndex);
        }
        data.setConstructorScope(parseConstrucorScope(beanDefIndex));
        if (data.isConstructorScopeValid() == false) {
            throw new BeanCodeGenException("Invalid constructor scope: " + data.getConstructorScope(), file, beanDefIndex);
        }
        data.setBeanMetaScope(parseBeanMetaScope(beanDefIndex));
        if (data.isBeanMetaScopeValid() == false) {
            throw new BeanCodeGenException("Invalid meta-bean scope: " + data.getBeanMetaScope(), file, beanDefIndex);
        }
        data.setBeanBuilderScope(parseBeanBuilderScope(beanDefIndex));
        if (data.isBeanBuilderScopeValid() == false) {
            throw new BeanCodeGenException("Invalid bean builder scope: " + data.getBeanBuilderScope(), file, beanDefIndex);
        }
        data.setFactoryName(parseFactoryName(beanDefIndex));
        data.setCacheHashCode(parseCacheHashCode(beanDefIndex));
        data.setCloneStyle(parseCloneStyle(beanDefIndex));
        if (data.isCloneStyleValid() == false) {
            throw new BeanCodeGenException("Invalid clone style: " + data.getCloneStyle(), file, beanDefIndex);
        }
        data.setImmutableConstructor(parseImmutableConstructor(beanDefIndex));
        data.setConstructable(parseConstructable(beanDefIndex));
        data.setTypeParts(parseBeanType(beanDefIndex));
        String classHeaderAfterType = classHeaderAfterType(beanDefIndex, data.getType());
        data.setSuperTypeParts(parseBeanSuperType(classHeaderAfterType));
        data.setSerializable(parseSerializable(classHeaderAfterType));
        if (parseBeanHierarchy(beanDefIndex).equals("immutable")) {
            data.setImmutable(true);
            data.setConstructorStyle(CONSTRUCTOR_BY_BUILDER);
        } else if (data.getImmutableConstructor() == CONSTRUCTOR_NONE) {
            if (data.isImmutable()) {
                if (data.isTypeFinal()) {
                    data.setConstructorStyle(CONSTRUCTOR_BY_ARGS);
                } else {
                    data.setConstructorStyle(CONSTRUCTOR_BY_BUILDER);
                }
            } else {
                if (data.isBeanStyleLight()) {
                    data.setConstructorStyle(CONSTRUCTOR_BY_ARGS);
                } else {
                    data.setConstructorStyle(CONSTRUCTOR_BY_BUILDER);
                }
            }
        } else {
            data.setConstructorStyle(data.getImmutableConstructor());
        }
        if (data.isImmutable()) {
            data.setImmutableValidator(parseImmutableValidator(beanDefIndex));
            data.setImmutableDefaults(parseImmutableDefaults(beanDefIndex));
            data.setImmutablePreBuild(parseImmutablePreBuild(beanDefIndex));
            if (data.isBeanStyleLight() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Light beans must be declared final", file, beanDefIndex);
            }
            if (data.isBeanStyleMinimal() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Minimal beans must be declared final", file, beanDefIndex);
            }
            if (data.isFactoryRequired() && !data.isRootClass()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Factory method only allowed when bean has no bean superclass", file, beanDefIndex);
            }
            if (data.isFactoryRequired() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Factory method only allowed when bean is final", file, beanDefIndex);
            }
        } else {
            if (data.isBeanStyleLight() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Light beans must be declared final", file, beanDefIndex);
            }
            if (data.isBeanStyleMinimal() && !data.isTypeFinal()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Minimal beans must be declared final", file, beanDefIndex);
            }
            if (data.isFactoryRequired()) {
                throw new BeanCodeGenException(
                        "Invalid bean style: Factory method only allowed when bean is immutable", file, beanDefIndex);
            }
        }
        properties = parseProperties(data);
        autoStartIndex = parseStartAutogen();
        autoEndIndex = parseEndAutogen();
        data.setManualSerializationId(parseManualSerializationId(beanDefIndex));
        data.setManualClone(parseManualClone(beanDefIndex));
        data.setManualEqualsHashCode(parseManualEqualsHashCode(beanDefIndex));
        data.setManualToStringCode(parseManualToStringCode(beanDefIndex));
        if (data.isImmutable()) {
            for (PropertyGen prop : properties) {
                if (prop.getData().isDerived() == false && prop.getData().isFinal() == false) {
                    throw new BeanCodeGenException("ImmutableBean must have final properties: " +
                            data.getTypeRaw() + "." + prop.getData().getFieldName(),
                            file, prop.getData().getLineIndex());
                }
            }
        } else {
            if (data.getImmutableConstructor() > CONSTRUCTOR_NONE) {
                throw new BeanCodeGenException("Mutable beans must not specify @ImmutableConstructor: " +
                        data.getTypeRaw(), file, beanDefIndex);
            }
            if (!"smart".equals(data.getConstructorScope()) && !data.isBeanStyleLight()) {
                throw new BeanCodeGenException("Mutable beans must not specify @BeanDefinition(constructorScope): " +
                                data.getTypeRaw(), file, beanDefIndex);
            }
        }
        if (data.isCacheHashCode()) {
            data.setCacheHashCode(data.isImmutable() && data.isManualEqualsHashCode() == false);
        }
        return new BeanGen(file, content, config, data, properties, autoStartIndex, autoEndIndex);
    }
823196
private static Stream<PropertyDescriptor> getPropertyDescriptors(Class<?> clazz) {

		return Arrays.stream(BeanUtils.getPropertyDescriptors(clazz))
				.filter(descriptor -> !FIELDS_TO_IGNORE.contains(descriptor.getName()))
				.filter(descriptor -> !descriptorToBeIgnoredByJackson(clazz, descriptor))
				.filter(descriptor -> !toBeIgnoredByJackson(clazz, descriptor.getName()))
				.filter(descriptor -> !readerIsNotToBeIgnoredByJackson(descriptor));
	}
236393
private void registerJsfCdiToSpring(BeanDefinition definition) {

		if (definition instanceof AnnotatedBeanDefinition) {
			AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

			String scopeName = null;
			// firstly check whether bean is defined via configuration
			if (annDef.getFactoryMethodMetadata() != null) {
				scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
			}
			else {
				// fallback to type
				scopeName = deduceScopeName(annDef.getMetadata());
			}

			if (scopeName != null) {
				definition.setScope(scopeName);

				log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
			}
		}
	}
730579
private void parseProperties(Element element, BeanDefinitionBuilder builder,
                                 ManagedList<AbstractBeanDefinition> propertyList) {
        NodeList properties = element.getChildNodes();

        for (int i = 0; i < properties.getLength(); i++) {
            Node node = properties.item(i);

            if (!(node instanceof Element)) {
                continue;
            }

            Element property = (Element) node;
            BeanDefinitionBuilder propertyBuilder = BeanDefinitionBuilder.genericBeanDefinition(PropertyInfo.class);
            addProperties(property, propertyBuilder);
            parseConfig(property, propertyBuilder);
            propertyList.add(propertyBuilder.getBeanDefinition());
        }
    }
1014214
public static Annotation[] readAnnotations(ValueExpression p_expression, UIComponent p_component) {
		FacesContext context = FacesContext.getCurrentInstance();
		ELContext elContext = context.getELContext();
		try {
			ValueReference valueReference = p_expression.getValueReference(elContext);
			Object base;
			if (null == valueReference) {
				base = evaluteBaseForMojarra(elContext, p_expression);
			} else {
				base = valueReference.getBase();
			}
			if (null == base) {
				return null;
			}
			Field declaredField = getField(base, p_expression.getExpressionString());
			if (null != declaredField) {
				return declaredField.getAnnotations();
			}
			Method getter = getGetter(base, p_expression.getExpressionString());
			if (null != getter) {
				return getter.getAnnotations();
			}
		} catch (PropertyNotFoundException ex) {
			// this happens if a bean is null. That's a legal state, so suffice it to return no annotation.
		}
		return null;
	}
904891
protected void init(Map stormConf, TopologyContext topologyContext) {
		setId(topologyContext.getThisComponentId());

		try {
			method = inputSignature.findMethod(beanType);
			logger.info("{} uses {}", this, method.toGenericString());
		} catch (ReflectiveOperationException e) {
			throw new IllegalStateException("Unusable input signature", e);
		}

		if (spring == null)
			spring = SingletonApplicationContext.get(stormConf, topologyContext);

		spring.getBean(beanType);
		logger.debug("Bean lookup successful");
	}
1352716
private static BeanProperty[][] getBeanProperties(Class beanType, PropertySet set) {
        List readProperties = new ArrayList();
        List writeProperties = new ArrayList();

        Map map = BeanIntrospector.getAllProperties(beanType);

        Iterator it = map.values().iterator();
        while (it.hasNext()) {
            BeanProperty bp = (BeanProperty)it.next();

            if (set == PropertySet.READ_WRITE ||
                set == PropertySet.READ_WRITE_UNCHECKED_EXCEPTIONS)
            {
                if (bp.getReadMethod() == null || bp.getWriteMethod() == null) {
                    continue;
                }
            }
 
            boolean checkedAllowed = 
                set != PropertySet.UNCHECKED_EXCEPTIONS &&
                set != PropertySet.READ_WRITE_UNCHECKED_EXCEPTIONS;

            if (bp.getReadMethod() != null) {
                if (checkedAllowed || !throwsCheckedException(bp.getReadMethod())) {
                    readProperties.add(bp);
                }
            }
            if (bp.getWriteMethod() != null) {
                if (checkedAllowed || !throwsCheckedException(bp.getWriteMethod())) {
                    writeProperties.add(bp);
                }
            }
        }

        BeanProperty[][] props = new BeanProperty[2][];
        
        props[0] = new BeanProperty[readProperties.size()];
        readProperties.toArray(props[0]);
        props[1] = new BeanProperty[writeProperties.size()];
        writeProperties.toArray(props[1]);

        return props;
    }
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;
	}
1257765
protected <T> void buildHeaderMapper(final BeanMapping<T> beanMapping, final CsvBean beanAnno) {
        
        final HeaderMapper headerMapper = (HeaderMapper) configuration.getBeanFactory().create(beanAnno.headerMapper());
        beanMapping.setHeaderMapper(headerMapper);
        
        beanMapping.setHeader(beanAnno.header());
        beanMapping.setValidateHeader(beanAnno.validateHeader());
        
    }
115819
public static BeanBox getUniqueBeanBox(BeanBoxContext ctx, Class<?> clazz) {
		BeanBoxException.assureNotNull(clazz, "Target class can not be null");
		BeanBox box = ctx.beanBoxMetaCache.get(clazz);
		if (box != null)
			return box;
		if (BeanBox.class.isAssignableFrom(clazz))
			try {
				box = (BeanBox) clazz.newInstance();
				if (box.singleton == null)
					box.singleton = true;
			} catch (Exception e) {
				BeanBoxException.throwEX(e);
			}
		else
			box = doCreateBeanBox(ctx, clazz);
		ctx.beanBoxMetaCache.put(clazz, box);
		return box;
	}
109917
protected void autowireBean(String beanName, BeanDefinition mbd, BindRegistry registry) {
    Map<String, Class<?>> properties = unsatisfiedNonSimpleProperties(mbd);
    for (Map.Entry<String, Class<?>> entry : properties.entrySet()) {
      String propertyName = entry.getKey();
      Class<?> propertyType = entry.getValue();
      List<String> beanNames = registry.getBeanNames(propertyType);
      List<String> innerNames = CollectUtils.newArrayList();
      for (String n : beanNames) {
        if (n.contains("#")) innerNames.add(n);
      }
      beanNames.removeAll(innerNames);
      boolean binded = false;
      if (beanNames.size() == 1) {
        mbd.getPropertyValues().add(propertyName, new RuntimeBeanReference(beanNames.get(0)));
        binded = true;
      } else if (beanNames.size() > 1) {
        // first autowire by primary
        for (String name : beanNames) {
          if (registry.isPrimary(name)) {
            mbd.getPropertyValues().add(propertyName, new RuntimeBeanReference(name));
            binded = true;
            break;
          }
        }
        // second autowire by name
        if (!binded) {
          for (String name : beanNames) {
            if (name.equals(propertyName)) {
              mbd.getPropertyValues().add(propertyName, new RuntimeBeanReference(name));
              binded = true;
              break;
            }
          }
        }
      }
      if (!binded) {
        if (beanNames.isEmpty()) {
          logger.debug("{}'s {} cannot found candidate beans.", beanName, propertyName);
        } else {
          logger.warn("{}'s {} expected single bean but found {} : {}",
              new Object[] { beanName, propertyName, beanNames.size(), beanNames });
        }
      }
    }
  }
1316693
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {

		if (beanFactory == null) {
			return;
		}

		String[] beanNames = beanFactory.getBeanDefinitionNames();
		int singletonBeanCount = 0;

		for (int i = 0; i < beanNames.length; i++) {
			// using beanDefinition to check singleton property because when
			// accessing through
			// context (applicationContext.isSingleton(beanName)), bean will be
			// created already,
			// possibly bypassing other BeanFactoryPostProcessors
			BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanNames[i]);

			if (beanDefinition.isSingleton()) {
				singletonBeanCount++;
			}

		}

		this.progressMonitor.taskStarted(this.loadingAppContextMessage, singletonBeanCount);

		beanFactory.addBeanPostProcessor(new ProgressMonitoringBeanPostProcessor(beanFactory));

	}