Example usage for org.springframework.context.support AbstractApplicationContext addBeanFactoryPostProcessor

List of usage examples for org.springframework.context.support AbstractApplicationContext addBeanFactoryPostProcessor

Introduction

In this page you can find the example usage for org.springframework.context.support AbstractApplicationContext addBeanFactoryPostProcessor.

Prototype

@Override
    public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor) 

Source Link

Usage

From source file:org.rivetlogic.utils.IntegrationUtils.java

public static BeanFactory getBeanFactory() throws IOException {
    if (beanFactory == null) {
        synchronized (beanFactoryLockObj) {
            if (beanFactory == null) {
                PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
                AbstractApplicationContext context = new ClassPathXmlApplicationContext(
                        "application-context.xml");

                Resource resource = new FileSystemResource("cma-cfg.properties");
                Properties properties = new Properties();
                properties.load(resource.getInputStream());

                configurer.setProperties(properties);

                context.addBeanFactoryPostProcessor(configurer);
                context.refresh();/*from   ww  w  .  jav  a2s .co m*/

                beanFactory = context.getBeanFactory();
            }
        }
    }

    return beanFactory;
}

From source file:org.rivetlogic.export.components.XmlExtractRequestProcessor.java

private void initializeCMSCreds(Ticket ticketParam)
        throws IOException, AuthenticationFailure, CmaRuntimeException {

    // set up the bean factory
    if (beanFactory == null) {
        PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
        AbstractApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml");

        Resource resource = context.getResource("classpath:core/cma-cfg.properties");
        Properties properties = new Properties();
        properties.load(resource.getInputStream());

        configurer.setProperties(properties);

        context.addBeanFactoryPostProcessor(configurer);
        context.refresh();/*from   w w w. j  av  a2 s  .  com*/

        beanFactory = context.getBeanFactory();
        authService = (AuthenticationService) beanFactory.getBean("authenticationService",
                AuthenticationServiceImpl.class);
    }

    // get a ticket
    if (this.ticket == null) {

        if (ticketParam != null) {
            this.ticket = ticketParam;

        } else {
            this.ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray());
        }
    }

    try {
        authService.validate(ticket);
    } catch (InvalidTicketException e) {
        log.debug("ticket invalid, getting a new one.");
        ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray());
    }
}

From source file:org.rivetlogic.export.components.AbstractXMLProcessor.java

private void initialize() throws AuthenticationFailure, CmaRuntimeException, IOException {

    if (ticket == null) {
        if (beanFactory == null) {
            PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
            AbstractApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml");

            Resource resource = context.getResource("classpath:core/cma-cfg.properties");
            Properties properties = new Properties();
            properties.load(resource.getInputStream());

            configurer.setProperties(properties);

            context.addBeanFactoryPostProcessor(configurer);
            context.refresh();//w  ww  .ja v a  2s.  com

            beanFactory = context.getBeanFactory();
        }

        authService = (AuthenticationService) beanFactory.getBean("authenticationService",
                AuthenticationServiceImpl.class);

        ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray());
        nodeService = (NodeService) beanFactory.getBean("nodeService", NodeServiceImpl.class);
        searchService = (SearchService) beanFactory.getBean("searchService", SearchServiceImpl.class);

        contentService = (ContentServiceImpl) beanFactory.getBean("contentService", ContentServiceImpl.class);
    }

    try {
        authService.validate(ticket);
    } catch (InvalidTicketException e) {
        logger.debug("ticket invalid, getting a new one.");
        ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray());
    }
}