Skip to content

Commit

Permalink
[WFCORE-4917]: Experimental - Provide a cool boot banner.
Browse files Browse the repository at this point in the history
 * Add support for a cool ASCII art banner via a banner.txt in the $JBOSS_HOME/bin directory.

Jira: https://issues.redhat.com/browse/WFCORE-4917
Signed-off-by: Emmanuel Hugonnet <[email protected]>
  • Loading branch information
ehsavoie committed Jan 5, 2024
1 parent 452acf2 commit 1558c29
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<prop name="--internal-remove-config" value=""/>
</props>
<packages>
<package name="banner" optional="true"/>
<package name="product.conf" optional="true"/>
<package name="misc.standalone"/>
<package name="org.jboss.as.standalone"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_ ___ __ __________ ______
| | / (_) /___/ / ____/ /_ __ / ____/___ ________
| | /| / / / / __ / /_ / / / / / / / / __ \/ ___/ _ \
| |/ |/ / / / /_/ / __/ / / /_/ / / /___/ /_/ / / / __/
|__/|__/_/_/\__,_/_/ /_/\__, / \____/\____/_/ \___/
/____/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" ?>

<package-spec xmlns="urn:jboss:galleon:package:2.0" name="banner">
</package-spec>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
~ Copyright The WildFly Authors
~ SPDX-License-Identifier: Apache-2.0
-->

<module xmlns="urn:jboss:module:1.9" name="org.jboss.as.product" slot="wildfly-core">
<module xmlns="urn:jboss:module:1.5" name="org.jboss.as.product" slot="wildfly-core">

<properties>
<property name="jboss.api" value="private"/>
Expand All @@ -16,4 +15,4 @@
</resources>

