All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fisco.bcos.web3j.protocol.Service Maven / Gradle / Ivy

There is a newer version: 2.6.6
Show newest version
package org.fisco.bcos.web3j.protocol;

import java.util.concurrent.CompletableFuture;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.reactivex.Flowable;
import org.fisco.bcos.web3j.protocol.core.Request;
import org.fisco.bcos.web3j.protocol.core.Response;
import org.fisco.bcos.web3j.protocol.websocket.events.Notification;
import org.fisco.bcos.web3j.utils.Async;

/**
 * Base service implementation.
 */
public abstract class Service implements Web3jService {

    protected final ObjectMapper objectMapper;

    public Service(boolean includeRawResponses) {
        objectMapper = ObjectMapperFactory.getObjectMapper(includeRawResponses);
    }

    @Override
    public  CompletableFuture sendAsync(
            Request jsonRpc20Request, Class responseType) {
        return Async.run(() -> send(jsonRpc20Request, responseType));
    }
    @Override
    public > Flowable subscribe(
            Request request,
            String unsubscribeMethod,
            Class responseType) {
        throw new UnsupportedOperationException(
                String.format(
                        "Service %s does not support subscriptions",
                        this.getClass().getSimpleName()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy