|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2011, 2018 IBM Corporation and others. |
| 2 | + * Copyright (c) 2011, 2020 IBM Corporation and others. |
3 | 3 | * All rights reserved. This program and the accompanying materials
|
4 | 4 | * are made available under the terms of the Eclipse Public License v1.0
|
5 | 5 | * which accompanies this distribution, and is available at
|
@@ -63,6 +63,7 @@ public class WebSphereServerInfo implements IMetadataGenerator {
|
63 | 63 | private Bootstrap bootstrap;
|
64 | 64 | private final Map<IPath, JVMOptions> jvmOptionsFiles;
|
65 | 65 | private ServerEnv serverEnv;
|
| 66 | + private ServerEnv sharedServerEnv; |
66 | 67 | private ServerEnv etcServerEnv;
|
67 | 68 |
|
68 | 69 | private final UserDirectory userDir;
|
@@ -114,12 +115,15 @@ public IPath getServerAppsPath() {
|
114 | 115 | public IPath getServerOutputPath() {
|
115 | 116 | if (serverName == null)
|
116 | 117 | return null;
|
117 |
| - ServerEnv env = null; |
118 |
| - if ((env = (ServerEnv) getServerEnv()) != null) { |
119 |
| - String wlpOutputDir = env.getValue(Constants.WLP_OUTPUT_DIR); |
120 |
| - if (wlpOutputDir != null) { |
121 |
| - return new Path(wlpOutputDir).append(serverName); |
122 |
| - } |
| 118 | + ConfigVars v = new ConfigVars(); |
| 119 | + addServerEnvVars(v); |
| 120 | + String wlpOutputDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR); |
| 121 | + if (wlpOutputDir != null && !wlpOutputDir.isEmpty()) { |
| 122 | + return new Path(wlpOutputDir).append(serverName); |
| 123 | + } |
| 124 | + wlpOutputDir = System.getenv(Constants.WLP_OUTPUT_DIR); |
| 125 | + if (wlpOutputDir != null && !wlpOutputDir.isEmpty()) { |
| 126 | + return new Path(wlpOutputDir).append(serverName); |
123 | 127 | }
|
124 | 128 | return userDir.getOutputPath().append(serverName);
|
125 | 129 | }
|
@@ -161,6 +165,14 @@ public ExtendedConfigFile getServerEnv() {
|
161 | 165 | return serverEnv;
|
162 | 166 | }
|
163 | 167 |
|
| 168 | + public ExtendedConfigFile getSharedServerEnv() { |
| 169 | + return sharedServerEnv; |
| 170 | + } |
| 171 | + |
| 172 | + public ExtendedConfigFile getEtcServerEnv() { |
| 173 | + return etcServerEnv; |
| 174 | + } |
| 175 | + |
164 | 176 | public ConfigurationFile getConfigRoot() {
|
165 | 177 | synchronized (infoLock) {
|
166 | 178 | updateConfigurationCache();
|
@@ -345,6 +357,17 @@ private boolean updateServerEnv() {
|
345 | 357 | serverEnv = null;
|
346 | 358 | }
|
347 | 359 |
|
| 360 | + File sharedServerEnvFile = getUserDirectory().getSharedPath().append(ExtendedConfigFile.SERVER_ENV_FILE).toFile(); |
| 361 | + if (sharedServerEnvFile.exists()) { |
| 362 | + if (sharedServerEnv == null || sharedServerEnv.hasChanged()) { |
| 363 | + changed = true; |
| 364 | + sharedServerEnv = new ServerEnv(sharedServerEnvFile, null); |
| 365 | + } |
| 366 | + } else if (sharedServerEnv != null) { |
| 367 | + changed = true; |
| 368 | + sharedServerEnv = null; |
| 369 | + } |
| 370 | + |
348 | 371 | File etcServerEnvFile = runtime.getRuntimeLocation().append(ExtendedConfigFile.ETC_DIR).append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
|
349 | 372 | if (etcServerEnvFile.exists()) {
|
350 | 373 | if (etcServerEnv == null || etcServerEnv.hasChanged()) {
|
@@ -437,12 +460,22 @@ private void addServerVars(ConfigVars vars) {
|
437 | 460 | }
|
438 | 461 | }
|
439 | 462 |
|
| 463 | + addServerEnvVars(vars); |
| 464 | + } |
| 465 | + |
| 466 | + private void addServerEnvVars(ConfigVars vars) { |
440 | 467 | // Do the env vars from the <runtime install dir>/etc directory first
|
441 |
| - // since those from the server directory should override. |
| 468 | + // since it is the lowest priority server.env file |
442 | 469 | if (etcServerEnv != null) {
|
443 | 470 | etcServerEnv.getVariables(vars);
|
444 | 471 | }
|
445 | 472 |
|
| 473 | + // Followed by env vars from the <user dir>/shared directory |
| 474 | + if (sharedServerEnv != null) { |
| 475 | + sharedServerEnv.getVariables(vars); |
| 476 | + } |
| 477 | + |
| 478 | + // And finally the env vars from the config dir |
446 | 479 | if (serverEnv != null) {
|
447 | 480 | serverEnv.getVariables(vars);
|
448 | 481 | }
|
@@ -1032,26 +1065,23 @@ public IPath getLogDirectory() {
|
1032 | 1065 | return new Path(messageloc);
|
1033 | 1066 | }
|
1034 | 1067 | String logDir = null;
|
1035 |
| - ServerEnv env = (ServerEnv) getServerEnv(); |
1036 |
| - if (env != null) { |
1037 |
| - ConfigVars v = new ConfigVars(); |
1038 |
| - env.getVariables(v); |
1039 |
| - //When both LOG_DIR and WLP_OUTPUT_DIR are specified . Logs will be created under LOG_DIR. |
1040 |
| - logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.ENV_LOG_DIR); |
1041 |
| - if (logDir != null) { |
1042 |
| - return new Path(logDir); |
1043 |
| - } |
1044 |
| - logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR); |
1045 |
| - if (logDir != null) { |
1046 |
| - return new Path(logDir).append(getServerName()).append("logs"); |
1047 |
| - } |
| 1068 | + ConfigVars v = new ConfigVars(); |
| 1069 | + addServerEnvVars(v); |
| 1070 | + //When both LOG_DIR and WLP_OUTPUT_DIR are specified . Logs will be created under LOG_DIR. |
| 1071 | + logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.ENV_LOG_DIR); |
| 1072 | + if (logDir != null && !logDir.isEmpty()) { |
| 1073 | + return new Path(logDir); |
| 1074 | + } |
| 1075 | + logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR); |
| 1076 | + if (logDir != null && !logDir.isEmpty()) { |
| 1077 | + return new Path(logDir).append(getServerName()).append("logs"); |
1048 | 1078 | }
|
1049 | 1079 | logDir = System.getenv(Constants.ENV_LOG_DIR);
|
1050 |
| - if (logDir != null) { |
| 1080 | + if (logDir != null && !logDir.isEmpty()) { |
1051 | 1081 | return new Path(logDir);
|
1052 | 1082 | }
|
1053 | 1083 | logDir = System.getenv(Constants.WLP_OUTPUT_DIR);
|
1054 |
| - if (logDir != null) { |
| 1084 | + if (logDir != null && !logDir.isEmpty()) { |
1055 | 1085 | return new Path(logDir).append(getServerName()).append("logs");
|
1056 | 1086 | }
|
1057 | 1087 | return null;
|
|
0 commit comments