Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#385 Improve customizability of DefaultGLSPServerLauncher #128

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,15 @@ public void failed(final Throwable exc, final Void attachment) {
return onShutdown;
}

private void createClientConnection(final AsynchronousSocketChannel socketChannel) {
protected void createClientConnection(final AsynchronousSocketChannel socketChannel) {
Injector injector = createInjector();
GsonConfigurator gsonConf = injector.getInstance(GsonConfigurator.class);
try {
InputStream in = Channels.newInputStream(socketChannel);
OutputStream out = Channels.newOutputStream(socketChannel);

Consumer<GsonBuilder> configureGson = (final GsonBuilder builder) -> gsonConf.configureGsonBuilder(builder);
Function<MessageConsumer, MessageConsumer> wrapper = Function.identity();
GLSPServer glspServer = injector.getInstance(GLSPServer.class);
Launcher<GLSPClient> launcher = Launcher.createIoLauncher(glspServer, GLSPClient.class, in, out,
threadPool, wrapper, configureGson);
threadPool, messageWrapper(injector), configureGson(injector));
glspServer.connect(launcher.getRemoteProxy());
log.info("Starting GLSP server connection for client " + socketChannel.getRemoteAddress());
launcher.startListening().get();
Expand All @@ -123,6 +120,15 @@ private void createClientConnection(final AsynchronousSocketChannel socketChanne
}
}

protected Consumer<GsonBuilder> configureGson(final Injector injector) {
GsonConfigurator gsonConf = injector.getInstance(GsonConfigurator.class);
return (final GsonBuilder builder) -> gsonConf.configureGsonBuilder(builder);
}

protected Function<MessageConsumer, MessageConsumer> messageWrapper(final Injector injector) {
return Function.identity();
}

@Override
public void shutdown() {
log.info("Stopping all connections to the GLSP server...");
Expand Down