io.quarkus.grpc.runtime.devmode.DevModeInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-grpc Show documentation
Show all versions of quarkus-grpc Show documentation
Serve and consume gRPC services
package io.quarkus.grpc.runtime.devmode;
import io.grpc.Metadata;
import io.grpc.ServerCall;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
public class DevModeInterceptor implements ServerInterceptor {
private final ClassLoader classLoader;
public DevModeInterceptor(ClassLoader contextClassLoader) {
classLoader = contextClassLoader;
}
@Override
public ServerCall.Listener interceptCall(ServerCall serverCall, Metadata metadata,
ServerCallHandler next) {
ClassLoader originalTccl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
return next.startCall(serverCall, metadata);
} finally {
Thread.currentThread().setContextClassLoader(originalTccl);
}
}
}