Spring Framework AutowiredAnnotationBeanPostProcessor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AutowiredAnnotationBeanPostProcessor class.

This code example shows how to use the following methods:processInjection, setBeanFactory
	 */ 
	public static void processInjectionBasedOnCurrentContext(Object target) { 
		Assert.notNull(target, "Target object must not be null"); 
		WebApplicationContext cc = ContextLoader.getCurrentWebApplicationContext(); 
		if (cc != null) { 
			AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); 
			bpp.setBeanFactory(cc.getAutowireCapableBeanFactory()); 
			bpp.processInjection(target); 
		} 
		else { 
			if (logger.isDebugEnabled()) { 
				logger.debug("Current WebApplicationContext is not available for processing of " + 
						ClassUtils.getShortName(target.getClass()) + ": " + 
						"Make sure this class gets constructed in a Spring web application. Proceeding without injection."); 
			} 
		} 
	} 
 
 
	/** 
7
CodeRank
This code example shows how to use the following methods:determineCandidateConstructors
	//  } 
 
	@Override 
	@SuppressWarnings({ "unchecked", "rawtypes" }) 
	public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
	Constructor[] candidates = super.determineCandidateConstructors(beanClass, beanName);
	if (candidates == null) {
		Constructor constructor = checkIfThereIsOnlyOneNonDefaultConstructor(beanClass);
		if (constructor != null) {
		candidates = new Constructor[]{constructor};
		} 
	} 
	return candidates;
	} 
 
	@SuppressWarnings({ "rawtypes" }) 
	private Constructor checkIfThereIsOnlyOneNonDefaultConstructor(Class beanClass) {
	Constructor[] constructors = beanClass.getDeclaredConstructors();
	if (constructors.length == 1) {
		if (constructors[0].getParameterTypes().length > 0) {
5
CodeRank
See Code Examples for Spring Framework AutowiredAnnotationBeanPostProcessor Methods: