Java 类io.grpc.ServerTransportFilter 实例源码

项目:grpc-java    文件:ServerImpl.java   
/**
 * Construct a server.
 *
 * @param builder builder with configuration for server
 * @param transportServer transport server that will create new incoming transports
 * @param rootContext context that callbacks for new RPCs should be derived from
 */
ServerImpl(
    AbstractServerImplBuilder<?> builder,
    InternalServer transportServer,
    Context rootContext) {
  this.executorPool = Preconditions.checkNotNull(builder.executorPool, "executorPool");
  this.registry = Preconditions.checkNotNull(builder.registryBuilder.build(), "registryBuilder");
  this.fallbackRegistry =
      Preconditions.checkNotNull(builder.fallbackRegistry, "fallbackRegistry");
  this.transportServer = Preconditions.checkNotNull(transportServer, "transportServer");
  // Fork from the passed in context so that it does not propagate cancellation, it only
  // inherits values.
  this.rootContext = Preconditions.checkNotNull(rootContext, "rootContext").fork();
  this.decompressorRegistry = builder.decompressorRegistry;
  this.compressorRegistry = builder.compressorRegistry;
  this.transportFilters = Collections.unmodifiableList(
      new ArrayList<ServerTransportFilter>(builder.transportFilters));
  this.interceptors =
      builder.interceptors.toArray(new ServerInterceptor[builder.interceptors.size()]);
  this.handshakeTimeoutMillis = builder.handshakeTimeoutMillis;
}
项目:grpc-java    文件:ServerImpl.java   
@Override
public Attributes transportReady(Attributes attributes) {
  handshakeTimeoutFuture.cancel(false);
  handshakeTimeoutFuture = null;

  for (ServerTransportFilter filter : transportFilters) {
    attributes = Preconditions.checkNotNull(filter.transportReady(attributes),
        "Filter %s returned null", filter);
  }
  this.attributes = attributes;
  return attributes;
}
项目:grpc-java    文件:ServerImpl.java   
@Override
public void transportTerminated() {
  if (handshakeTimeoutFuture != null) {
    handshakeTimeoutFuture.cancel(false);
    handshakeTimeoutFuture = null;
  }
  for (ServerTransportFilter filter : transportFilters) {
    filter.transportTerminated(attributes);
  }
  transportClosed(transport);
}
项目:dropwizard-grpc    文件:DropwizardServerBuilder.java   
@Override
public DropwizardServerBuilder addTransportFilter(final ServerTransportFilter filter) {
    origin.addTransportFilter(filter);
    return this;
}
项目:grpc-java    文件:AbstractServerImplBuilder.java   
@Override
public final T addTransportFilter(ServerTransportFilter filter) {
  transportFilters.add(checkNotNull(filter, "filter"));
  return thisT();
}