All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.vespa.config.server.rpc.RpcRequestHandlerProvider Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.rpc;

import com.yahoo.component.annotation.Inject;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.config.server.RequestHandler;
import com.yahoo.vespa.config.server.rpc.security.DefaultRpcAuthorizerProvider;
import com.yahoo.vespa.config.server.tenant.TenantRepository;

import java.util.Optional;

/**
 * This is a hack to avoid a cyclic dependency involving {@link RpcServer}, {@link DefaultRpcAuthorizerProvider} and {@link TenantRepository}.
 *
 * @author bjorncs
 */
public class RpcRequestHandlerProvider implements RequestHandlerProvider {

    private volatile RpcServer instance;

    @Inject
    public RpcRequestHandlerProvider() {}

    @Override
    public Optional getRequestHandler(TenantName tenantName) {
        if (instance == null) {
            throw new IllegalStateException("RpcServer instance has not been registered");
        }
        return instance.getRequestHandler(tenantName);
    }

    void setInstance(RpcServer instance) {
        this.instance = instance;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy