Skip to content

Commit b697bdb

Browse files
committed
Issue OpenLiberty#228: Support all server.env files
1 parent 24d6c96 commit b697bdb

File tree

6 files changed

+103
-47
lines changed

6 files changed

+103
-47
lines changed

dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/Constants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2019 IBM Corporation and others.
2+
* Copyright (c) 2011, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -196,6 +196,7 @@ public class Constants {
196196
// configuration variables
197197
public static final String SERVER_CONFIG_VAR = "${server.config.dir}";
198198
public static final String SERVER_OUTPUT_VAR = "${server.output.dir}";
199+
public static final String WLP_USER_DIR_VAR = "${wlp.user.dir}";
199200
public static final String WLP_INSTALL_VAR = "${wlp.install.dir}";
200201
public static final String LOGGING_DIR_VAR = "${com.ibm.ws.logging.log.directory}";
201202
public static final String MESSAGES_FILENAME_VAR = "${com.ibm.ws.logging.message.file.name}";

dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereServerBehaviour.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2017 IBM Corporation and others.
2+
* Copyright (c) 2011, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -693,9 +693,9 @@ public WebSphereServerInfo getWebSphereServerInfo() {
693693
/**
694694
* Setup for starting the server.
695695
*
696-
* @param launch ILaunch
696+
* @param launch ILaunch
697697
* @param launchMode String
698-
* @param monitor IProgressMonitor
698+
* @param monitor IProgressMonitor
699699
* @throws CoreException if anything goes wrong
700700
*/
701701
public void preLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
@@ -1337,7 +1337,7 @@ public boolean isCleanOnStartup() {
13371337
* reset to <code>false</code> during every launch.
13381338
*
13391339
* @param clean <code>true</code> if the server should be cleaned on next startup,
1340-
* and <code>false</code> otherwise.
1340+
* and <code>false</code> otherwise.
13411341
*/
13421342
public void setCleanOnStartup(boolean clean) {
13431343
cleanOnStartup = clean;
@@ -1711,6 +1711,12 @@ else if (userDir != null && userDir.getRemoteUserPath() != null) {
17111711
if (fileLocation != null)
17121712
fileLocations.add(new File(fileLocation).toString().replace("\\", "/"));
17131713
}
1714+
1715+
if (serverInfo.getSharedServerEnv() != null) {
1716+
URI fileLocation = serverInfo.getSharedServerEnv().getURI();
1717+
if (fileLocation != null)
1718+
fileLocations.add(new File(fileLocation).toString().replace("\\", "/"));
1719+
}
17141720
}
17151721
return fileLocations.toArray(new String[fileLocations.size()]);
17161722
}

dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereServerInfo.java

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2018 IBM Corporation and others.
2+
* Copyright (c) 2011, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -63,6 +63,7 @@ public class WebSphereServerInfo implements IMetadataGenerator {
6363
private Bootstrap bootstrap;
6464
private final Map<IPath, JVMOptions> jvmOptionsFiles;
6565
private ServerEnv serverEnv;
66+
private ServerEnv sharedServerEnv;
6667
private ServerEnv etcServerEnv;
6768

6869
private final UserDirectory userDir;
@@ -114,12 +115,11 @@ public IPath getServerAppsPath() {
114115
public IPath getServerOutputPath() {
115116
if (serverName == null)
116117
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);
123123
}
124124
return userDir.getOutputPath().append(serverName);
125125
}
@@ -161,6 +161,14 @@ public ExtendedConfigFile getServerEnv() {
161161
return serverEnv;
162162
}
163163

164+
public ExtendedConfigFile getSharedServerEnv() {
165+
return sharedServerEnv;
166+
}
167+
168+
public ExtendedConfigFile getEtcServerEnv() {
169+
return etcServerEnv;
170+
}
171+
164172
public ConfigurationFile getConfigRoot() {
165173
synchronized (infoLock) {
166174
updateConfigurationCache();
@@ -345,6 +353,17 @@ private boolean updateServerEnv() {
345353
serverEnv = null;
346354
}
347355

356+
File sharedServerEnvFile = getUserDirectory().getSharedPath().append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
357+
if (sharedServerEnvFile.exists()) {
358+
if (sharedServerEnv == null || sharedServerEnv.hasChanged()) {
359+
changed = true;
360+
sharedServerEnv = new ServerEnv(sharedServerEnvFile, null);
361+
}
362+
} else if (sharedServerEnv != null) {
363+
changed = true;
364+
sharedServerEnv = null;
365+
}
366+
348367
File etcServerEnvFile = runtime.getRuntimeLocation().append(ExtendedConfigFile.ETC_DIR).append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
349368
if (etcServerEnvFile.exists()) {
350369
if (etcServerEnv == null || etcServerEnv.hasChanged()) {
@@ -437,12 +456,22 @@ private void addServerVars(ConfigVars vars) {
437456
}
438457
}
439458

459+
addServerEnvVars(vars);
460+
}
461+
462+
private void addServerEnvVars(ConfigVars vars) {
440463
// Do the env vars from the <runtime install dir>/etc directory first
441-
// since those from the server directory should override.
464+
// since it is the lowest priority server.env file
442465
if (etcServerEnv != null) {
443466
etcServerEnv.getVariables(vars);
444467
}
445468

469+
// Followed by env vars from the <user dir>/shared directory
470+
if (sharedServerEnv != null) {
471+
sharedServerEnv.getVariables(vars);
472+
}
473+
474+
// And finally the env vars from the config dir
446475
if (serverEnv != null) {
447476
serverEnv.getVariables(vars);
448477
}
@@ -1032,26 +1061,23 @@ public IPath getLogDirectory() {
10321061
return new Path(messageloc);
10331062
}
10341063
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-
}
1064+
ConfigVars v = new ConfigVars();
1065+
addServerEnvVars(v);
1066+
//When both LOG_DIR and WLP_OUTPUT_DIR are specified . Logs will be created under LOG_DIR.
1067+
logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.ENV_LOG_DIR);
1068+
if (logDir != null && !logDir.isEmpty()) {
1069+
return new Path(logDir);
1070+
}
1071+
logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR);
1072+
if (logDir != null && !logDir.isEmpty()) {
1073+
return new Path(logDir).append(getServerName()).append("logs");
10481074
}
10491075
logDir = System.getenv(Constants.ENV_LOG_DIR);
1050-
if (logDir != null) {
1076+
if (logDir != null && !logDir.isEmpty()) {
10511077
return new Path(logDir);
10521078
}
10531079
logDir = System.getenv(Constants.WLP_OUTPUT_DIR);
1054-
if (logDir != null) {
1080+
if (logDir != null && !logDir.isEmpty()) {
10551081
return new Path(logDir).append(getServerName()).append("logs");
10561082
}
10571083
return null;

dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/config/validation/ConfigurationValidator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2017 IBM Corporation and others.
2+
* Copyright (c) 2011, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -176,6 +176,12 @@ private void updateResultDependencies(ConfigurationFile configFile,
176176
ExtendedConfigFile serverEnv = serverInfo.getServerEnv();
177177
if (serverEnv != null && serverEnv.getIFile() != null)
178178
resourceList.add(serverEnv.getIFile());
179+
serverEnv = serverInfo.getSharedServerEnv();
180+
if (serverEnv != null && serverEnv.getIFile() != null)
181+
resourceList.add(serverEnv.getIFile());
182+
serverEnv = serverInfo.getEtcServerEnv();
183+
if (serverEnv != null && serverEnv.getIFile() != null)
184+
resourceList.add(serverEnv.getIFile());
179185
}
180186

181187
// Add a dependency on unresolved includes

dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/RuntimeExplorerViewActionProvider.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2017 IBM Corporation and others.
2+
* Copyright (c) 2011, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -47,9 +47,10 @@ public class RuntimeExplorerViewActionProvider extends CommonActionProvider {
4747
protected NewQuickServerAction newQuickServerAction;
4848
protected ShowInServersAction showInServersAction;
4949
protected PropertiesAction propertiesAction;
50-
protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[2];
51-
protected NewConfigDropinAction[] newConfigDropinActions = new NewConfigDropinAction[2];
50+
protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[1];
51+
protected NewExtendedConfigAction[] newServerEnvActions = new NewExtendedConfigAction[2];
5252
protected NewExtendedConfigAction[] newJVMOptionsActions = new NewExtendedConfigAction[4];
53+
protected NewConfigDropinAction[] newConfigDropinActions = new NewConfigDropinAction[2];
5354
protected AddOnRuntimeAction addOnRuntimeAction;
5455

5556
@Override
@@ -74,23 +75,26 @@ public void init(ICommonActionExtensionSite aSite) {
7475

7576
showInServersAction = new ShowInServersAction(selProvider);
7677
propertiesAction = new PropertiesAction(selProvider, shell);
77-
//propertiesAction.runtime.
78+
7879
createConfigActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE, selProvider, viewer);
79-
createConfigActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer);
8080

81-
newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selProvider, viewer);
82-
newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selProvider, viewer);
81+
newServerEnvActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR);
82+
newServerEnvActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer, Constants.WLP_USER_DIR_VAR + "/"
83+
+ Constants.SHARED_FOLDER);
8384

