Example usage for org.springframework.boot Banner printBanner

List of usage examples for org.springframework.boot Banner printBanner

Introduction

In this page you can find the example usage for org.springframework.boot Banner printBanner.

Prototype

void printBanner(Environment environment, Class<?> sourceClass, PrintStream out);

Source Link

Document

Print the banner to the specified print stream.

Usage

From source file:org.springframework.boot.SpringApplication.java

/**
 * Print a custom banner message to the console, optionally extracting its location or
 * content from the Environment (banner.location and banner.charset). The defaults are
 * banner.location=classpath:banner.txt, banner.charset=UTF-8. If the banner file does
 * not exist or cannot be printed, a simple default is created.
 * @param environment the environment//from ww w.j a  va2 s  . co m
 * @see #setBannerMode
 */
protected void printBanner(Environment environment) {

    Banner selectedBanner = selectBanner(environment);

    if (this.bannerMode == Banner.Mode.LOG) {
        try {
            this.log.info(createStringFromBanner(selectedBanner, environment));
        } catch (UnsupportedEncodingException ex) {
            this.log.warn("Failed to create String for banner", ex);
        }
    } else {
        selectedBanner.printBanner(environment, this.mainApplicationClass, System.out);
    }
}

From source file:org.springframework.boot.SpringApplication.java

private String createStringFromBanner(Banner banner, Environment environment)
        throws UnsupportedEncodingException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    banner.printBanner(environment, this.mainApplicationClass, new PrintStream(baos));
    String charset = environment.getProperty("banner.charset", "UTF-8");
    return baos.toString(charset);
}

From source file:org.springframework.boot.SpringApplicationBannerPrinter.java

public Banner print(Environment environment, Class<?> sourceClass, PrintStream out) {
    Banner banner = getBanner(environment, this.fallbackBanner);
    banner.printBanner(environment, sourceClass, out);
    return new PrintedBanner(banner, sourceClass);
}

From source file:org.springframework.boot.SpringApplicationBannerPrinter.java

private String createStringFromBanner(Banner banner, Environment environment, Class<?> mainApplicationClass)
        throws UnsupportedEncodingException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    banner.printBanner(environment, mainApplicationClass, new PrintStream(baos));
    String charset = environment.getProperty("banner.charset", "UTF-8");
    return baos.toString(charset);
}