Example usage for org.springframework.context ConfigurableApplicationContext getStartupDate

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

Introduction

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

Prototype

long getStartupDate();

Source Link

Document

Return the timestamp when this context was first loaded.

Usage

From source file:guru.qas.martini.jmeter.config.MartiniSpringConfiguration.java

@Override
public void testStarted() {
    synchronized (contextRef) {
        ConfigurableApplicationContext context = initializeContext();
        ConfigurableApplicationContext previous = contextRef.getAndSet(context);
        if (null != previous) {
            previous.close();//w ww .  j a va 2 s . c o  m
        }

        String hostname = JMeterUtils.getLocalHostName();
        String ip = JMeterUtils.getLocalHostIP();
        String name = super.getName();
        String id = context.getId();
        long startupDate = context.getStartupDate();
        String username = System.getProperty("user.name");

        ConfigurableEnvironment environment = context.getEnvironment();
        String[] activeProfiles = environment.getActiveProfiles();
        ArrayList<String> profiles = Lists.newArrayList(activeProfiles);

        Map<String, String> environmentVariables = this.getEnvironmentProperties().getArgumentsAsMap();

        SuiteIdentifier identifier = DefaultSuiteIdentifier.builder().setId(id).setStartupTimestamp(startupDate)
                .setName(name).setHostname(hostname).setHostAddress(ip).setUsername(username)
                .setProfiles(profiles).setEnvironmentVariables(environmentVariables).build();

        ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        beanFactory.registerSingleton(BEAN_SUITE_IDENTIFIER, identifier);

        EventManager eventManager = context.getBean(EventManager.class);
        eventManager.publishBeforeSuite(this, identifier);
    }
}