mirror of https://github.com/grpc/grpc-java.git
core: make InternalHandlerRegistry a HandlerRegistry
This commit is contained in:
parent
b2dd6ae7f0
commit
39d2dd0eaa
|
|
@ -65,8 +65,9 @@ public abstract class AbstractServerImplBuilder<T extends AbstractServerImplBuil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerMethodDefinition<?, ?> lookupMethod(String methodName,
|
@Nullable
|
||||||
@Nullable String authority) {
|
public ServerMethodDefinition<?, ?> lookupMethod(
|
||||||
|
String methodName, @Nullable String authority) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package io.grpc.internal;
|
package io.grpc.internal;
|
||||||
|
|
||||||
|
import io.grpc.HandlerRegistry;
|
||||||
import io.grpc.ServerMethodDefinition;
|
import io.grpc.ServerMethodDefinition;
|
||||||
import io.grpc.ServerServiceDefinition;
|
import io.grpc.ServerServiceDefinition;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -26,7 +27,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
final class InternalHandlerRegistry {
|
final class InternalHandlerRegistry extends HandlerRegistry {
|
||||||
|
|
||||||
private final List<ServerServiceDefinition> services;
|
private final List<ServerServiceDefinition> services;
|
||||||
private final Map<String, ServerMethodDefinition<?, ?>> methods;
|
private final Map<String, ServerMethodDefinition<?, ?>> methods;
|
||||||
|
|
@ -40,16 +41,19 @@ final class InternalHandlerRegistry {
|
||||||
/**
|
/**
|
||||||
* Returns the service definitions in this registry.
|
* Returns the service definitions in this registry.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<ServerServiceDefinition> getServices() {
|
public List<ServerServiceDefinition> getServices() {
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
ServerMethodDefinition<?, ?> lookupMethod(String methodName) {
|
@Override
|
||||||
|
public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
|
||||||
|
// TODO (carl-mastrangelo): honor authority header.
|
||||||
return methods.get(methodName);
|
return methods.get(methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Builder {
|
static final class Builder {
|
||||||
|
|
||||||
// Store per-service first, to make sure services are added/replaced atomically.
|
// Store per-service first, to make sure services are added/replaced atomically.
|
||||||
private final HashMap<String, ServerServiceDefinition> services =
|
private final HashMap<String, ServerServiceDefinition> services =
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public final class ServerImpl extends io.grpc.Server implements Instrumented<Ser
|
||||||
private final ObjectPool<? extends Executor> executorPool;
|
private final ObjectPool<? extends Executor> executorPool;
|
||||||
/** Executor for application processing. Safe to read after {@link #start()}. */
|
/** Executor for application processing. Safe to read after {@link #start()}. */
|
||||||
private Executor executor;
|
private Executor executor;
|
||||||
private final InternalHandlerRegistry registry;
|
private final HandlerRegistry registry;
|
||||||
private final HandlerRegistry fallbackRegistry;
|
private final HandlerRegistry fallbackRegistry;
|
||||||
private final List<ServerTransportFilter> transportFilters;
|
private final List<ServerTransportFilter> transportFilters;
|
||||||
// This is iterated on a per-call basis. Use an array instead of a Collection to avoid iterator
|
// This is iterated on a per-call basis. Use an array instead of a Collection to avoid iterator
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue