微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer的实例源码

项目:dsp4e    文件DebugLauncher.java   
/**
 * 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;
        }

    };
}
项目:SOMns-vscode    文件Launcher.java   
/**
 * 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,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,remoteInterface);

    return new Launcher<T> () {

        @Override
        public Future<?> startListening() {
            return ConcurrentMessageProcessor.startProcessing(reader,executorService);
        }

        @Override
        public T getRemoteProxy() {
            return remoteProxy;
        }

    };
}
项目:lsp4j    文件DebugLauncher.java   
/**
 * 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,jsonHandler);
    outGoingMessageStream = wrapper.apply(outGoingMessageStream);
    RemoteEndpoint serverEndpoint = new DebugRemoteEndpoint(outGoingMessageStream,remoteInterface);

    return new DebugLauncher<T>() {

        @Override
        public Future<?> startListening() {
            return ConcurrentMessageProcessor.startProcessing(reader,executorService);
        }

        @Override
        public T getRemoteProxy() {
            return remoteProxy;
        }

    };
}
项目:lsp4j    文件Launcher.java   
/**
 * Create a new Launcher for a given local service object,executorService);
        }

        @Override
        public T getRemoteProxy() {
            return remoteProxy;
        }

    };
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。