Skip to content

Commit

Permalink
Issue OpenLiberty#228: Support all server.env files
Browse files Browse the repository at this point in the history
  • Loading branch information
eharris369 committed Feb 25, 2020
1 parent 24d6c96 commit ce0380d
Showing 1 changed file with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2018 IBM Corporation and others.
* Copyright (c) 2011, 2020 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -63,6 +63,7 @@ public class WebSphereServerInfo implements IMetadataGenerator {
private Bootstrap bootstrap;
private final Map<IPath, JVMOptions> jvmOptionsFiles;
private ServerEnv serverEnv;
private ServerEnv sharedServerEnv;
private ServerEnv etcServerEnv;

private final UserDirectory userDir;
Expand Down Expand Up @@ -345,6 +346,17 @@ private boolean updateServerEnv() {
serverEnv = null;
}

File sharedServerEnvFile = getUserDirectory().getSharedPath().append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
if (sharedServerEnvFile.exists()) {
if (sharedServerEnv == null || sharedServerEnv.hasChanged()) {
changed = true;
sharedServerEnv = new ServerEnv(sharedServerEnvFile, null);
}
} else if (sharedServerEnv != null) {
changed = true;
sharedServerEnv = null;
}

File etcServerEnvFile = runtime.getRuntimeLocation().append(ExtendedConfigFile.ETC_DIR).append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
if (etcServerEnvFile.exists()) {
if (etcServerEnv == null || etcServerEnv.hasChanged()) {
Expand Down Expand Up @@ -437,12 +449,28 @@ private void addServerVars(ConfigVars vars) {
}
}

String wlpOutputDir = System.getenv(Constants.WLP_OUTPUT_DIR);
if (wlpOutputDir != null && !wlpOutputDir.isEmpty()) {
vars.addResolved(Constants.WLP_OUTPUT_DIR, wlpOutputDir, null, null);
}

String wlpUserDir = System.getenv(Constants.WLP_USER_DIR);
if (wlpUserDir != null && !wlpUserDir.isEmpty()) {
vars.addResolved(Constants.WLP_USER_DIR, wlpUserDir, null, null);
}

// Do the env vars from the <runtime install dir>/etc directory first
// since those from the server directory should override.
// since it is the lowest priority server.env file
if (etcServerEnv != null) {
etcServerEnv.getVariables(vars);
}

// Followed by env vars from the <user dir>/shared directory
if (sharedServerEnv != null) {
sharedServerEnv.getVariables(vars);
}

// And finally the env vars from the config dir
if (serverEnv != null) {
serverEnv.getVariables(vars);
}
Expand Down

0 comments on commit ce0380d

Please sign in to comment.