org.hertsstack.rpcclient.HertsRpcClientCStreamingMethodHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of herts-rpc-client Show documentation
Show all versions of herts-rpc-client Show documentation
Herts real time framework for RpcClient
The newest version!
package org.hertsstack.rpcclient;
import org.hertsstack.core.context.HertsType;
import org.hertsstack.core.descriptor.CustomGrpcDescriptor;
import org.hertsstack.core.exception.ServiceNotFoundException;
import org.hertsstack.core.exception.StreamBodyException;
import org.hertsstack.core.service.HertsService;
import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.MethodDescriptor;
import io.grpc.stub.ClientCalls;
import io.grpc.stub.StreamObserver;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Herts rpc client handler
* Client streaming Method Handler
*
* @author Herts Contributer
*/
class HertsRpcClientCStreamingMethodHandler extends io.grpc.stub.AbstractBlockingStub implements InvocationHandler {
private final Map> methodTypes = new HashMap<>();
private final ConcurrentMap> descriptors = new ConcurrentHashMap<>();
private final Class> hertsRpcService;
private final String serviceName;
public HertsRpcClientCStreamingMethodHandler(Channel channel, CallOptions callOptions, Class> hertsRpcService) {
super(channel, callOptions);
this.hertsRpcService = hertsRpcService;
this.serviceName = hertsRpcService.getName();
Class> hertsServiceClass;
try {
hertsServiceClass = Class.forName(this.serviceName);
} catch (ClassNotFoundException ignore) {
throw new ServiceNotFoundException("Unknown class name. Allowed class is " + HertsService.class.getName());
}
Method[] methods = hertsServiceClass.getDeclaredMethods();
for (Method method : methods) {
methodTypes.put(method.getName(), method.getReturnType());
}
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
String methodName = method.getName();
MethodDescriptor
© 2015 - 2025 Weber Informatics LLC | Privacy Policy