Simple utility module to make it easy to plug in the server identifier when integrating Tomcat.
| 32 | * Simple utility module to make it easy to plug in the server identifier when integrating Tomcat. |
| 33 | */ |
| 34 | public class ServerInfo { |
| 35 | |
| 36 | /** |
| 37 | * Default constructor. |
| 38 | */ |
| 39 | public ServerInfo() { |
| 40 | } |
| 41 | |
| 42 | |
| 43 | // ------------------------------------------------------- Static Variables |
| 44 | |
| 45 | |
| 46 | /** |
| 47 | * The server information String with which we identify ourselves. |
| 48 | */ |
| 49 | private static final String serverInfo; |
| 50 | |
| 51 | /** |
| 52 | * The server built String. |
| 53 | */ |
| 54 | private static final String serverBuilt; |
| 55 | |
| 56 | /** |
| 57 | * The server built String, in ISO-8604 date format. |
| 58 | */ |
| 59 | private static final String serverBuiltIso; |
| 60 | |
| 61 | /** |
| 62 | * The server's version number String. |
| 63 | */ |
| 64 | private static final String serverNumber; |
| 65 | |
| 66 | static { |
| 67 | |
| 68 | String info = null; |
| 69 | String built = null; |
| 70 | String builtIso = null; |
| 71 | String number = null; |
| 72 | |
| 73 | Properties props = new Properties(); |
| 74 | try (InputStream is = ServerInfo.class.getResourceAsStream("/org/apache/catalina/util/ServerInfo.properties")) { |
| 75 | props.load(is); |
| 76 | info = props.getProperty("server.info"); |
| 77 | built = props.getProperty("server.built"); |
| 78 | builtIso = props.getProperty("server.built.iso"); |
| 79 | number = props.getProperty("server.number"); |
| 80 | } catch (Throwable t) { |
| 81 | ExceptionUtils.handleThrowable(t); |
| 82 | } |
| 83 | if (info == null || info.equals("Apache Tomcat/@VERSION@")) { |
| 84 | info = "Apache Tomcat/11.0.x-dev"; |
| 85 | } |
| 86 | if (built == null || built.equals("@VERSION_BUILT@")) { |
| 87 | built = "unknown"; |
| 88 | } |
| 89 | if (builtIso == null || builtIso.equals("@VERSION_BUILT_ISO@")) { |
| 90 | builtIso = "unknown"; |
| 91 | } |
nothing calls this directly
no test coverage detected