<dependencies/>
</module>
</module>
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
JBoss-Project-Release-Name: ${product.release.name}
JBoss-Product-Release-Version: ${project.version}
JBoss-Project-Banner: \n
_ ___ __ __________ ______ \n
| | / (_) /___/ / ____/ /_ __ / ____/___ ________ \n
| | /| / / / / __ / /_ / / / / / / / / __ \/ ___/ _ \\n
| |/ |/ / / / /_/ / __/ / / /_/ / / /___/ /_/ / / / __/\n
|__/|__/_/_/\__,_/_/ /_/\__, / \____/\____/_/ \___/ \n
/____/ \n
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public void start(StartContext context) throws StartException {
// processState.setStarting();
final ProductConfig config = environment.getProductConfig();
final String prettyVersion = config.getPrettyVersionString();
ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
final String banner = environment.getStability() == org.jboss.as.version.Stability.EXPERIMENTAL ? config.getBanner() : "";
ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion, banner);
if (System.getSecurityManager() != null) {
ServerLogger.AS_ROOT_LOGGER.securityManagerEnabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public synchronized void start(final StartContext context) throws StartException
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment();
final ProductConfig config = serverEnvironment.getProductConfig();
final String prettyVersion = config.getPrettyVersionString();
ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
final String banner = serverEnvironment.getStability() == org.jboss.as.version.Stability.EXPERIMENTAL ? config.getBanner() : "";
ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion, banner);
if (System.getSecurityManager() != null) {
ServerLogger.AS_ROOT_LOGGER.securityManagerEnabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,11 @@ public interface ServerLogger extends BasicLogger {
* Logs an informational message indicating the server is starting.
*
* @param prettyVersion the server version.
* @param banner the server ACII banner.
*/
@LogMessage(level = INFO)
@Message(id = 49, value = "%s starting")
void serverStarting(String prettyVersion);
@Message(id = 49, value = "%s starting%s")
void serverStarting(String prettyVersion, String banner);

/**
* Logs an informational message indicating the server is stopped.
Expand Down
1 change: 1 addition & 0 deletions testsuite/domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
</excluded-configs>
<excluded-packages>
<name>product.conf</name>
<name>banner</name>
</excluded-packages>
</feature-pack>
</feature-packs>
Expand Down
3 changes: 3 additions & 0 deletions testsuite/manualmode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<version>${project.version}</version>
<excluded-packages>
<param>product.conf</param>
<name>banner</name>
</excluded-packages>
</feature-pack>
</feature-packs>
Expand Down Expand Up @@ -442,6 +443,7 @@
</included-packages>
<excluded-packages>
<name>product.conf</name>
<name>banner</name>
</excluded-packages>
</feature-pack>
</feature-packs>
Expand Down Expand Up @@ -543,6 +545,7 @@
</included-packages>
<excluded-packages>
<name>product.conf</name>
<name>banner</name>
</excluded-packages>
</feature-pack>
</feature-packs>
Expand Down
3 changes: 3 additions & 0 deletions testsuite/rbac/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
</config>
</included-configs>
<excludedPackages>
<name>banner</name>
<param>product.conf</param>
</excludedPackages>
</feature-pack>
Expand Down Expand Up @@ -332,6 +333,7 @@
<name>org.jboss.as.patching.cli</name>
</included-packages>
<excluded-packages>
<name>banner</name>
<name>product.conf</name>
</excluded-packages>
</feature-pack>
Expand Down Expand Up @@ -456,6 +458,7 @@
<name>org.jboss.as.patching.cli</name>
</included-packages>
<excluded-packages>
<name>banner</name>
<name>product.conf</name>
</excluded-packages>
</feature-pack>
Expand Down
3 changes: 3 additions & 0 deletions testsuite/standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
</config>
</included-configs>
<excluded-packages>
<name>banner</name>
<name>product.conf</name>
</excluded-packages>
</feature-pack>
Expand Down Expand Up @@ -307,6 +308,7 @@
<name>org.jboss.as.patching.cli</name>
</included-packages>
<excluded-packages>
<name>banner</name>
<name>product.conf</name>
</excluded-packages>
</feature-pack>
Expand Down Expand Up @@ -407,6 +409,7 @@
<name>org.jboss.as.patching.cli</name>
</included-packages>
<excluded-packages>
<name>banner</name>
<name>product.conf</name>
</excluded-packages>
</feature-pack>
Expand Down
36 changes: 32 additions & 4 deletions version/src/main/java/org/jboss/as/version/ProductConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
Expand All @@ -34,21 +35,23 @@ public class ProductConfig implements Serializable {

private final String name;
private final String version;
private final String banner;
private final String consoleSlot;
private final Stability defaultStability;
private final Set<Stability> stabilities;
private boolean isProduct;

public static ProductConfig fromFilesystemSlot(ModuleLoader loader, String home, Map<?, ?> providedProperties) {
return new ProductConfig(loader, getProductConfProperties(home), providedProperties);
return new ProductConfig(loader, home, getProductConfProperties(home), providedProperties);
}

public static ProductConfig fromKnownSlot(String slot, ModuleLoader loader, Map<?, ?> providedProperties) {
return new ProductConfig(loader, new ProductConfProps(slot), providedProperties);
return new ProductConfig(loader, null, new ProductConfProps(slot), providedProperties);
}
private ProductConfig(ModuleLoader loader, ProductConfProps productConfProps, Map<?, ?> providedProperties) {
private ProductConfig(ModuleLoader loader, String home, ProductConfProps productConfProps, Map<?, ?> providedProperties) {
String productName = null;
String projectName = null;
String projectBanner = "";
String productVersion = null;
String consoleSlot = null;
Stability defaultStability = Stability.COMMUNITY;
Expand Down Expand Up @@ -81,10 +84,18 @@ private ProductConfig(ModuleLoader loader, ProductConfProps productConfProps, Ma
minStability = Stability.fromString(minStabilityValue);
}
}
Path bannerPath = getBannerFile(home);
if (bannerPath != null && Files.exists(bannerPath)) {
try {
projectBanner = System.lineSeparator() + Files.readString(bannerPath);
} catch (Exception e) {
// Don't care
}
}
}

setSystemProperties(productConfProps.miscProperties, providedProperties);
} catch (Exception e) {
e.printStackTrace();
// Don't care
} finally {
safeClose(manifestStream);
Expand All @@ -95,6 +106,14 @@ private ProductConfig(ModuleLoader loader, ProductConfProps productConfProps, Ma
this.consoleSlot = consoleSlot;
this.defaultStability = defaultStability;
this.stabilities = EnumSet.range(maxStability, minStability);
this.banner = projectBanner;
}

private static Path getBannerFile(String home) {
if (home != null) {
return Paths.get(home, "bin", "banner.txt");
}
return null;
}

private static String getProductConf(String home) {
Expand Down Expand Up @@ -133,6 +152,7 @@ public ProductConfig(final String productName, final String productVersion, fina
this.consoleSlot = consoleSlot;
this.defaultStability = Stability.DEFAULT;
this.stabilities = EnumSet.of(this.defaultStability);
this.banner = null;
}

public String getProductName() {
Expand Down Expand Up @@ -167,6 +187,14 @@ public Set<Stability> getStabilitySet() {
return this.stabilities;
}

/**
* The product ASCII banner defined in MANIFEST.MF using \n as line ending.
* @return the ASCII banner.
*/
public String getBanner() {
return banner;
}

public String getPrettyVersionString() {
if (name != null) {
return String.format("%s %s (WildFly Core %s)", name, version, Version.AS_VERSION);
Expand Down

0 comments on commit 1558c29

Please sign in to comment.