org.bcos.web3j.protocol.ipc.IpcService Maven / Gradle / Ivy
package org.bcos.web3j.protocol.ipc;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.bcos.web3j.protocol.Service;
import org.bcos.web3j.protocol.core.Request;
import org.bcos.web3j.protocol.core.Response;
/**
* Ipc service implementation.
*/
public class IpcService extends Service {
private static final Log log = LogFactory.getLog(IpcService.class);
private final IOFacade ioFacade;
public IpcService(IOFacade ioFacade, boolean includeRawResponses) {
super(includeRawResponses);
this.ioFacade = ioFacade;
}
public IpcService(IOFacade ioFacade) {
this(ioFacade, false);
}
@Override
public T send(Request request, Class responseType) throws IOException {
String payload = objectMapper.writeValueAsString(request);
ioFacade.write(payload);
log.debug(">> " + payload);
String result = ioFacade.read();
log.debug("<< " + result);
return objectMapper.readValue(result, responseType);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy