Example usage for org.springframework.context.support AbstractRefreshableConfigApplicationContext registerShutdownHook

List of usage examples for org.springframework.context.support AbstractRefreshableConfigApplicationContext registerShutdownHook

Introduction

In this page you can find the example usage for org.springframework.context.support AbstractRefreshableConfigApplicationContext registerShutdownHook.

Prototype

@Override
public void registerShutdownHook() 

Source Link

Document

Register a shutdown hook with the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time.

Usage

From source file:pl.altkom.spring.sample.Main.java

public static void main(String[] args) {

    System.out.println("!!!!!");

    AbstractRefreshableConfigApplicationContext ctx = new ClassPathXmlApplicationContext("spring-context.xml");

    ctx.registerShutdownHook();

    NewsletterService newsletterService = ctx.getBean("newsletterServiceImpl", NewsletterService.class);
    newsletterService.send("tre", "temat");

    //ctx.close();

}