45 lines
1.8 KiB
Java
45 lines
1.8 KiB
Java
package io.grpc.util;
|
|
|
|
import io.grpc.BindableService;
|
|
import io.grpc.HandlerRegistry;
|
|
import io.grpc.MethodDescriptor;
|
|
import io.grpc.ServerMethodDefinition;
|
|
import io.grpc.ServerServiceDefinition;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentMap;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class MutableHandlerRegistry extends HandlerRegistry {
|
|
private final ConcurrentMap<String, ServerServiceDefinition> services = new ConcurrentHashMap();
|
|
|
|
public final ServerServiceDefinition addService(ServerServiceDefinition serverServiceDefinition) {
|
|
return this.services.put(serverServiceDefinition.getServiceDescriptor().getName(), serverServiceDefinition);
|
|
}
|
|
|
|
public final ServerServiceDefinition addService(BindableService bindableService) {
|
|
return addService(bindableService.bindService());
|
|
}
|
|
|
|
public final boolean removeService(ServerServiceDefinition serverServiceDefinition) {
|
|
return this.services.remove(serverServiceDefinition.getServiceDescriptor().getName(), serverServiceDefinition);
|
|
}
|
|
|
|
@Override // io.grpc.HandlerRegistry
|
|
public final List<ServerServiceDefinition> getServices() {
|
|
return Collections.unmodifiableList(new ArrayList(this.services.values()));
|
|
}
|
|
|
|
@Override // io.grpc.HandlerRegistry
|
|
public final ServerMethodDefinition<?, ?> lookupMethod(String str, String str2) {
|
|
ServerServiceDefinition serverServiceDefinition;
|
|
String extractFullServiceName = MethodDescriptor.extractFullServiceName(str);
|
|
if (extractFullServiceName == null || (serverServiceDefinition = this.services.get(extractFullServiceName)) == null) {
|
|
return null;
|
|
}
|
|
return serverServiceDefinition.getMethod(str);
|
|
}
|
|
}
|