本文整理了Java中org.eclipse.lsp4j.jsonrpc.Launcher.createIoLauncher()
方法的一些代码示例,展示了Launcher.createIoLauncher()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Launcher.createIoLauncher()
方法的具体详情如下:
包路径:org.eclipse.lsp4j.jsonrpc.Launcher
类名称:Launcher
方法名:createIoLauncher
[英]Create a new Launcher for a given local service object, a given remote interface and an input and output stream. Threads are started with the given executor service. The wrapper function is applied to the incoming and outgoing message streams so additional message handling such as validation and tracing can be included.
[中]为给定的本地服务对象、给定的远程接口以及输入和输出流创建新的启动器。线程由给定的执行器服务启动。包装器函数应用于传入和传出消息流,因此可以包括验证和跟踪等附加消息处理。
代码示例来源:origin: eclipse/lsp4j
/**
* Create a new Launcher for a given local service object, a given remote interface and an input and output stream.
* Threads are started with the given executor service. The wrapper function is applied to the incoming and
* outgoing message streams so additional message handling such as validation and tracing can be included.
*
* @param localService - the object that receives method calls from the remote service
* @param remoteInterface - an interface on which RPC methods are looked up
* @param in - input stream to listen for incoming messages
* @param out - output stream to send outgoing messages
* @param executorService - the executor service used to start threads
* @param wrapper - a function for plugging in additional message consumers
*/
static <T> Launcher<T> createLauncher(Object localService, Class<T> remoteInterface, InputStream in, OutputStream out,
ExecutorService executorService, Function<MessageConsumer, MessageConsumer> wrapper) {
return createIoLauncher(localService, remoteInterface, in, out, executorService, wrapper);
}
代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc
/**
* Create a new Launcher for a given local service object, a given remote interface and an input and output stream.
* Threads are started with the given executor service. The wrapper function is applied to the incoming and
* outgoing message streams so additional message handling such as validation and tracing can be included.
*
* @param localService - the object that receives method calls from the remote service
* @param remoteInterface - an interface on which RPC methods are looked up
* @param in - input stream to listen for incoming messages
* @param out - output stream to send outgoing messages
* @param executorService - the executor service used to start threads
* @param wrapper - a function for plugging in additional message consumers
*/
static <T> Launcher<T> createLauncher(Object localService, Class<T> remoteInterface, InputStream in, OutputStream out,
ExecutorService executorService, Function<MessageConsumer, MessageConsumer> wrapper) {
return createIoLauncher(localService, remoteInterface, in, out, executorService, wrapper);
}
代码示例来源:origin: spring-projects/sts4
private <T> Launcher<T> createSocketLauncher(
Object localService, Class<T> remoteInterface,
SocketAddress socketAddress, ExecutorService executorService,
Function<MessageConsumer, MessageConsumer> wrapper
) throws Exception {
AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open().bind(socketAddress);
AsynchronousSocketChannel socketChannel = serverSocket.accept().get();
log.info("Client connected via socket");
return Launcher.createIoLauncher(localService, remoteInterface, Channels.newInputStream(socketChannel),
Channels.newOutputStream(socketChannel), executorService, wrapper);
}
代码示例来源:origin: com.eclipsesource.glsp/glsp-server
public void run() throws IOException, InterruptedException, ExecutionException {
Injector injector = Guice.createInjector(module);
GsonConfigurator gsonConf = injector.getInstance(GsonConfigurator.class);
AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open()
.bind(new InetSocketAddress(host, port));
ExecutorService threadPool = Executors.newCachedThreadPool();
log.info("The graphical server launcher is ready to accept new client requests");
while (true) {
AsynchronousSocketChannel socketChannel = serverSocket.accept().get();
InputStream in = Channels.newInputStream(socketChannel);
OutputStream out = Channels.newOutputStream(socketChannel);
Consumer<GsonBuilder> configureGson = (GsonBuilder builder) -> gsonConf.configureGsonBuilder(builder);
Function<MessageConsumer, MessageConsumer> wrapper = (MessageConsumer it) -> {
return it;
};
GLSPServer languageServer = injector.getInstance(GLSPServer.class);
Launcher<GLSPClient> launcher = Launcher.createIoLauncher(languageServer,
GLSPClient.class, in, out, threadPool, wrapper, configureGson);
languageServer.connect(launcher.getRemoteProxy());
launcher.startListening();
log.info("Started language server for client " + socketChannel.getRemoteAddress());
}
}
}
代码示例来源:origin: eclipse/lsp4j
Launcher<A> launcher = Launcher.createIoLauncher(a, A.class, new ByteArrayInputStream("".getBytes()), out,
Executors.newCachedThreadPool(), c -> c,
gsonBuilder -> {gsonBuilder.registerTypeAdapter(Param.class, typeAdapter);});
代码示例来源:origin: eclipse/eclipse.jdt.ls
private void startConnection() throws IOException {
Launcher<JavaLanguageClient> launcher;
ExecutorService executorService = Executors.newCachedThreadPool();
protocol = new JDTLanguageServer(projectsManager, preferenceManager);
if (JDTEnvironmentUtils.inSocketStreamDebugMode()) {
String host = JDTEnvironmentUtils.getClientHost();
Integer port = JDTEnvironmentUtils.getClientPort();
InetSocketAddress inetSocketAddress = new InetSocketAddress(host, port);
AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open().bind(inetSocketAddress);
try {
AsynchronousSocketChannel socketChannel = serverSocket.accept().get();
InputStream in = Channels.newInputStream(socketChannel);
OutputStream out = Channels.newOutputStream(socketChannel);
Function<MessageConsumer, MessageConsumer> messageConsumer = it -> it;
launcher = Launcher.createIoLauncher(protocol, JavaLanguageClient.class, in, out, executorService, messageConsumer);
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Error when opening a socket channel at " + host + ":" + port + ".", e);
}
} else {
ConnectionStreamFactory connectionFactory = new ConnectionStreamFactory();
InputStream in = connectionFactory.getInputStream();
OutputStream out = connectionFactory.getOutputStream();
Function<MessageConsumer, MessageConsumer> wrapper = new ParentProcessWatcher(this.languageServer);
launcher = Launcher.createLauncher(protocol, JavaLanguageClient.class, in, out, executorService, wrapper);
}
protocol.connectClient(launcher.getRemoteProxy());
launcher.startListening();
}
代码示例来源:origin: eclipse/lsp4j
Launcher<Object> launcher = Launcher.createIoLauncher(Arrays.asList(a, b), Arrays.asList(A.class, B.class),
classLoader, in, out, Executors.newCachedThreadPool(), c -> c, null);
内容来源于网络,如有侵权,请联系作者删除!