Example usage for org.springframework.web.context ConfigurableWebApplicationContext addBeanFactoryPostProcessor

List of usage examples for org.springframework.web.context ConfigurableWebApplicationContext addBeanFactoryPostProcessor

Introduction

In this page you can find the example usage for org.springframework.web.context ConfigurableWebApplicationContext addBeanFactoryPostProcessor.

Prototype

void addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor);

Source Link

Document

Add a new BeanFactoryPostProcessor that will get applied to the internal bean factory of this application context on refresh, before any of the bean definitions get evaluated.

Usage

From source file:no.dusken.aranea.spring.AraneaContextLoaderListener.java

public void addDeveloperModeReplacer(ConfigurableWebApplicationContext wac) {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    final Properties properties = new Properties();
    properties.setProperty("developerMode", Boolean.toString(System.getProperty("developerMode") != null));
    configurer.setProperties(properties);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    wac.addBeanFactoryPostProcessor(configurer);
}

From source file:no.kantega.publishing.spring.OpenAksessContextLoaderListener.java

private void addConfigurationPropertyReplacer(ConfigurableWebApplicationContext wac,
        final Properties properties) {
    wac.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
            PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
            cfg.setProperties(properties);
            cfg.postProcessBeanFactory(beanFactory);
        }//w ww.  ja v  a 2s .c  o m
    });
}

From source file:no.kantega.publishing.spring.OpenAksessContextLoaderListener.java

private void addConfigurationAndLoaderAsSingletonsInContext(ConfigurableWebApplicationContext wac,
        final Configuration configuration, final ConfigurationLoader loader) {
    wac.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
            beanFactory.registerSingleton("aksessConfiguration", configuration);
            beanFactory.registerSingleton("aksessConfigurationLoader", loader);

        }//w w w.j ava2  s  . c  om
    });
}

From source file:org.springframework.web.struts.ContextLoaderPlugIn.java

/**
 * Instantiate the WebApplicationContext for the ActionServlet, either a default
 * XmlWebApplicationContext or a custom context class if set. This implementation
 * expects custom contexts to implement ConfigurableWebApplicationContext.
 * Can be overridden in subclasses./*from  ww  w  . j  ava2 s .c  o  m*/
 * @throws org.springframework.beans.BeansException if the context couldn't be initialized
 * @see #setContextClass
 * @see org.springframework.web.context.support.XmlWebApplicationContext
 */
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent)
        throws BeansException {

    if (logger.isDebugEnabled()) {
        logger.debug("ContextLoaderPlugIn for Struts ActionServlet '" + getServletName() + "', module '"
                + getModulePrefix() + "' will try to create custom WebApplicationContext "
                + "context of class '" + getContextClass().getName() + "', using parent context [" + parent
                + "]");
    }
    if (!ConfigurableWebApplicationContext.class.isAssignableFrom(getContextClass())) {
        throw new ApplicationContextException(
                "Fatal initialization error in ContextLoaderPlugIn for Struts ActionServlet '"
                        + getServletName() + "', module '" + getModulePrefix()
                        + "': custom WebApplicationContext class [" + getContextClass().getName()
                        + "] is not of type ConfigurableWebApplicationContext");
    }

    ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils
            .instantiateClass(getContextClass());
    wac.setParent(parent);
    wac.setServletContext(getServletContext());
    wac.setNamespace(getNamespace());
    if (getContextConfigLocation() != null) {
        wac.setConfigLocations(StringUtils.tokenizeToStringArray(getContextConfigLocation(),
                ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS));
    }
    wac.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
            beanFactory.addBeanPostProcessor(new ActionServletAwareProcessor(getActionServlet()));
        }
    });
    wac.refresh();
    return wac;
}