Java Code Examples for org.eclipse.lsp4j.jsonrpc.Launcher#createLauncher()
The following examples show how to use
org.eclipse.lsp4j.jsonrpc.Launcher#createLauncher() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
@Test public void testValidationIssue2() throws Exception { String requestMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"1\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": null, \"nested\": { \"value\": null } }\n" + "}"; String clientMessages = getHeader(requestMessage1.getBytes().length) + requestMessage1; ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out, true, null); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 379" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"error\":{\"code\":-32600,\"message\":\"Multiple issues were found in \\u0027askServer\\u0027 request.\"," + "\"data\":[" + "{\"text\":\"The accessor \\u0027MyParam.getValue()\\u0027 must return a non-null value. Path: $.params.nested.value\",\"code\":-32602}," + "{\"text\":\"The accessor \\u0027MyParam.getValue()\\u0027 must return a non-null value. Path: $.params.value\",\"code\":-32602}" + "]}}", out.toString()); }
Example 2
Source File: SendNotificationTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws IOException { this.client = mock(ExecuteCommandProposedClient.class); PipedOutputStream clientWritesTo = new PipedOutputStream(); PipedInputStream clientReadsFrom = new PipedInputStream(); PipedInputStream serverReadsFrom = new PipedInputStream(); PipedOutputStream serverWritesTo = new PipedOutputStream(); serverWritesTo.connect(clientReadsFrom); clientWritesTo.connect(serverReadsFrom); this.closeables = new Closeable[] { clientWritesTo, clientReadsFrom, serverReadsFrom, serverWritesTo }; Launcher<JavaLanguageClient> serverLauncher = Launcher.createLauncher(new Object(), JavaLanguageClient.class, serverReadsFrom, serverWritesTo); serverLauncher.startListening(); Launcher<LanguageServer> clientLauncher = Launcher.createLauncher(client, LanguageServer.class, clientReadsFrom, clientWritesTo); clientLauncher.startListening(); this.clientConnection = serverLauncher.getRemoteProxy(); }
Example 3
Source File: SocketServerLauncher.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public void launch(String[] args) { Injector injector = Guice.createInjector(getServerModule()); try (AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open() .bind(getSocketAddress(args))) { LOG.info("Started server socket at " + getSocketAddress(args)); while (true) { AsynchronousSocketChannel socketChannel = serverSocket.accept().get(); InputStream in = Channels.newInputStream(socketChannel); OutputStream out = Channels.newOutputStream(socketChannel); PrintWriter trace = getTrace(args); boolean validate = shouldValidate(args); LanguageServerImpl languageServer = injector.getInstance(LanguageServerImpl.class); LOG .info("Starting Xtext Language Server for client " + socketChannel.getRemoteAddress()); Launcher<LanguageClient> launcher = Launcher.createLauncher(languageServer, LanguageClient.class, in, out, validate, trace); languageServer.connect(launcher.getRemoteProxy()); launcher.startListening(); LOG.info("Xtext Language Server has been started."); } } catch (Throwable t) { t.printStackTrace(); } }
Example 4
Source File: ProtocolTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
/** * creates a proxy, delegating to a remote endpoint, forwarding to another remote endpoint, that delegates to an actual implementation. * @param intf * @param impl * @return * @throws IOException */ public <T> T wrap(Class<T> intf, T impl) { PipedInputStream in1 = new PipedInputStream(); PipedOutputStream out1 = new PipedOutputStream(); Launcher<T> launcher1 = Launcher.createLauncher(impl, intf, in1, out1); PipedInputStream in2 = new PipedInputStream(); PipedOutputStream out2 = new PipedOutputStream(); Launcher<T> launcher2 = Launcher.createLauncher(new Object(), intf, in2, out2); try { in1.connect(out2); in2.connect(out1); } catch (IOException e) { throw new IllegalStateException(e); } launcher1.startListening(); launcher2.startListening(); return launcher2.getRemoteProxy(); }
Example 5
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
@Test public void testResponse1() throws Exception { // create client message String requestMessage = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"42\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessage = getHeader(requestMessage.getBytes().length) + requestMessage; // create server side ByteArrayInputStream in = new ByteArrayInputStream(clientMessage.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 52" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"result\":{\"value\":\"bar\"}}", out.toString()); }
Example 6
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
@Test public void testResponse2() throws Exception { // create client message String requestMessage = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": 42,\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessage = getHeader(requestMessage.getBytes().length) + requestMessage; // create server side ByteArrayInputStream in = new ByteArrayInputStream(clientMessage.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 50" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":42,\"result\":{\"value\":\"bar\"}}", out.toString()); }
Example 7
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
@Test public void testEither() throws Exception { // create client message String requestMessage = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": 42,\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"either\": \"bar\", \"value\": \"foo\" }\n" + "}"; String clientMessage = getHeader(requestMessage.getBytes().length) + requestMessage; // create server side ByteArrayInputStream in = new ByteArrayInputStream(clientMessage.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 65" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":42,\"result\":{\"value\":\"foo\",\"either\":\"bar\"}}", out.toString()); }
Example 8
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
@Test public void testEitherNull() throws Exception { // create client message String requestMessage = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": 42,\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"either\": null, \"value\": \"foo\" }\n" + "}"; String clientMessage = getHeader(requestMessage.getBytes().length) + requestMessage; // create server side ByteArrayInputStream in = new ByteArrayInputStream(clientMessage.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 50" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":42,\"result\":{\"value\":\"foo\"}}", out.toString()); }
Example 9
Source File: LauncherTest.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
@Test public void testCanceled() throws Exception { A a = new A() { @Override public void say(Param p) { } }; Launcher<A> launcher = Launcher.createLauncher(a, A.class, new InputStream() { @Override public int read() throws IOException { try { Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } return '\n'; } }, new ByteArrayOutputStream()); Future<?> startListening = launcher.startListening(); startListening.cancel(true); Assert.assertTrue(startListening.isDone()); Assert.assertTrue(startListening.isCancelled()); }
Example 10
Source File: ExtendableConcurrentMessageProcessorTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
/** * Test that an adopter making use of these APIs is able to * identify which client is making any given request. */ @Test public void testIdentifyClientRequest() throws Exception { // create client side PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(); PipedInputStream in2 = new PipedInputStream(); PipedOutputStream out2 = new PipedOutputStream(); in.connect(out2); out.connect(in2); MyClient client = new MyClientImpl(); Launcher<MyServer> clientSideLauncher = Launcher.createLauncher(client, MyServer.class, in, out); // create server side MyServer server = new MyServerImpl(); MessageContextStore<MyClient> contextStore = new MessageContextStore<>(); Launcher<MyClient> serverSideLauncher = createLauncher(createBuilder(contextStore), server, MyClient.class, in2, out2); TestContextWrapper.setMap(contextStore); clientSideLauncher.startListening(); serverSideLauncher.startListening(); CompletableFuture<MyParam> fooFuture = clientSideLauncher.getRemoteProxy().askServer(new MyParam("FOO")); CompletableFuture<MyParam> barFuture = serverSideLauncher.getRemoteProxy().askClient(new MyParam("BAR")); Assert.assertEquals("FOO", fooFuture.get(TIMEOUT, TimeUnit.MILLISECONDS).value); Assert.assertEquals("BAR", barFuture.get(TIMEOUT, TimeUnit.MILLISECONDS).value); Assert.assertFalse(TestContextWrapper.error); }
Example 11
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testValidationIssue1() throws Exception { String requestMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"1\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": null }\n" + "}"; String requestMessage2 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"2\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessages = getHeader(requestMessage1.getBytes().length) + requestMessage1 + getHeader(requestMessage2.getBytes().length) + requestMessage2; ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out, true, null); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 157" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"error\":{\"code\":-32602,\"message\":\"The accessor \\u0027MyParam.getValue()\\u0027 must return a non-null value. Path: $.params.value\"}}" + "Content-Length: 51" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"value\":\"bar\"}}", out.toString()); }
Example 12
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testMalformedJson4() throws Exception { String requestMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"1\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}}"; String requestMessage2 = "{\"jsonrpc\":\"2.0\",\n" + "\"id\":\"2\",\n" + "\"method\":\"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessages = getHeader(requestMessage1.getBytes().length) + requestMessage1 + getHeader(requestMessage2.getBytes().length) + requestMessage2; ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 195" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"error\":{\"code\":-32700,\"message\":\"Message could not be parsed.\"," + "\"data\":{\"message\":\"Use JsonReader.setLenient(true) to accept malformed JSON at line 5 column 3 path $\"}}}" + "Content-Length: 51" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"value\":\"bar\"}}", out.toString()); }
Example 13
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testMalformedJson3() throws Exception { String requestMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"1\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "]"; String requestMessage2 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"2\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessages = getHeader(requestMessage1.getBytes().length) + requestMessage1 + getHeader(requestMessage2.getBytes().length) + requestMessage2; ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 165" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"error\":{\"code\":-32700,\"message\":\"Message could not be parsed.\"," + "\"data\":{\"message\":\"Unterminated object at line 5 column 2 path $.params\"}}}" + "Content-Length: 51" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"value\":\"bar\"}}", out.toString()); }
Example 14
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testMalformedJson2() throws Exception { // intercept log messages LogMessageAccumulator logMessages = new LogMessageAccumulator(); try { logMessages.registerTo(StreamMessageProducer.class); String requestMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"params\": { \"value\": }\n" + "\"id\": \"1\",\n" + "\"method\":\"askServer\",\n" + "}"; String requestMessage2 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"2\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessages = getHeader(requestMessage1.getBytes().length) + requestMessage1 + getHeader(requestMessage2.getBytes().length) + requestMessage2; ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening(); logMessages.await(Level.SEVERE, "com.google.gson.stream.MalformedJsonException: Expected value at line 2 column 22 path $.params.value"); Assert.assertEquals("Content-Length: 51" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"value\":\"bar\"}}", out.toString()); } finally { logMessages.unregister(); } }
Example 15
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testMalformedJson1() throws Exception { String requestMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"1\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": }\n" + "}"; String requestMessage2 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"2\",\n" + "\"method\": \"askServer\",\n" + "\"params\": { \"value\": \"bar\" }\n" + "}"; String clientMessages = getHeader(requestMessage1.getBytes().length) + requestMessage1 + getHeader(requestMessage2.getBytes().length) + requestMessage2; ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening().get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertEquals("Content-Length: 214" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"error\":{\"code\":-32700,\"message\":\"Message could not be parsed.\"," + "\"data\":{\"message\":\"com.google.gson.stream.MalformedJsonException: Expected value at line 4 column 22 path $.params.value\"}}}" + "Content-Length: 51" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"2\",\"result\":{\"value\":\"bar\"}}", out.toString()); }
Example 16
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testUnexpectedParams() throws Exception { // intercept log messages LogMessageAccumulator logMessages = new LogMessageAccumulator(); try { logMessages.registerTo(GenericEndpoint.class); // create client messages String notificationMessage = "{\"jsonrpc\": \"2.0\",\n" + "\"method\": \"myNotification\",\n" + "\"params\": { \"value\": \"foo\" }\n" + "}"; String clientMessages = getHeader(notificationMessage.getBytes().length) + notificationMessage; // create server side ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); UnexpectedParamsTestServer server = new UnexpectedParamsTestServer() { public void myNotification() { } }; Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening(); logMessages.await(Level.WARNING, "Unexpected params '{\"value\":\"foo\"}' for " + "'public abstract void org.eclipse.lsp4j.jsonrpc.test.IntegrationTest$UnexpectedParamsTestServer.myNotification()' is ignored"); } finally { logMessages.unregister(); } }
Example 17
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testUnknownMessages() throws Exception { // intercept log messages LogMessageAccumulator logMessages = new LogMessageAccumulator(); try { logMessages.registerTo(GenericEndpoint.class); // create client messages String clientMessage1 = "{\"jsonrpc\": \"2.0\",\n" + "\"method\": \"foo1\",\n" + "\"params\": \"bar\"\n" + "}"; String clientMessage2 = "{\"jsonrpc\": \"2.0\",\n" + "\"id\": \"1\",\n" + "\"method\": \"foo2\",\n" + "\"params\": \"bar\"\n" + "}"; String clientMessages = getHeader(clientMessage1.getBytes().length) + clientMessage1 + getHeader(clientMessage2.getBytes().length) + clientMessage2; // create server side ByteArrayInputStream in = new ByteArrayInputStream(clientMessages.getBytes()); ByteArrayOutputStream out = new ByteArrayOutputStream(); MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in, out); serverSideLauncher.startListening(); logMessages.await(Level.WARNING, "Unsupported notification method: foo1"); logMessages.await(Level.WARNING, "Unsupported request method: foo2"); Assert.assertEquals("Content-Length: 95" + CRLF + CRLF + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"error\":{\"code\":-32601,\"message\":\"Unsupported request method: foo2\"}}", out.toString()); } finally { logMessages.unregister(); } }
Example 18
Source File: IntegrationTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testBothDirectionRequests() throws Exception { // create client side PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(); PipedInputStream in2 = new PipedInputStream(); PipedOutputStream out2 = new PipedOutputStream(); in.connect(out2); out.connect(in2); MyClient client = new MyClientImpl(); Launcher<MyServer> clientSideLauncher = Launcher.createLauncher(client, MyServer.class, in, out); // create server side MyServer server = new MyServerImpl(); Launcher<MyClient> serverSideLauncher = Launcher.createLauncher(server, MyClient.class, in2, out2); clientSideLauncher.startListening(); serverSideLauncher.startListening(); CompletableFuture<MyParam> fooFuture = clientSideLauncher.getRemoteProxy().askServer(new MyParam("FOO")); CompletableFuture<MyParam> barFuture = serverSideLauncher.getRemoteProxy().askClient(new MyParam("BAR")); Assert.assertEquals("FOO", fooFuture.get(TIMEOUT, TimeUnit.MILLISECONDS).value); Assert.assertEquals("BAR", barFuture.get(TIMEOUT, TimeUnit.MILLISECONDS).value); }
Example 19
Source File: LauncherTest.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Test public void testDone() throws Exception { A a = new A() { @Override public void say(Param p) { } }; Launcher<A> launcher = Launcher.createLauncher(a, A.class, new ByteArrayInputStream("".getBytes()), new ByteArrayOutputStream()); Future<?> startListening = launcher.startListening(); startListening.get(TIMEOUT, TimeUnit.MILLISECONDS); Assert.assertTrue(startListening.isDone()); Assert.assertFalse(startListening.isCancelled()); }
Example 20
Source File: SarosLauncher.java From saros with GNU General Public License v2.0 | 4 votes |
/** * Starts the server. * * @param args command-line arguments * @throws Exception on critical failures */ public static void main(String[] args) throws Exception { if (args.length > 1) { throw new IllegalArgumentException("wrong number of arguments"); } else if (args.length != 1) { throw new IllegalArgumentException("port parameter not supplied"); } else if (!args[0].matches("\\d+")) { throw new IllegalArgumentException("port is not a number"); } URL log4jProperties = SarosLauncher.class.getResource(LOGGING_CONFIG_FILE); PropertyConfigurator.configure(log4jProperties); log.addAppender(new ConsoleAppender()); int port = Integer.parseInt(args[0]); Socket socket = new Socket("localhost", port); log.info("listening on port " + port); Runtime.getRuntime() .addShutdownHook( new Thread() { public void run() { try { socket.close(); } catch (IOException e) { // NOP } } }); SarosLanguageServer langSvr = new SarosLanguageServer(); Launcher<ISarosLanguageClient> l = Launcher.createLauncher( langSvr, ISarosLanguageClient.class, socket.getInputStream(), socket.getOutputStream()); ISarosLanguageClient langClt = l.getRemoteProxy(); log.addAppender(new LanguageClientAppender(langClt)); langSvr.connect(langClt); l.startListening(); }