Package org.eclipse.lsp4j.jsonrpc
Interface Launcher<T>
-
- Type Parameters:
T- remote service interface type
- All Known Implementing Classes:
StandardLauncher
public interface Launcher<T>This is the entry point for applications that use LSP4J. A Launcher does all the wiring that is necessary to connect your endpoint via an input stream and an output stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classLauncher.Builder<T>The launcher builder wires up all components for JSON-RPC communication.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <T> Launcher<T>createIoLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, boolean validate, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)Create a new Launcher for a given local service object, a given remote interface and an input and output stream.static <T> Launcher<T>createIoLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper)Create a new Launcher for a given local service object, a given remote interface and an input and output stream.static <T> Launcher<T>createIoLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)Create a new Launcher for a given local service object, a given remote interface and an input and output stream.static Launcher<java.lang.Object>createIoLauncher(java.util.Collection<java.lang.Object> localServices, java.util.Collection<java.lang.Class<?>> remoteInterfaces, java.lang.ClassLoader classLoader, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)Create a new Launcher for a collection of local service objects, a collection of remote interfaces and an input and output stream.static <T> Launcher<T>createLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out)Create a new Launcher for a given local service object, a given remote interface and an input and output stream.static <T> Launcher<T>createLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, boolean validate, java.io.PrintWriter trace)Create a new Launcher for a given local service object, a given remote interface and an input and output stream, and set up message validation and tracing.static <T> Launcher<T>createLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper)Create a new Launcher for a given local service object, a given remote interface and an input and output stream.RemoteEndpointgetRemoteEndpoint()Returns the remote endpoint.TgetRemoteProxy()Returns the proxy instance that implements the remote service interfaces.java.util.concurrent.Future<java.lang.Void>startListening()Start a thread that listens to the input stream.
-
-
-
Method Detail
-
createLauncher
static <T> Launcher<T> createLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out)
Create a new Launcher for a given local service object, a given remote interface and an input and output stream.- Parameters:
localService- - the object that receives method calls from the remote serviceremoteInterface- - an interface on which RPC methods are looked upin- - input stream to listen for incoming messagesout- - output stream to send outgoing messages
-
createLauncher
static <T> Launcher<T> createLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, boolean validate, java.io.PrintWriter trace)
Create a new Launcher for a given local service object, a given remote interface and an input and output stream, and set up message validation and tracing.- Parameters:
localService- - the object that receives method calls from the remote serviceremoteInterface- - an interface on which RPC methods are looked upin- - input stream to listen for incoming messagesout- - output stream to send outgoing messagesvalidate- - whether messages should be validated with theReflectiveMessageValidatortrace- - a writer to which incoming and outgoing messages are traced, ornullto disable tracing
-
createLauncher
static <T> Launcher<T> createLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper)
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.- Parameters:
localService- - the object that receives method calls from the remote serviceremoteInterface- - an interface on which RPC methods are looked upin- - input stream to listen for incoming messagesout- - output stream to send outgoing messagesexecutorService- - the executor service used to start threadswrapper- - a function for plugging in additional message consumers
-
createIoLauncher
static <T> Launcher<T> createIoLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper)
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.- Parameters:
localService- - the object that receives method calls from the remote serviceremoteInterface- - an interface on which RPC methods are looked upin- - input stream to listen for incoming messagesout- - output stream to send outgoing messagesexecutorService- - the executor service used to start threadswrapper- - a function for plugging in additional message consumers
-
createIoLauncher
static <T> Launcher<T> createIoLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)
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. TheconfigureGsonfunction can be used to register additional type adapters in theGsonBuilderin order to support protocol classes that cannot be handled by Gson's reflective capabilities.- Parameters:
localService- - the object that receives method calls from the remote serviceremoteInterface- - an interface on which RPC methods are looked upin- - input stream to listen for incoming messagesout- - output stream to send outgoing messagesexecutorService- - the executor service used to start threadswrapper- - a function for plugging in additional message consumersconfigureGson- - a function for Gson configuration
-
createIoLauncher
static <T> Launcher<T> createIoLauncher(java.lang.Object localService, java.lang.Class<T> remoteInterface, java.io.InputStream in, java.io.OutputStream out, boolean validate, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)
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. TheconfigureGsonfunction can be used to register additional type adapters in theGsonBuilderin order to support protocol classes that cannot be handled by Gson's reflective capabilities.- Parameters:
localService- - the object that receives method calls from the remote serviceremoteInterface- - an interface on which RPC methods are looked upin- - input stream to listen for incoming messagesout- - output stream to send outgoing messagesvalidate- - whether messages should be validated with theReflectiveMessageValidatorexecutorService- - the executor service used to start threadswrapper- - a function for plugging in additional message consumersconfigureGson- - a function for Gson configuration
-
createIoLauncher
static Launcher<java.lang.Object> createIoLauncher(java.util.Collection<java.lang.Object> localServices, java.util.Collection<java.lang.Class<?>> remoteInterfaces, java.lang.ClassLoader classLoader, java.io.InputStream in, java.io.OutputStream out, java.util.concurrent.ExecutorService executorService, java.util.function.Function<MessageConsumer,MessageConsumer> wrapper, java.util.function.Consumer<com.google.gson.GsonBuilder> configureGson)
Create a new Launcher for a collection of local service objects, a collection of remote interfaces 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. TheconfigureGsonfunction can be used to register additional type adapters in theGsonBuilderin order to support protocol classes that cannot be handled by Gson's reflective capabilities.- Parameters:
localServices- - the objects that receive method calls from the remote servicesremoteInterfaces- - interfaces on which RPC methods are looked upclassLoader- - a class loader that is able to resolve all given interfacesin- - input stream to listen for incoming messagesout- - output stream to send outgoing messagesexecutorService- - the executor service used to start threadswrapper- - a function for plugging in additional message consumersconfigureGson- - a function for Gson configuration
-
startListening
java.util.concurrent.Future<java.lang.Void> startListening()
Start a thread that listens to the input stream. The thread terminates when the stream is closed.- Returns:
- a future that returns
nullwhen the listener thread is terminated
-
getRemoteProxy
T getRemoteProxy()
Returns the proxy instance that implements the remote service interfaces.
-
getRemoteEndpoint
RemoteEndpoint getRemoteEndpoint()
Returns the remote endpoint. Use this one to send genericrequestornotifymethods to the remote services.
-
-