changeset 7290:1bb43e54af7a

RT-35473 [Monocle] Allow specifying the VNC port (required to allow simultaneous tests in Jenkins)
author Daniel Blaukopf <daniel.blaukopf@oracle.com>
date Wed, 11 Jun 2014 22:52:13 +0300
parents 6eaeae29f418
children 3aa343ef3313
files modules/graphics/src/main/java/com/sun/glass/ui/monocle/vnc/VNCScreen.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/vnc/VNCScreen.java	Wed Jun 11 15:21:05 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/vnc/VNCScreen.java	Wed Jun 11 22:52:13 2014 +0300
@@ -39,6 +39,8 @@
 import java.nio.channels.SocketChannel;
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.Charset;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.BitSet;
 import java.util.HashSet;
 import java.util.Set;
@@ -55,10 +57,13 @@
         super(1024, 600, 32);
         try {
             server = ServerSocketChannel.open();
-            server.bind(new InetSocketAddress(5901));
+            int vncPort = AccessController.doPrivileged(
+                    (PrivilegedAction<Integer>)
+                            () -> Integer.getInteger("vnc.port", 5901));
+            server.bind(new InetSocketAddress(vncPort));
             Thread t = new Thread(new ConnectionAccepter());
             t.setDaemon(true);
-            t.setName("VNC Server on port 5901");
+            t.setName("VNC Server on port " + vncPort);
             t.start();
         } catch (IOException e) {
             e.printStackTrace();