List of usage examples for org.springframework.beans.factory.config AutowireCapableBeanFactory containsBean
boolean containsBean(String name);
From source file:org.molasdin.wbase.jsf.spring.web.SpringBeansRewireListener.java
@Override public void sessionDidActivate(HttpSessionEvent httpSessionEvent) { HttpSession session = httpSessionEvent.getSession(); WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(session.getServletContext()); AutowireCapableBeanFactory bf = ctx.getAutowireCapableBeanFactory(); for (String entry : IteratorUtils.asIterable(IteratorUtils.asIterator(session.getAttributeNames()))) { if (bf.containsBean(entry)) { Object bean = session.getAttribute(entry); bean = bf.configureBean(bean, entry); session.setAttribute(entry, bean); }/* w w w. j ava2s . c o m*/ } }
From source file:org.echocat.jomon.spring.BeanProvider.java
@Nonnull @Override// w w w .ja va 2s . c om public <T> T provideFor(@Nonnull String name, @Nonnull Class<T> clazz, @Nonnull Type type) { final T result; final AutowireCapableBeanFactory beanFactory = getBeanFactory(); if (beanFactory.containsBean(name)) { validateTypeAgainstBeanConfiguration(name, type); result = beanFactory.getBean(name, clazz); } else if (isCreateLocaleBeansIfNotPresentInApplicationContext()) { result = type == singleton ? getLocalCreatedAndConfiguredSingleton(name, clazz) : createInstanceAndConfigure(name, clazz); } else { throw new IllegalArgumentException("No such bean named '" + name + "' found."); } return result; }