Example usage for org.springframework.context.support GenericXmlApplicationContext getBean

List of usage examples for org.springframework.context.support GenericXmlApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.context.support GenericXmlApplicationContext getBean.

Prototype

@Override
    public Object getBean(String name) throws BeansException 

Source Link

Usage

From source file:org.objectrepository.MessageConsumerDaemon.java

public void init() {

    log.info("Startup service...");
    GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    context.setValidating(false);/*from   w w  w  .  j  a v  a2s  .  co m*/
    context.load("/META-INF/spring/application-context.xml", "META-INF/spring/dispatcher-servlet.xml");
    context.refresh();
    setContext(context);
    context.registerShutdownHook();

    final RejectedExecutionHandler rejectedExecutionHandler = context.getBean(RejectedExecutionHandler.class);
    for (Queue taskExecutor : taskExecutors) {
        taskExecutor.setRejectedExecutionHandler(rejectedExecutionHandler);
        taskExecutor.initialize();
        log.info("Initialized " + taskExecutor.getQueueName());
    }
}