本文整理汇总了Java中org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints.toServiceObject方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceEndpoints.toServiceObject方法的具体用法?Java ServiceEndpoints.toServiceObject怎么用?Java ServiceEndpoints.toServiceObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints
的用法示例。
在下文中一共展示了ServiceEndpoints.toServiceObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServerInitialized
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
@Override
public void onServerInitialized(
LanguageServerLauncher launcher,
LanguageServer server,
ServerCapabilities capabilities,
String projectPath) {
try {
Map<String, String> preferences =
requestFactory.fromUrl(apiUrl + "/preferences").useGetMethod().request().asProperties();
Endpoint endpoint = ServiceEndpoints.toEndpoint(server);
YamlSchemaAssociations serviceObject =
ServiceEndpoints.toServiceObject(endpoint, YamlSchemaAssociations.class);
Map<String, String[]> associations =
jsonToSchemaAssociations(preferences.get("yaml.preferences"));
serviceObject.yamlSchemaAssociation(associations);
} catch (ApiException | IOException e) {
LOG.error(e.getLocalizedMessage(), e);
}
}
示例2: putSchemas
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
/**
* Route for getting getting schemas from client side and injecting them into yaml language server
*
* @param yamlDto A yamlDTO containing the list of schemas you would like to add
*/
@POST
@Path("schemas")
@Consumes(MediaType.APPLICATION_JSON)
public void putSchemas(YamlDTO yamlDto) throws ApiException {
LanguageServer yamlLS = YamlLanguageServerLauncher.getYamlLanguageServer();
if (yamlDto != null && yamlLS != null) {
Endpoint endpoint = ServiceEndpoints.toEndpoint(yamlLS);
YamlSchemaAssociations serviceObject =
ServiceEndpoints.toServiceObject(endpoint, YamlSchemaAssociations.class);
Map<String, String[]> schemaAssociations = new HashMap<>();
Map<String, String> yamlDtoSchemas = yamlDto.getSchemas();
for (Map.Entry<String, String> schema : yamlDtoSchemas.entrySet()) {
schemaAssociations.put(
schema.getKey(), new Gson().fromJson(schema.getValue(), String[].class));
}
serviceObject.yamlSchemaAssociation(schemaAssociations);
}
}
示例3: onServerInitialized
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
@Override
public void onServerInitialized(
LanguageServerLauncher launcher,
LanguageServer server,
ServerCapabilities capabilities,
String projectPath) {
Endpoint endpoint = ServiceEndpoints.toEndpoint(server);
JsonExtension serviceObject = ServiceEndpoints.toServiceObject(endpoint, JsonExtension.class);
Map<String, String[]> associations = new HashMap<>();
associations.put("/*.schema.json", new String[] {"http://json-schema.org/draft-04/schema#"});
associations.put("/bower.json", new String[] {"http://json.schemastore.org/bower"});
associations.put("/.bower.json", new String[] {"http://json.schemastore.org/bower"});
associations.put("/.bowerrc", new String[] {"http://json.schemastore.org/bowerrc"});
associations.put("/composer.json", new String[] {"https://getcomposer.org/schema.json"});
associations.put("/package.json", new String[] {"http://json.schemastore.org/package"});
associations.put("/jsconfig.json", new String[] {"http://json.schemastore.org/jsconfig"});
associations.put("/tsconfig.json", new String[] {"http://json.schemastore.org/tsconfig"});
serviceObject.jsonSchemaAssociation(associations);
}
示例4: createIoLauncher
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
/**
* 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.
* The {@code configureGson} function can be used to register additional type adapters in the {@link GsonBuilder}
* in order to support protocol classes that cannot be handled by Gson's reflective capabilities.
*
* @param localService - an object on which classes RPC methods are looked up
* @param remoteInterface - an interface on which RPC methods are looked up
* @param in - inputstream to listen for incoming messages
* @param out - outputstream to send outgoing messages
* @param executorService - the executor service used to start threads
* @param wrapper - a function for plugging in additional message consumers
* @param configureGson - a function for Gson configuration
*/
static <T> DebugLauncher<T> createIoLauncher(Object localService, Class<T> remoteInterface, InputStream in, OutputStream out,
ExecutorService executorService, Function<MessageConsumer, MessageConsumer> wrapper, Consumer<GsonBuilder> configureGson) {
Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<String, JsonRpcMethod>();
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(remoteInterface));
if (localService instanceof JsonRpcMethodProvider) {
JsonRpcMethodProvider rpcMethodProvider = (JsonRpcMethodProvider) localService;
supportedMethods.putAll(rpcMethodProvider.supportedMethods());
} else {
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(localService.getClass()));
}
MessageJsonHandler jsonHandler = new DebugMessageJsonHandler(supportedMethods, configureGson);
MessageConsumer outGoingMessageStream = new StreamMessageConsumer(out, jsonHandler);
outGoingMessageStream = wrapper.apply(outGoingMessageStream);
RemoteEndpoint serverEndpoint = new RemoteEndpoint(outGoingMessageStream, ServiceEndpoints.toEndpoint(localService));
jsonHandler.setMethodProvider(serverEndpoint);
// wrap incoming message stream
MessageConsumer messageConsumer = wrapper.apply(serverEndpoint);
StreamMessageProducer reader = new StreamMessageProducer(in, jsonHandler);
T remoteProxy = ServiceEndpoints.toServiceObject(serverEndpoint, remoteInterface);
return new DebugLauncher<T> () {
@Override
public Future<?> startListening() {
return ConcurrentMessageProcessor.startProcessing(reader, messageConsumer, executorService);
}
@Override
public T getRemoteProxy() {
return remoteProxy;
}
};
}
示例5: createIoLauncher
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
/**
* 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.
* The {@code configureGson} function can be used to register additional type adapters in the {@link GsonBuilder}
* in order to support protocol classes that cannot be handled by Gson's reflective capabilities.
*
* @param localService - an object on which classes RPC methods are looked up
* @param remoteInterface - an interface on which RPC methods are looked up
* @param in - inputstream to listen for incoming messages
* @param out - outputstream to send outgoing messages
* @param executorService - the executor service used to start threads
* @param wrapper - a function for plugging in additional message consumers
* @param configureGson - a function for Gson configuration
*/
static <T> Launcher<T> createIoLauncher(Object localService, Class<T> remoteInterface, InputStream in, OutputStream out,
ExecutorService executorService, Function<MessageConsumer, MessageConsumer> wrapper, Consumer<GsonBuilder> configureGson) {
Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<String, JsonRpcMethod>();
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(remoteInterface));
if (localService instanceof JsonRpcMethodProvider) {
JsonRpcMethodProvider rpcMethodProvider = (JsonRpcMethodProvider) localService;
supportedMethods.putAll(rpcMethodProvider.supportedMethods());
} else {
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(localService.getClass()));
}
MessageJsonHandler jsonHandler = new MessageJsonHandler(supportedMethods, configureGson);
MessageConsumer outGoingMessageStream = new StreamMessageConsumer(out, jsonHandler);
outGoingMessageStream = wrapper.apply(outGoingMessageStream);
RemoteEndpoint serverEndpoint = new RemoteEndpoint(outGoingMessageStream, ServiceEndpoints.toEndpoint(localService));
jsonHandler.setMethodProvider(serverEndpoint);
// wrap incoming message stream
MessageConsumer messageConsumer = wrapper.apply(serverEndpoint);
StreamMessageProducer reader = new StreamMessageProducer(in, jsonHandler);
T remoteProxy = ServiceEndpoints.toServiceObject(serverEndpoint, remoteInterface);
return new Launcher<T> () {
@Override
public Future<?> startListening() {
return ConcurrentMessageProcessor.startProcessing(reader, messageConsumer, executorService);
}
@Override
public T getRemoteProxy() {
return remoteProxy;
}
};
}
示例6: initialize
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
@Override
public void initialize(final ILanguageServerAccess access) {
this.access = access;
this.access.addBuildListener(this);
LanguageClient _languageClient = access.getLanguageClient();
this.client = ServiceEndpoints.<TestLangLSPExtension.CustomClient>toServiceObject(((Endpoint) _languageClient), TestLangLSPExtension.CustomClient.class);
}
示例7: createIoLauncher
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
/**
* 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. The {@code configureGson} function can be used
* to register additional type adapters in the {@link GsonBuilder} in order to
* support protocol classes that cannot be handled by Gson's reflective
* capabilities.
*
* @param localService
* - an object on which classes RPC methods are looked up
* @param remoteInterface
* - an interface on which RPC methods are looked up
* @param in
* - inputstream to listen for incoming messages
* @param out
* - outputstream to send outgoing messages
* @param executorService
* - the executor service used to start threads
* @param wrapper
* - a function for plugging in additional message consumers
* @param configureGson
* - a function for Gson configuration
*/
static <T> DebugLauncher<T> createIoLauncher(Object localService, Class<T> remoteInterface, InputStream in,
OutputStream out, ExecutorService executorService, Function<MessageConsumer, MessageConsumer> wrapper,
Consumer<GsonBuilder> configureGson) {
Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<String, JsonRpcMethod>();
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(remoteInterface));
if (localService instanceof JsonRpcMethodProvider) {
JsonRpcMethodProvider rpcMethodProvider = (JsonRpcMethodProvider) localService;
supportedMethods.putAll(rpcMethodProvider.supportedMethods());
} else {
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(localService.getClass()));
}
MessageJsonHandler jsonHandler = new DebugMessageJsonHandler(supportedMethods, configureGson);
MessageConsumer outGoingMessageStream = new StreamMessageConsumer(out, jsonHandler);
outGoingMessageStream = wrapper.apply(outGoingMessageStream);
RemoteEndpoint serverEndpoint = new DebugRemoteEndpoint(outGoingMessageStream,
ServiceEndpoints.toEndpoint(localService));
jsonHandler.setMethodProvider(serverEndpoint);
// wrap incoming message stream
MessageConsumer messageConsumer = wrapper.apply(serverEndpoint);
StreamMessageProducer reader = new StreamMessageProducer(in, jsonHandler);
T remoteProxy = ServiceEndpoints.toServiceObject(serverEndpoint, remoteInterface);
return new DebugLauncher<T>() {
@Override
public Future<?> startListening() {
return ConcurrentMessageProcessor.startProcessing(reader, messageConsumer, executorService);
}
@Override
public T getRemoteProxy() {
return remoteProxy;
}
};
}
示例8: testIssue106
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints; //导入方法依赖的package包/类
@Test public void testIssue106() {
Foo foo = ServiceEndpoints.toServiceObject(new GenericEndpoint(new Object()), Foo.class);
assertEquals(foo, foo);
}