use of org.apache.catalina.util.ServerInfo in project tomee by apache.
the class ServerListener method installServerInfo.
private synchronized void installServerInfo() {
if (SystemInstance.get().getOptions().get("tomee.keep-server-info", false)) {
return;
}
// force static init
final String value = ServerInfo.getServerInfo();
Field field = null;
boolean acc = true;
try {
field = ServerInfo.class.getDeclaredField("serverInfo");
acc = field.isAccessible();
final int slash = value.indexOf('/');
field.setAccessible(true);
final String tomeeVersion = OpenEjbVersion.get().getVersion();
final int modifiers = field.getModifiers();
if (Modifier.isFinal(modifiers)) {
// this is a bit fragile, we can surely drop this feature at some point
final Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, modifiers & ~Modifier.FINAL);
}
field.set(null, value.substring(0, slash) + " (TomEE)" + value.substring(slash) + " (" + tomeeVersion + ")");
} catch (final Exception e) {
// no-op
} finally {
if (field != null) {
field.setAccessible(acc);
}
}
}
Aggregations