Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOMEE-4014 - Re-add "tomee.keep-server-info" #993

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,28 @@ public class ServerInfo {
number = "9.0.x";
}

// TOMEE-4014 - PATCH START
try {
final int slash = info.indexOf('/');
Class<?> versionClass = Class.forName("org.apache.openejb.util.OpenEjbVersion");
Object instance = versionClass.getDeclaredMethod("get").invoke(null);
final String tomeeVersion = (String) versionClass.getDeclaredMethod("getVersion").invoke(instance);
final Class<?> systemInstanceClass = Class.forName("org.apache.openejb.loader.SystemInstance");
final Class<?> optionsClass = Class.forName("org.apache.openejb.loader.Options");
final Object systemInstance = systemInstanceClass.getDeclaredMethod("get").invoke(null);
final Object optionsInstance = systemInstanceClass.getDeclaredMethod("getOptions").invoke(systemInstance);

info = info.substring(0, slash) + " (TomEE)" + info.substring(slash) + " (" + tomeeVersion + ")";
final boolean keepServerInfo = (boolean) optionsClass.getDeclaredMethod("get", String.class, boolean.class).invoke(optionsInstance, "tomee.keep-server-info", false);

if (!keepServerInfo) {
final int slash = info.indexOf('/');
final Class<?> versionClass = Class.forName("org.apache.openejb.util.OpenEjbVersion");
final Object instance = versionClass.getDeclaredMethod("get").invoke(null);
final String tomeeVersion = (String) versionClass.getDeclaredMethod("getVersion").invoke(instance);

info = info.substring(0, slash) + " (TomEE)" + info.substring(slash) + " (" + tomeeVersion + ")";
}
} catch (Throwable t) {
// ignore
t.printStackTrace();
}
// TOMEE-4041 - PATCH END

serverInfo = info;
serverBuilt = built;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.util.ServerInfo;
import org.apache.openejb.classloader.ClassLoaderConfigurer;
import org.apache.openejb.config.QuickJarsTxtParser;
import org.apache.openejb.loader.IO;
import org.apache.openejb.loader.ProvisioningUtil;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.util.OpenEjbVersion;
import org.apache.tomee.loader.TomcatHelper;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
Expand All @@ -48,7 +44,6 @@
import static java.util.Arrays.asList;

// this listener is the real tomee one (the OpenEJBListener is more tomcat oriented)
// so it even changes the server info
public class ServerListener implements LifecycleListener {
private static final Logger LOGGER = Logger.getLogger(ServerListener.class.getName());

Expand Down