diff options
| author | Stéphane Bégaudeau | 2018-05-22 14:35:32 +0000 |
|---|---|---|
| committer | Stéphane Bégaudeau | 2018-05-22 14:39:23 +0000 |
| commit | d7651f3dc1246623c252e0f342bb7f94ae1df9b0 (patch) | |
| tree | ca74a9cb549e0ddf05f2619726df6c5cf8b3d2a5 | |
| parent | ccbdc55a7a2a328840ce6dd795221d8769b226b4 (diff) | |
| download | org.eclipse.sirius-d7651f3dc1246623c252e0f342bb7f94ae1df9b0.tar.gz org.eclipse.sirius-d7651f3dc1246623c252e0f342bb7f94ae1df9b0.tar.xz org.eclipse.sirius-d7651f3dc1246623c252e0f342bb7f94ae1df9b0.zip | |
[509735] Use a random port for the server by default
The Sirius server will now be started with a random port by default. The
workflow page will use the port computed dynamically by the server to
display its content.
Bug: 509735
Change-Id: Ic4a53abd5df30b9fdbbce82eff117c23c77564d9
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
3 files changed, 14 insertions, 16 deletions
diff --git a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java index b4ab5a4d85..effb1c7df1 100644 --- a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java +++ b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java @@ -11,6 +11,7 @@ package org.eclipse.sirius.server.internal; import java.net.InetSocketAddress; +import java.net.URI; import java.util.Optional; import org.eclipse.core.runtime.IStatus; @@ -37,15 +38,13 @@ public class SiriusServerManager { /** * The default port. */ - private static final String PORT = "8080"; //$NON-NLS-1$ + private static final String PORT = "0"; //$NON-NLS-1$ /** * The Jetty server. */ private Server server; - private InetSocketAddress address; - /** * Starts the HTTP server. */ @@ -53,7 +52,7 @@ public class SiriusServerManager { public void start() { if (this.server == null || !this.server.isRunning()) { int port = Integer.valueOf(System.getProperty(PORT_VMARG, PORT)).intValue(); - address = new InetSocketAddress(HOSTNAME, port); + InetSocketAddress address = new InetSocketAddress(HOSTNAME, port); this.server = new Server(address); this.server.setHandler(new HandlerCollection()); @@ -85,10 +84,10 @@ public class SiriusServerManager { /** * Returns the address on which the server is listening. - * + * * @return the address on which the server is listening. */ - public InetSocketAddress getAddress() { - return this.address; + public URI getURI() { + return this.server.getURI(); } } diff --git a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java index cb74c8d996..e9c6b4b2ca 100644 --- a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java +++ b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.sirius.server.internal; -import java.net.InetSocketAddress; +import java.net.URI; import java.util.List; import java.util.stream.Collectors; @@ -153,12 +153,12 @@ public class SiriusServerPlugin extends EMFPlugin { } /** - * Returns the address on which the server is listening. - * - * @return the address on which the server is listening. + * Returns the URI on which the server is listening. + * + * @return the URI on which the server is listening. */ - public InetSocketAddress getServerAddress() { - return serverManager.getAddress(); + public URI getServerURI() { + return serverManager.getURI(); } } } diff --git a/plugins/org.eclipse.sirius.workflow.ui.page/src/org/eclipse/sirius/workflow/ui/page/WorkflowPage.java b/plugins/org.eclipse.sirius.workflow.ui.page/src/org/eclipse/sirius/workflow/ui/page/WorkflowPage.java index 1c8a5f67a0..dd11fd2734 100644 --- a/plugins/org.eclipse.sirius.workflow.ui.page/src/org/eclipse/sirius/workflow/ui/page/WorkflowPage.java +++ b/plugins/org.eclipse.sirius.workflow.ui.page/src/org/eclipse/sirius/workflow/ui/page/WorkflowPage.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.sirius.workflow.ui.page; -import java.net.InetSocketAddress; import java.text.MessageFormat; import java.util.Objects; import java.util.Optional; @@ -90,10 +89,10 @@ public class WorkflowPage extends AbstractSessionEditorPage { URI uri = session.getSessionResource().getURI(); if (uri.isPlatformResource()) { @SuppressWarnings("restriction") - InetSocketAddress addr = SiriusServerPlugin.getPlugin().getServerAddress(); + java.net.URI serverUri = SiriusServerPlugin.getPlugin().getServerURI(); // Use this URL when using the frontend in dev mode. // return "http://localhost:3000/projects/" + uri.segment(1); //$NON-NLS-1$ - return String.format("http://%s:%d/projects/%s?fullscreen=true", addr.getHostString(), addr.getPort(), uri.segment(1)); //$NON-NLS-1$ + return String.format("http://%s:%d/projects/%s?fullscreen=true", serverUri.getHost(), serverUri.getPort(), uri.segment(1)); //$NON-NLS-1$ } else { return "http://localhost:8080/"; //$NON-NLS-1$ } |
