Code example for XmlBeanFactory

Methods: getBeansOfType

0
		{ 
			return; 
		} 
		 
		ClassPathResource res = new ClassPathResource("applicationContext.xml");
		beanFactory = new XmlBeanFactory(res);
	} 
	 
	/** 
	 * Retrieve a Spring bean based on the class that it implements. Where multiple  
	 * beans implement a class, the first will be returned.  
	 *  
	 * @param cl The type of bean to be retrieved. 
	 * @return The bean, or null if none exists. 
	 */ 
	public static <T extends Object> T getBean(Class<T> cl)
	{ 
		if (beanFactory == null)
		{ 
			initSpring(); 
		} 
 
		String[] beanNamesForType = beanFactory.getBeanNamesForType(cl);
		if (beanNamesForType.length ==0) 
		{ 
			return null; 
		} 
		return beanFactory.getBean (beanNamesForType[0], cl);
	} 
	 
	public static Collection<AbstractStorageFacet> getStorageBeans()
	{ 
		if (beanFactory == null)
		{ 
			initSpring(); 
		} 
 
		return beanFactory.getBeansOfType(AbstractStorageFacet.class).values();
	} 
}