Example usage for org.springframework.beans.factory.config AutowireCapableBeanFactory configureBean

List of usage examples for org.springframework.beans.factory.config AutowireCapableBeanFactory configureBean

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config AutowireCapableBeanFactory configureBean.

Prototype

Object configureBean(Object existingBean, String beanName) throws BeansException;

Source Link

Document

Configure the given raw bean: autowiring bean properties, applying bean property values, applying factory callbacks such as setBeanName and setBeanFactory , and also applying all bean post processors (including ones which might wrap the given raw bean).

Usage

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);
        }//from   w w w  .  ja  va  2 s. co m
    }

}