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

FISH-10055 Introduce Payara Micro Global Context Root Support #7187

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2021] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2025] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.web;

Expand Down Expand Up @@ -136,6 +136,16 @@ public <V> V loadMetaData(Class<V> type, DeploymentContext dc) {
if (contextRoot == null)
contextRoot = ((GenericHandler)dc.getArchiveHandler()).getDefaultApplicationNameFromArchiveName(dc.getOriginalSource());


if (this.env.getRuntimeType().isMicro()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I see this kind of code more and more sprinkled throughout the codebase.
This is a code smell. There should be a strategy pattern utilized here to get more cohesion / convergence of code that belongs in Micro / Server / DAS / instance

String globalContextRoot = getProperty("payaramicro.globalContextRoot");
if (globalContextRoot != null && !globalContextRoot.isBlank()) {
globalContextRoot = removeSlashes(globalContextRoot);
contextRoot = removeSlashes(contextRoot);

contextRoot = "/" + globalContextRoot + "/" + contextRoot;
}
}
if (!contextRoot.startsWith("/")) {
contextRoot = "/" + contextRoot;
}
Expand Down Expand Up @@ -239,4 +249,18 @@ void runJSPC(final DeploymentContext dc) throws DeploymentException {
throw de;
}
}

private String getProperty(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use TranslateConfigView?

String result;
result = System.getProperty(value);
if (result == null) {
result = System.getenv(value.replace('.', '_'));
}
return result;
}

private String removeSlashes(String value) {
return value.replaceAll("^/|/$", "");
}

}