Example usage for org.springframework.core.env StandardEnvironment getProperty

List of usage examples for org.springframework.core.env StandardEnvironment getProperty

Introduction

In this page you can find the example usage for org.springframework.core.env StandardEnvironment getProperty.

Prototype

@Override
    @Nullable
    public String getProperty(String key) 

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");
    }/*ww w. j av  a  2  s.  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;
}