8485
newJVMOptionsActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR);
85-
newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.WLP_INSTALL_VAR + "/"
86-
+ Constants.USER_FOLDER + "/"
86+
newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.WLP_USER_DIR_VAR + "/"
8787
+ Constants.SHARED_FOLDER);
8888
newJVMOptionsActions[2] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR + "/"
8989
+ Constants.CONFIG_DROPINS_FOLDER + "/"
9090
+ Constants.CONFIG_DEFAULT_DROPINS_FOLDER);
9191
newJVMOptionsActions[3] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR + "/"
9292
+ Constants.CONFIG_DROPINS_FOLDER + "/"
9393
+ Constants.CONFIG_OVERRIDE_DROPINS_FOLDER);
94+
95+
newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selProvider, viewer);
96+
newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selProvider, viewer);
97+
9498
addOnRuntimeAction = new AddOnRuntimeAction(shell, selProvider);
9599
}
96100

@@ -108,8 +112,13 @@ public void fillContextMenu(IMenuManager menu) {
108112
MenuManager configMenu = new MenuManager(Messages.menuNewExtendedConfig, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), "extendedConfig");
109113
for (int i = 0; i < createConfigActions.length; i++)
110114
configMenu.add(createConfigActions[i]);
115+
// Add the submenu for server.env
116+
MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.SERVER_ENV_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.SERVER_ENV_FILE);
117+
for (int i = 0; i < newServerEnvActions.length; i++)
118+
subConfigMenu.add(newServerEnvActions[i]);
119+
configMenu.add(subConfigMenu);
111120
// Add the submenu for jvm.options
112-
MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE);
121+
subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE);
113122
for (int i = 0; i < newJVMOptionsActions.length; i++)
114123
subConfigMenu.add(newJVMOptionsActions[i]);
115124
configMenu.add(subConfigMenu);

0 commit comments

Comments
 (0)