From 9a78b1fe20741c72c4e491d2f1b0b2339826c05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rene=CC=81=20Bock?= Date: Mon, 28 Jun 2021 11:06:59 +0200 Subject: [PATCH 1/2] ERXConfigurationManager isDeployedAsServlet relies now on the configured WOContext class rather on a check, if the JavaWOJSPServlet framework is loaded --- .../foundation/ERXConfigurationManager.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java index ee6ecf31826..1003e61d071 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import com.webobjects.appserver.WOApplication; +import com.webobjects.appserver._private.WOProperties; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSBundle; import com.webobjects.foundation.NSDictionary; @@ -391,16 +392,31 @@ public String hostName() { } /** - * Checks if the application is may be deployed as a servlet. - *

- * The current implementation only checks if the application - * is linked against JavaWOJSPServlet.framework. + * Checks if the application is be deployed as a servlet. * + * This heuristic to determine if an application is deployed as servlet relays on the fact, + * that contextClassName() is set WOServletContext or ERXWOServletContext + * * @return true if the application is deployed as a servlet */ public boolean isDeployedAsServlet() { - NSArray frameworkNames = (NSArray)NSBundle.frameworkBundles().valueForKey("name"); - return frameworkNames.containsObject("JavaWOJSPServlet"); + return contextClassName().contains("Servlet"); // i.e one of WOServletContext or ERXWOServletContext } - + + public void setContextClassName(String name) { + if (name != null) { + WOProperties.TheContextClassName = name; + } + + } + + public String contextClassName() { + if (WOProperties.TheContextClassName == null) { + String contextClassName = NSProperties.getProperty(WOProperties._ContextClassNameKey); + this.setContextClassName(contextClassName); + } + + return WOProperties.TheContextClassName; + } + } From d31dab704f580a5628581e35e50f48ed0d9d242c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rene=CC=81=20Bock?= Date: Thu, 21 Oct 2021 17:56:15 +0200 Subject: [PATCH 2/2] Fix NPE as isDeployedAsServlet() is called the first time before the properties are already loaded --- .../er/extensions/foundation/ERXConfigurationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java index 1003e61d071..936c2bf22e3 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXConfigurationManager.java @@ -400,7 +400,7 @@ public String hostName() { * @return true if the application is deployed as a servlet */ public boolean isDeployedAsServlet() { - return contextClassName().contains("Servlet"); // i.e one of WOServletContext or ERXWOServletContext + return contextClassName()!= null && contextClassName().contains("Servlet"); // i.e one of WOServletContext or ERXWOServletContext } public void setContextClassName(String name) {