From aa2b39354bc5360c70f2520097121ebb775dddc8 Mon Sep 17 00:00:00 2001 From: Erin Harris Date: Tue, 25 Feb 2020 17:20:16 -0500 Subject: [PATCH] Issue #228: Support all server.env files --- .../ibm/ws/st/core/internal/Constants.java | 3 +- .../ws/st/core/internal/WebSphereRuntime.java | 6 +++- .../st/core/internal/WebSphereServerInfo.java | 22 +++++++++++-- .../actions/NewExtendedConfigAction.java | 9 ++++-- .../RuntimeExplorerViewActionProvider.java | 31 +++++++++++++------ .../actions/UtilityActionProvider.java | 23 ++++++++++---- 6 files changed, 72 insertions(+), 22 deletions(-) diff --git a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/Constants.java b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/Constants.java index 5b6886cf..d947f7f4 100644 --- a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/Constants.java +++ b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/Constants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2019 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 @@ -196,6 +196,7 @@ public class Constants { // configuration variables public static final String SERVER_CONFIG_VAR = "${server.config.dir}"; public static final String SERVER_OUTPUT_VAR = "${server.output.dir}"; + public static final String WLP_USER_DIR_VAR = "${wlp.user.dir}"; public static final String WLP_INSTALL_VAR = "${wlp.install.dir}"; public static final String LOGGING_DIR_VAR = "${com.ibm.ws.logging.log.directory}"; public static final String MESSAGES_FILENAME_VAR = "${com.ibm.ws.logging.message.file.name}"; diff --git a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereRuntime.java b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereRuntime.java index 96fff332..d930befe 100644 --- a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereRuntime.java +++ b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereRuntime.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2019 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 @@ -2020,6 +2020,10 @@ public IPath getDefaultSharedResourcesPath() { return getRuntimePath(SHARED_RESOURCES_FOLDER); } + public IPath getEtcPath() { + return getRuntimePath(Constants.ETC_FOLDER); + } + private IPath getRuntimePath(String folder) { IPath path = getRuntime().getLocation(); if (path == null) diff --git a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereServerInfo.java b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereServerInfo.java index 69e59c4e..8d86517a 100644 --- a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereServerInfo.java +++ b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/WebSphereServerInfo.java @@ -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 @@ -63,6 +63,7 @@ public class WebSphereServerInfo implements IMetadataGenerator { private Bootstrap bootstrap; private final Map jvmOptionsFiles; private ServerEnv serverEnv; + private ServerEnv sharedServerEnv; private ServerEnv etcServerEnv; private final UserDirectory userDir; @@ -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()) { @@ -438,11 +450,17 @@ private void addServerVars(ConfigVars vars) { } // Do the env vars from the /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 /shared directory + if (sharedServerEnv != null) { + sharedServerEnv.getVariables(vars); + } + + // And finally the env vars from the config dir if (serverEnv != null) { serverEnv.getVariables(vars); } diff --git a/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/NewExtendedConfigAction.java b/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/NewExtendedConfigAction.java index fcd2d69e..a9bb360f 100644 --- a/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/NewExtendedConfigAction.java +++ b/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/NewExtendedConfigAction.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2012, 2017 IBM Corporation and others. + * Copyright (c) 2012, 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ package com.ibm.ws.st.ui.internal.actions; @@ -122,6 +122,8 @@ private IPath getPath() { path = server.getServerPath(); else if (in.contains(Constants.SHARED_FOLDER)) path = server.getUserDirectory().getSharedPath(); + else if (in.contains(Constants.ETC_FOLDER)) + path = server.getWebSphereRuntime().getEtcPath(); else if (in.contains(Constants.CONFIG_DEFAULT_DROPINS_FOLDER)) path = server.getConfigDefaultDropinsPath(); else if (in.contains(Constants.CONFIG_OVERRIDE_DROPINS_FOLDER)) @@ -140,6 +142,9 @@ private IFolder getFolder() { folder = server.getServerFolder(); else if (in.contains(Constants.SHARED_FOLDER)) folder = server.getUserDirectory().getSharedFolder(); + else if (in.contains(Constants.ETC_FOLDER)) + // No folder for the etc dir, use the path instead + return null; else if (in.contains(Constants.CONFIG_DEFAULT_DROPINS_FOLDER)) folder = server.getConfigDefaultDropinsFolder(); else if (in.contains(Constants.CONFIG_OVERRIDE_DROPINS_FOLDER)) diff --git a/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/RuntimeExplorerViewActionProvider.java b/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/RuntimeExplorerViewActionProvider.java index 1329cc11..4ae895fe 100644 --- a/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/RuntimeExplorerViewActionProvider.java +++ b/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/RuntimeExplorerViewActionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 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 @@ -47,9 +47,10 @@ public class RuntimeExplorerViewActionProvider extends CommonActionProvider { protected NewQuickServerAction newQuickServerAction; protected ShowInServersAction showInServersAction; protected PropertiesAction propertiesAction; - protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[2]; - protected NewConfigDropinAction[] newConfigDropinActions = new NewConfigDropinAction[2]; + protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[1]; + protected NewExtendedConfigAction[] newServerEnvActions = new NewExtendedConfigAction[3]; protected NewExtendedConfigAction[] newJVMOptionsActions = new NewExtendedConfigAction[4]; + protected NewConfigDropinAction[] newConfigDropinActions = new NewConfigDropinAction[2]; protected AddOnRuntimeAction addOnRuntimeAction; @Override @@ -74,16 +75,17 @@ public void init(ICommonActionExtensionSite aSite) { showInServersAction = new ShowInServersAction(selProvider); propertiesAction = new PropertiesAction(selProvider, shell); - //propertiesAction.runtime. + createConfigActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE, selProvider, viewer); - createConfigActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer); - newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selProvider, viewer); - newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selProvider, viewer); + newServerEnvActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR); + newServerEnvActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer, Constants.WLP_USER_DIR_VAR + "/" + + Constants.SHARED_FOLDER); + newServerEnvActions[2] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selProvider, viewer, Constants.WLP_INSTALL_VAR + "/" + + Constants.ETC_FOLDER); newJVMOptionsActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR); - newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.WLP_INSTALL_VAR + "/" - + Constants.USER_FOLDER + "/" + newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.WLP_USER_DIR_VAR + "/" + Constants.SHARED_FOLDER); newJVMOptionsActions[2] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR + "/" + Constants.CONFIG_DROPINS_FOLDER + "/" @@ -91,6 +93,10 @@ public void init(ICommonActionExtensionSite aSite) { newJVMOptionsActions[3] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selProvider, viewer, Constants.SERVER_CONFIG_VAR + "/" + Constants.CONFIG_DROPINS_FOLDER + "/" + Constants.CONFIG_OVERRIDE_DROPINS_FOLDER); + + newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selProvider, viewer); + newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selProvider, viewer); + addOnRuntimeAction = new AddOnRuntimeAction(shell, selProvider); } @@ -108,8 +114,13 @@ public void fillContextMenu(IMenuManager menu) { MenuManager configMenu = new MenuManager(Messages.menuNewExtendedConfig, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), "extendedConfig"); for (int i = 0; i < createConfigActions.length; i++) configMenu.add(createConfigActions[i]); + // Add the submenu for server.env + MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.SERVER_ENV_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.SERVER_ENV_FILE); + for (int i = 0; i < newServerEnvActions.length; i++) + subConfigMenu.add(newServerEnvActions[i]); + configMenu.add(subConfigMenu); // Add the submenu for jvm.options - MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE); + subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE); for (int i = 0; i < newJVMOptionsActions.length; i++) subConfigMenu.add(newJVMOptionsActions[i]); configMenu.add(subConfigMenu); diff --git a/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/UtilityActionProvider.java b/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/UtilityActionProvider.java index d4d87973..2d162f89 100644 --- a/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/UtilityActionProvider.java +++ b/dev/com.ibm.ws.st.ui/src/com/ibm/ws/st/ui/internal/actions/UtilityActionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2017 IBM Corporation and others. + * Copyright (c) 2012, 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 @@ -30,7 +30,8 @@ public class UtilityActionProvider extends CommonActionProvider { public static final String UTILITY_MENU_PATH = "utility"; - protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[2]; + protected NewExtendedConfigAction[] createConfigActions = new NewExtendedConfigAction[1]; + protected NewExtendedConfigAction[] newServerEnvActions = new NewExtendedConfigAction[3]; protected NewExtendedConfigAction[] newJVMOptionsActions = new NewExtendedConfigAction[4]; protected PackageAction packageAction; protected PluginConfigAction pluginConfigAction; @@ -47,10 +48,12 @@ public void init(ICommonActionExtensionSite aSite) { ISelectionProvider selectionProvider = aSite.getStructuredViewer(); createConfigActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE, selectionProvider, viewer); - createConfigActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer); - newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selectionProvider, viewer); - newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selectionProvider, viewer); + newServerEnvActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer, Constants.SERVER_CONFIG_VAR); + newServerEnvActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer, Constants.WLP_USER_DIR_VAR + "/" + + Constants.SHARED_FOLDER); + newServerEnvActions[2] = new NewExtendedConfigAction(ExtendedConfigFile.SERVER_ENV_FILE, selectionProvider, viewer, Constants.WLP_INSTALL_VAR + "/" + + Constants.ETC_FOLDER); newJVMOptionsActions[0] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selectionProvider, viewer, Constants.SERVER_CONFIG_VAR); newJVMOptionsActions[1] = new NewExtendedConfigAction(ExtendedConfigFile.JVM_OPTIONS_FILE, selectionProvider, viewer, Constants.WLP_INSTALL_VAR + "/" @@ -63,6 +66,9 @@ public void init(ICommonActionExtensionSite aSite) { + Constants.CONFIG_DROPINS_FOLDER + "/" + Constants.CONFIG_OVERRIDE_DROPINS_FOLDER); + newConfigDropinActions[0] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.DEFAULTS, selectionProvider, viewer); + newConfigDropinActions[1] = new NewConfigDropinAction(NewConfigDropinAction.DropinType.OVERRIDES, selectionProvider, viewer); + packageAction = new PackageAction(shell, selectionProvider); pluginConfigAction = new PluginConfigAction(shell, selectionProvider); dumpAction = new DumpAction(shell, selectionProvider); @@ -77,8 +83,13 @@ public void fillContextMenu(IMenuManager menu) { MenuManager configMenu = new MenuManager(Messages.menuNewExtendedConfig, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), "extendedConfig"); for (int i = 0; i < createConfigActions.length; i++) configMenu.add(createConfigActions[i]); + // Add the submenu for server.env + MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.SERVER_ENV_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.SERVER_ENV_FILE); + for (int i = 0; i < newServerEnvActions.length; i++) + subConfigMenu.add(newServerEnvActions[i]); + configMenu.add(subConfigMenu); // Add the submenu for jvm.options - MenuManager subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE); + subConfigMenu = new MenuManager(ExtendedConfigFile.JVM_OPTIONS_FILE, Activator.getImageDescriptor(ExtendedConfigFile.BOOTSTRAP_PROPS_FILE), ExtendedConfigFile.JVM_OPTIONS_FILE); for (int i = 0; i < newJVMOptionsActions.length; i++) subConfigMenu.add(newJVMOptionsActions[i]); configMenu.add(subConfigMenu);