Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkchan2005-04-26 15:50:33 +0000
committerkchan2005-04-26 15:50:33 +0000
commit3c2abdf6bbc2cbba3eaa92f0a7fd8cd9c1bfdaba (patch)
treec276f4250d1958fafbd6a36eff974e2737061bd7 /bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui
parent32546129acf06aeec0cfc360c66efb0fbaddf73f (diff)
downloadwebtools.webservices-3c2abdf6bbc2cbba3eaa92f0a7fd8cd9c1bfdaba.tar.gz
webtools.webservices-3c2abdf6bbc2cbba3eaa92f0a7fd8cd9c1bfdaba.tar.xz
webtools.webservices-3c2abdf6bbc2cbba3eaa92f0a7fd8cd9c1bfdaba.zip
[92391] Default base on server targetting in page 3.
Diffstat (limited to 'bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui')
-rw-r--r--bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java18
-rw-r--r--bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java70
-rw-r--r--bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils.java35
3 files changed, 114 insertions, 9 deletions
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java
index 54a0aaa2f..225c10a93 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ServerSelectionUtils.java
@@ -230,6 +230,7 @@ public class ServerSelectionUtils
* Given a list of existing servers, this returns the first one that is supported
* by the given Web service type id.
* Returns null of there are no supported servers in the array.
+ * @deprecated
*/
public static IServer getFirstSupportedServer(IServer[] servers, String typeId)
{
@@ -250,6 +251,7 @@ public class ServerSelectionUtils
/*
* Returns the factory id of a server type compatible with the Web service type and the runtime target.
* Returns null if there are none.
+ * @deprecated
*/
public static String getFirstSupportedServerType(IRuntime runtimeTarget, String typeId)
{
@@ -273,6 +275,7 @@ public class ServerSelectionUtils
/*
* Return the factory id of the first server type compatible with the runtimeTargets and typeId.
* Returns null if there are none.
+ * @deprecated
*/
public static String getFirstSupportedServerType(List runtimeTargets, String typeId)
{
@@ -323,7 +326,7 @@ public class ServerSelectionUtils
return null;
IServer[] servers = ServerCore.getServers();
- if (servers==null || servers.length!=0)
+ if (servers==null || servers.length==0)
return null;
ArrayList compatibleServersList = new ArrayList();
@@ -348,13 +351,16 @@ public class ServerSelectionUtils
}
return compatibleServers;
- }
+ }
+
+
/*
* Returns the factory Id and instance id of the first exiting server compatible
* with the runtime targets and typeId
* Returns null if there are none.
* The item at [0] is the factory id.
* The item at [1] is the instance id.
+ * @deprecated
*/
public static String[] getCompatibleExistingServer(List runtimeTargets, String typeId)
{
@@ -400,6 +406,13 @@ public class ServerSelectionUtils
return null;
}
+ /**
+ *
+ * @param runtimeTargets
+ * @param webServiceRuntimeId
+ * @return
+ * @deprecated
+ */
private static List getRuntimeTargetsSupportedByWSRuntime(List runtimeTargets, String webServiceRuntimeId)
{
ArrayList suppRuntimeTargets = new ArrayList();
@@ -422,6 +435,7 @@ public class ServerSelectionUtils
* @param webServiceRuntimeId
* @param j2eeVersion String representation of the int values in J2EEVersionConstants i.e. "12", "13", "14"
* @return String[] index [0] contains factoryId, index[1] contains instance Id.
+ * @deprecated
*/
public static String[] getServerFromWebServceRuntimeAndJ2EE(String webServiceRuntimeId, String j2eeVersion)
{
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java
index 21ca3b35d..0adef5858 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ClientRuntimeSelectionWidgetDefaultingCommand.java
@@ -45,6 +45,7 @@ import org.eclipse.wst.command.internal.provisional.env.core.selection.Selection
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;
@@ -702,17 +703,72 @@ public class ClientRuntimeSelectionWidgetDefaultingCommand extends SimpleCommand
private void setClientDefaultServer()
{
- //Temporarily pick the first existing server in the workspace
- IServer[] servers = ServerCore.getServers();
- if (servers.length > 0)
+ String initialClientProjectName = runtimeClientTypes_.getChoice().getChoice().getList().getSelection();
+ IRuntime runtimeTarget = ServerSelectionUtils.getRuntimeTarget(initialClientProjectName);
+ String runtimeTargetId = null;
+ if (runtimeTarget != null)
{
- clientIds_.setServerId(servers[0].getServerType().getId());
- clientIds_.setServerInstanceId(servers[0].getId());
+ runtimeTargetId = runtimeTarget.getRuntimeType().getId();
+ //Pick a compatible existing server if one exists.
+ IServer[] servers = ServerSelectionUtils.getCompatibleExistingServers(runtimeTarget);
+ if (servers!=null && servers.length>0)
+ {
+ for (int i=0; i<servers.length; i++)
+ {
+ String thisFactoryId = servers[0].getServerType().getId();
+ if (WebServiceRuntimeExtensionUtils.doesRuntimeSupportServer(clientIds_.getRuntimeId(), thisFactoryId))
+ {
+ //Pick this server and return.
+ clientIds_.setServerId(thisFactoryId);
+ clientIds_.setServerInstanceId(servers[0].getId());
+ return;
+ }
+ }
+ }
+
+ //No compatible existing server, set the factory id to something the runtime supports
+ String[] factoryIds = WebServiceRuntimeExtensionUtils.getWebServiceRuntimeById(clientIds_.getRuntimeId()).getServerFactoryIds();
+ if (factoryIds!=null && factoryIds.length>0)
+ {
+ for (int i=0; i<factoryIds.length; i++)
+ {
+ IServerType serverType = ServerCore.findServerType(factoryIds[i]);
+ if (serverType != null)
+ {
+ String serverRuntimeTypeId = serverType.getRuntimeType().getId();
+ if (serverRuntimeTypeId.equals(runtimeTargetId))
+ {
+ //Found a match
+ clientIds_.setServerId(factoryIds[i]);
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+ //Runtime does not specify any server factory ids
+ IServerType[] serverTypes = ServerCore.getServerTypes();
+ clientIds_.setServerId(serverTypes[0].getId());
+ }
+
}
else
{
- clientIds_.setServerId((WebServiceRuntimeExtensionUtils.getWebServiceRuntimeById(clientIds_.getRuntimeId()).getServerFactoryIds())[0]);
- }
+ // The project has no server target so pick a server factory id that is supported by the runtime
+ String[] fids = WebServiceRuntimeExtensionUtils.getWebServiceRuntimeById(clientIds_.getRuntimeId()).getServerFactoryIds();
+ if (fids!=null && fids.length>0)
+ {
+ clientIds_.setServerId(fids[0]);
+ }
+ else
+ {
+ //Runtime does not specify any server factory ids
+ IServerType[] serverTypes = ServerCore.getServerTypes();
+ clientIds_.setServerId(serverTypes[0].getId());
+ }
+
+ }
}
/*
private void setClientDefaultServer()
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils.java
index fb8631255..14f42a48f 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils.java
@@ -446,6 +446,41 @@ public class WebServiceRuntimeExtensionUtils
return server.getName();
}
+ public static boolean doesRuntimeSupportServer(String runtimeId, String factoryId)
+ {
+ WebServiceRuntimeInfo wsrt = getWebServiceRuntimeById(runtimeId);
+ if (wsrt != null)
+ {
+ String[] fids = wsrt.getServerFactoryIds();
+ if (fids!=null)
+ {
+ for (int i=0; i<fids.length; i++)
+ {
+ if (fids[i].equals(factoryId))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static String getFirstSupportedServer(String runtimeId)
+ {
+ WebServiceRuntimeInfo wsrt = getWebServiceRuntimeById(runtimeId);
+
+ if (wsrt != null)
+ {
+ String[] fids = wsrt.getServerFactoryIds();
+ if (fids!=null && fids.length>0)
+ {
+ return fids[0];
+ }
+ }
+
+ return null;
+ }
public static String[] getRuntimesByClientType(String clientTypeId)
{

Back to the top