當前位置: 首頁>>代碼示例>>Java>>正文


Java ConcurrentMessageProcessor類代碼示例

本文整理匯總了Java中org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor的典型用法代碼示例。如果您正苦於以下問題:Java ConcurrentMessageProcessor類的具體用法?Java ConcurrentMessageProcessor怎麽用?Java ConcurrentMessageProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConcurrentMessageProcessor類屬於org.eclipse.lsp4j.jsonrpc.json包,在下文中一共展示了ConcurrentMessageProcessor類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIoLauncher

import org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor; //導入依賴的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;
		}
		
	};
}
 
開發者ID:tracymiranda,項目名稱:dsp4e,代碼行數:53,代碼來源:DebugLauncher.java

示例2: createIoLauncher

import org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor; //導入依賴的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;
		}
		
	};
}
 
開發者ID:smarr,項目名稱:SOMns-vscode,代碼行數:53,代碼來源:Launcher.java

示例3: createIoLauncher

import org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor; //導入依賴的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;
		}

	};
}
 
開發者ID:eclipse,項目名稱:lsp4j,代碼行數:65,代碼來源:DebugLauncher.java


注:本文中的org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。