Example usage for org.springframework.context ApplicationContext getStartupDate

List of usage examples for org.springframework.context ApplicationContext getStartupDate

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContext getStartupDate.

Prototype

long getStartupDate();

Source Link

Document

Return the timestamp when this context was first loaded.

Usage

From source file:org.another.logserver.Starter.java

/**
 *
 * @param args/* w  w w.  jav a  2 s .  c om*/
 */
public static void main(String[] args) {

    LOGGER.info("Starting Another Log server ...");

    // Initialize components

    LOGGER.debug("Starting Spring context ...");
    final ApplicationContext springContext = new ClassPathXmlApplicationContext("spring.xml");

    LOGGER.info("Spring intilization: {}", springContext.getStartupDate());

    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            super.run();
            LOGGER.debug("Running Shutdown Hook");

            Configurator conf = springContext.getBean("configurator", Configurator.class);
            for (IEndPoint ep : conf.getConfiguredEndPoints().values()) {
                ep.stop();
            }

        }

    });

    ((AbstractApplicationContext) springContext).registerShutdownHook();

    LOGGER.debug("Entering wait loop");
    try {
        while (true) {
            Thread.sleep(1000 * 60 * 60);
        }
    } catch (Exception e) {
        LOGGER.error("", e);
    }

}

From source file:cn.edu.zjnu.acm.judge.config.StartUpConfiguration.java

@Autowired
public void setStartUpDate(ServletContext servlet, ApplicationContext application) {
    servlet.setAttribute("startUpDate", application.getStartupDate());
    log.debug("{}: {}", ServletContext.TEMPDIR, servlet.getAttribute(ServletContext.TEMPDIR));
}

From source file:org.apache.cocoon.servletservice.DispatcherServlet.java

public Map getBlockServletMap() {
    ApplicationContext applicationContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(getServletContext());
    if (this.blockServletCollector == null
            || applicationContext.getStartupDate() != this.applicationContextStartDate) {
        this.applicationContextStartDate = applicationContext.getStartupDate();
        this.blockServletCollector = (Map) applicationContext
                .getBean("org.apache.cocoon.servletservice.spring.BlockServletMap");
    }//from w ww .j  a  va 2  s.co m
    return blockServletCollector;
}