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 26, 2020
1 parent 24d6c96 commit d3859a3
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}";
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -693,9 +693,9 @@ public WebSphereServerInfo getWebSphereServerInfo() {
/**
* Setup for starting the server.
*
* @param launch ILaunch
* @param launch ILaunch
* @param launchMode String
* @param monitor IProgressMonitor
* @param monitor IProgressMonitor
* @throws CoreException if anything goes wrong
*/
public void preLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
Expand Down Expand Up @@ -1337,7 +1337,7 @@ public boolean isCleanOnStartup() {
* reset to <code>false</code> during every launch.
*
* @param clean <code>true</code> if the server should be cleaned on next startup,
* and <code>false</code> otherwise.
* and <code>false</code> otherwise.
*/
public void setCleanOnStartup(boolean clean) {
cleanOnStartup = clean;
Expand Down Expand Up @@ -1711,6 +1711,12 @@ else if (userDir != null && userDir.getRemoteUserPath() != null) {
if (fileLocation != null)
fileLocations.add(new File(fileLocation).toString().replace("\\", "/"));
}

if (serverInfo.getSharedServerEnv() != null) {
URI fileLocation = serverInfo.getSharedServerEnv().getURI();
if (fileLocation != null)
fileLocations.add(new File(fileLocation).toString().replace("\\", "/"));
}
}
return fileLocations.toArray(new String[fileLocations.size()]);
}
Expand Down
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 @@ -114,12 +115,15 @@ public IPath getServerAppsPath() {
public IPath getServerOutputPath() {
if (serverName == null)
return null;
ServerEnv env = null;
if ((env = (ServerEnv) getServerEnv()) != null) {
String wlpOutputDir = env.getValue(Constants.WLP_OUTPUT_DIR);
if (wlpOutputDir != null) {
return new Path(wlpOutputDir).append(serverName);
}
ConfigVars v = new ConfigVars();
addServerEnvVars(v);
String wlpOutputDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR);
if (wlpOutputDir != null && !wlpOutputDir.isEmpty()) {
return new Path(wlpOutputDir).append(serverName);
}
wlpOutputDir = System.getenv(Constants.WLP_OUTPUT_DIR);
if (wlpOutputDir != null && !wlpOutputDir.isEmpty()) {
return new Path(wlpOutputDir).append(serverName);
}
return userDir.getOutputPath().append(serverName);
}
Expand Down Expand Up @@ -161,6 +165,14 @@ public ExtendedConfigFile getServerEnv() {
return serverEnv;
}

public ExtendedConfigFile getSharedServerEnv() {
return sharedServerEnv;
}

public ExtendedConfigFile getEtcServerEnv() {
return etcServerEnv;
}

public ConfigurationFile getConfigRoot() {
synchronized (infoLock) {
updateConfigurationCache();
Expand Down Expand Up @@ -345,6 +357,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 +460,22 @@ private void addServerVars(ConfigVars vars) {
}
}

addServerEnvVars(vars);
}

private void addServerEnvVars(ConfigVars vars) {
// 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 Expand Up @@ -1032,26 +1065,23 @@ public IPath getLogDirectory() {
return new Path(messageloc);
}
String logDir = null;
ServerEnv env = (ServerEnv) getServerEnv();
if (env != null) {
ConfigVars v = new ConfigVars();
env.getVariables(v);
//When both LOG_DIR and WLP_OUTPUT_DIR are specified . Logs will be created under LOG_DIR.
logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.ENV_LOG_DIR);
if (logDir != null) {
return new Path(logDir);
}
logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR);
if (logDir != null) {
return new Path(logDir).append(getServerName()).append("logs");
}
ConfigVars v = new ConfigVars();
addServerEnvVars(v);
//When both LOG_DIR and WLP_OUTPUT_DIR are specified . Logs will be created under LOG_DIR.
logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.ENV_LOG_DIR);
if (logDir != null && !logDir.isEmpty()) {
return new Path(logDir);
}
logDir = v.getValue(Constants.ENV_VAR_PREFIX + Constants.WLP_OUTPUT_DIR);
if (logDir != null && !logDir.isEmpty()) {
return new Path(logDir).append(getServerName()).append("logs");
}
logDir = System.getenv(Constants.ENV_LOG_DIR);
if (logDir != null) {
if (logDir != null && !logDir.isEmpty()) {
return new Path(logDir);
}
logDir = System.getenv(Constants.WLP_OUTPUT_DIR);
if (logDir != null) {
if (logDir != null && !logDir.isEmpty()) {
return new Path(logDir).append(getServerName()).append("logs");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -176,6 +176,12 @@ private void updateResultDependencies(ConfigurationFile configFile,
ExtendedConfigFile serverEnv = serverInfo.getServerEnv();
if (serverEnv != null && serverEnv.getIFile() != null)
resourceList.add(serverEnv.getIFile());
serverEnv = serverInfo.getSharedServerEnv();
if (serverEnv != null && serverEnv.getIFile() != null)
resourceList.add(serverEnv.getIFile());
serverEnv = serverInfo.getEtcServerEnv();
if (serverEnv != null && serverEnv.getIFile() != null)
resourceList.add(serverEnv.getIFile());
}

// Add a dependency on unresolved includes
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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[2];
protected NewExtendedConfigAction[] newJVMOptionsActions = new NewExtendedConfigAction[4];
protected NewConfigDropinAction[] newConfigDropinActions = new NewConfigDropinAction[2];
protected AddOnRuntimeAction addOnRuntimeAction;

@Override
Expand All @@ -74,23 +75,26 @@ 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);

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 + "/"
+ Constants.CONFIG_DEFAULT_DROPINS_FOLDER);
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);
}

Expand All @@ -108,8 +112,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);
Expand Down
Loading

0 comments on commit d3859a3

Please sign in to comment.