Skip to content

Commit 02aaad5

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

File tree

6 files changed

+73
-27
lines changed

6 files changed

+73
-27
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: 24 additions & 2 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;
@@ -161,6 +162,10 @@ public ExtendedConfigFile getServerEnv() {
161162
return serverEnv;
162163
}
163164

165+
public ExtendedConfigFile getSharedServerEnv() {
166+
return sharedServerEnv;
167+
}
168+
164169
public ConfigurationFile getConfigRoot() {
165170
synchronized (infoLock) {
166171
updateConfigurationCache();
@@ -345,6 +350,17 @@ private boolean updateServerEnv() {
345350
serverEnv = null;
346351
}
347352

353+
File sharedServerEnvFile = getUserDirectory().getSharedPath().append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
354+
if (sharedServerEnvFile.exists()) {
355+
if (sharedServerEnv == null || sharedServerEnv.hasChanged()) {
356+
changed = true;
357+
sharedServerEnv = new ServerEnv(sharedServerEnvFile, null);
358+
}
359+
} else if (sharedServerEnv != null) {
360+
changed = true;
361+
sharedServerEnv = null;
362+
}
363+
348364
File etcServerEnvFile = runtime.getRuntimeLocation().append(ExtendedConfigFile.ETC_DIR).append(ExtendedConfigFile.SERVER_ENV_FILE).toFile();
349365
if (etcServerEnvFile.exists()) {
350366
if (etcServerEnv == null || etcServerEnv.hasChanged()) {
@@ -438,11 +454,17 @@ private void addServerVars(ConfigVars vars) {
438454
}
439455

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

462+
// Followed by env vars from the <user dir>/shared directory
463+
if (sharedServerEnv != null) {
464+
sharedServerEnv.getVariables(vars);
465+
}
466+
467+
// And finally the env vars from the config dir
446468
if (serverEnv != null) {
447469
serverEnv.getVariables(vars);
448470
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2017 IBM Corporation and others.
2+
* Copyright (c) 2012, 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
66
* http://www.eclipse.org/legal/epl-v10.html
77
*
88
* Contributors:
9-
* IBM Corporation - initial API and implementation
9+
* IBM Corporation - initial API and implementation
1010
*******************************************************************************/
1111
package com.ibm.ws.st.ui.internal.actions;
1212

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);

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2017 IBM Corporation and others.
2+
* Copyright (c) 2012, 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
@@ -30,7 +30,8 @@
3030

3131
public class UtilityActionProvider extends CommonActionProvider {
3232
public static final String UTILITY_MENU_PATH = "utility";
33-
protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[2];
33+
protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[1];
34+
protected NewExtendedConfigAction[] newServerEnvActions = new NewExtendedConfigAction[2];
3435
protected NewExtendedConfigAction[] newJVMOptionsActions = new NewExtendedConfigAction[4];
3536
protected PackageAction packageAction;
3637
protected PluginConfigAction pluginConfigAction;
@@ -47,14 +48,13 @@ public void init(ICommonActionExtensionSite aSite) {
4748
ISelectionProvider selectionProvider = aSite.getStructuredViewer();
4849

4950
createConfigActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE, selectionProvider, viewer);
50-
createConfigActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer);
5151

52-
newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selectionProvider, viewer);
53-
newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selectionProvider, viewer);
52+
newServerEnvActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer, Constants.SERVER_CONFIG_VAR);
53+
newServerEnvActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer, Constants.WLP_USER_DIR_VAR + "/"
54+
+ Constants.SHARED_FOLDER);
5455

5556
newJVMOptionsActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selectionProvider, viewer, Constants.SERVER_CONFIG_VAR);
56-
newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selectionProvider, viewer, Constants.WLP_INSTALL_VAR + "/"
57-
+ Constants.USER_FOLDER + "/"
57+
newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selectionProvider, viewer, Constants.WLP_USER_DIR_VAR + "/"
5858
+ Constants.SHARED_FOLDER);
5959
newJVMOptionsActions[2] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selectionProvider, viewer, Constants.SERVER_CONFIG_VAR + "/"
6060
+ Constants.CONFIG_DROPINS_FOLDER + "/"
@@ -63,6 +63,9 @@ public void init(ICommonActionExtensionSite aSite) {
6363
+ Constants.CONFIG_DROPINS_FOLDER + "/"
6464
+ Constants.CONFIG_OVERRIDE_DROPINS_FOLDER);
6565

66+
newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selectionProvider, viewer);
67+
newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selectionProvider, viewer);
68+
6669
packageAction = new PackageAction(shell, selectionProvider);
6770
pluginConfigAction = new PluginConfigAction(shell, selectionProvider);
6871
dumpAction = new DumpAction(shell, selectionProvider);
@@ -77,8 +80,13 @@ public void fillContextMenu(IMenuManager menu) {
7780
MenuManager configMenu = new MenuManager(Messages.menuNewExtendedConfig, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), "extendedConfig");
7881
for (int i = 0; i < createConfigActions.length; i++)
7982
configMenu.add(createConfigActions[i]);
83+
// Add the submenu for server.env
84+
MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.SERVER_ENV_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.SERVER_ENV_FILE);
85+
for (int i = 0; i < newServerEnvActions.length; i++)
86+
subConfigMenu.add(newServerEnvActions[i]);
87+
configMenu.add(subConfigMenu);
8088
// Add the submenu for jvm.options
81-
MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE);
89+
subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE);
8290
for (int i = 0; i < newJVMOptionsActions.length; i++)
8391
subConfigMenu.add(newJVMOptionsActions[i]);
8492
configMenu.add(subConfigMenu);

0 commit comments

Comments
 (0)