[513486] - add API to separate hasRuntime vs requiresRuntime on serverType
Change-Id: I8a446c8b58033d57a095a2d6bd619e6716a26bbc
Signed-off-by: Rob Stryker <stryker@redhat.com>
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java
index 33c377f..7dcc2ab 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java
@@ -100,21 +100,30 @@
public IRuntimeType getRuntimeType();
/**
- * Returns whether this type of server requires a server
- * runtime.
- * <p>
- * [issue: See issues on getRuntimeType(). I suspect this
- * method is unnecessary, and that
- * this.getRuntimeType() != null will do.]
- * </p>
+ * Returns whether this type of server has support for
+ * a server runtime.
*
- * @return <code>true</code> if this type of server requires
+ * This method is equivalent to this.getRuntimeType() != null
+ *
+ * @return <code>true</code> if this type of server supports
* a server runtime, and <code>false</code> if it does not
* @see #getRuntimeType()
*/
public boolean hasRuntime();
/**
+ * Returns whether this type of server requires a server
+ * runtime.
+ *
+ * @return <code>true</code> if this type of server requires
+ * a server runtime, and <code>false</code> if it does not
+ * @see #getRuntimeType()
+ * @since 1.9
+ */
+ public boolean requiresRuntime();
+
+
+ /**
* Returns whether this type of server supports the given launch mode.
* <p>
* [issue: It also seems odd that this is part of the server type
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java
index 8106605..1778990 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java
@@ -114,14 +114,19 @@
}
public boolean hasRuntime() {
+ return getRuntimeType() != null;
+ }
+
+ public boolean requiresRuntime() {
try {
String s = element.getAttribute("runtime");
- return "true".equals(s);
+ return "true".equals(s) && getRuntimeType() != null;
} catch (Exception e) {
return false;
}
}
+
public ILaunchConfigurationType getLaunchConfigurationType() {
try {
String launchConfigId = element.getAttribute("launchConfigId");
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerTypeProxy.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerTypeProxy.java
index 4f3af52..81578b2 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerTypeProxy.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerTypeProxy.java
@@ -77,6 +77,10 @@
public boolean hasRuntime() {
return false;
}
+
+ public boolean requiresRuntime() {
+ return false;
+ }
public void dispose() {
runtimeType = null;
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java
index 352faf3..01dfa25 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerBehaviourDelegate.java
@@ -902,7 +902,7 @@
Trace.trace(Trace.STRING_FINEST, "-->-- Publishing to server: " + getServer().toString() + " -->--");
}
- if (getServer().getServerType().hasRuntime() && getServer().getRuntime() == null)
+ if (getServer().getServerType().requiresRuntime() && getServer().getRuntime() == null)
return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, Messages.errorPublishNoRuntime, null);
final List<IModule[]> moduleList = getAllModules();
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java
index 577c4b9..e5a1455 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java
@@ -179,7 +179,7 @@
} else
hostname.setText("");
- // check if "runtime" property is true or false
+ // check if server type can have a runtime
if (runtime != null && server != null && server.getServerType() != null && server.getServerType().hasRuntime())
runtimeLabel.setText(runtime.getName());
else
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java
index 35b56a2..65f5e9b 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java
@@ -502,7 +502,7 @@
try {
// try to create runtime first
IRuntime run = null;
- if (serverType.hasRuntime()) {
+ if (serverType.requiresRuntime()) {
runtime = null;
updateRuntimes(serverType, isLocalhost);
run = getDefaultRuntime();
@@ -511,7 +511,7 @@
if (server != null) {
server.setHost(host);
- if (serverType.hasRuntime() && server.getRuntime() == null) {
+ if (serverType.requiresRuntime() && server.getRuntime() == null) {
runtime = null;
updateRuntimes(serverType, isLocalhost);
setRuntime(getDefaultRuntime());
@@ -591,7 +591,7 @@
}
protected void updateRuntimeCombo(IServerType serverType) {
- if (serverType == null || !serverType.hasRuntime() || server == null) {
+ if (serverType == null || !serverType.requiresRuntime() || server == null) {
if (runtimeLabel != null) {
runtimeLabel.setEnabled(false);
runtimeCombo.setItems(new String[0]);
@@ -823,7 +823,7 @@
serverNameLabel.setVisible(true);
serverName.setVisible(true);
hostnameLabel.setVisible(true);
- if (serverType.hasRuntime() && server != null
+ if (serverType.requiresRuntime() && server != null
&& ServerUIPlugin.getRuntimes(serverType.getRuntimeType()).length >= 1) {
runtimeLabel.setVisible(true);
runtimeCombo.setVisible(true);