Example usage for org.springframework.boot.context.event ApplicationStartedEvent getSpringApplication

List of usage examples for org.springframework.boot.context.event ApplicationStartedEvent getSpringApplication

Introduction

In this page you can find the example usage for org.springframework.boot.context.event ApplicationStartedEvent getSpringApplication.

Prototype

public SpringApplication getSpringApplication() 

Source Link

Usage

From source file:org.wallride.autoconfigure.WallRideInitializer.java

public static ConfigurableEnvironment createEnvironment(ApplicationStartedEvent event) {
    StandardEnvironment environment = new StandardEnvironment();

    String home = environment.getProperty(WallRideProperties.HOME_PROPERTY);
    if (!StringUtils.hasText(home)) {
        throw new IllegalStateException(WallRideProperties.HOME_PROPERTY + " is empty");
    }//www. jav  a 2s .co  m
    if (!home.endsWith("/")) {
        home = home + "/";
    }

    String config = home + WallRideProperties.DEFAULT_CONFIG_PATH_NAME;
    String media = home + WallRideProperties.DEFAULT_MEDIA_PATH_NAME;

    System.setProperty(WallRideProperties.CONFIG_LOCATION_PROPERTY, config);
    System.setProperty(WallRideProperties.MEDIA_LOCATION_PROPERTY, media);

    event.getSpringApplication().getListeners().stream()
            .filter(listener -> listener.getClass().isAssignableFrom(ConfigFileApplicationListener.class))
            .map(listener -> (ConfigFileApplicationListener) listener)
            .forEach(listener -> listener.setSearchLocations(DEFAULT_CONFIG_SEARCH_LOCATIONS + "," + config));

    return environment;
}

From source file:org.wallride.autoconfigure.WallRideInitializer.java

@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
    event.getSpringApplication().setEnvironment(createEnvironment(event));
    event.getSpringApplication().setResourceLoader(createResourceLoader());
}

From source file:org.springframework.boot.logging.LoggingApplicationListener.java

private void onApplicationStartedEvent(ApplicationStartedEvent event) {
    this.loggingSystem = LoggingSystem.get(event.getSpringApplication().getClassLoader());
    this.loggingSystem.beforeInitialize();
}