private boolean _detect(String className) {
try {
ClassLoader systemClassLoader =
ClassLoader.getSystemClassLoader();
systemClassLoader.loadClass(className);
return true;
}
catch (ClassNotFoundException cnfe) {
Class<?> classObj = getClass();
if (classObj.getResource(className) != null) {
return true;
}
else {
return false;
}
}
}
private boolean _isGeronimo() {
return _detect(
"/org/apache/geronimo/system/main/Daemon.class");
}
private boolean _isGlassfish() {
String value = System.getProperty("com.sun.aas.instanceRoot");
if (value != null) {
return true;
}
else {
return false;
}
}
private boolean _isJBoss() {
return _detect("/org/jboss/Main.class");
}
private boolean _isTomcat() {
boolean tomcat = _detect(
"/org/apache/catalina/startup/Bootstrap.class");
if (!tomcat) {
tomcat = _detect("/org/apache/catalina/startup/Embedded.class");
}
return tomcat;
}
private boolean _isWebLogic() {
return _detect("/weblogic/Server.class");
}
private boolean _isWebSphere() {
return _detect(
"/com/ibm/websphere/product/VersionInfo.class");
}
判断应用服务器是jboss或tomcat等
最新推荐文章于 2021-09-22 14:36:13 发布