/******************************************************************************* * Copyright (c) 2012-2017 Codenvy, S.A. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ package org.eclipse.che.api.core.jsonrpc.commons.transmission; import org.eclipse.che.api.core.jsonrpc.commons.JsonRpcErrorTransmitter; import org.eclipse.che.api.core.jsonrpc.commons.JsonRpcMarshaller; import org.eclipse.che.api.core.jsonrpc.commons.ResponseDispatcher; import org.eclipse.che.api.core.websocket.commons.WebSocketMessageTransmitter; import org.slf4j.Logger; import javax.inject.Inject; import java.util.concurrent.atomic.AtomicInteger; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static org.slf4j.LoggerFactory.getLogger; /** * Method name configurator to defined method name that the request * will have. */ public class MethodNameConfigurator { private final static Logger LOGGER = getLogger(MethodNameConfigurator.class); public static AtomicInteger id = new AtomicInteger(0); private final JsonRpcMarshaller marshaller; private final ResponseDispatcher dispatcher; private final WebSocketMessageTransmitter transmitter; private final String endpointId; @Inject MethodNameConfigurator(JsonRpcMarshaller marshaller, ResponseDispatcher dispatcher, WebSocketMessageTransmitter transmitter, String endpointId) { this.marshaller = marshaller; this.dispatcher = dispatcher; this.transmitter = transmitter; this.endpointId = endpointId; } public ParamsConfigurator methodName(String name) { checkNotNull(name, "Method name must not be null"); checkArgument(!name.isEmpty(), "Method name must not be empty"); LOGGER.debug("Configuring outgoing request method name name: " + name); return new ParamsConfigurator(marshaller, dispatcher, transmitter, name, endpointId); } }