Search in sources :

Example 1 with ClientContext

use of org.jboss.resteasy.reactive.client.spi.ClientContext in project quarkus by quarkusio.

the class RestClientsContainer method getClientData.

/**
 * Used in Dev UI
 *
 * @return info about exposed clients
 */
public RestClientData getClientData() {
    ClientContext context = CLIENT_CONTEXT_RESOLVER.resolve(Thread.currentThread().getContextClassLoader());
    ClientProxies.ClientData clientData = context.getClientProxies().getClientData();
    List<RestClientInfo> restClients = new ArrayList<>();
    List<PossibleRestClientInfo> possibleRestClients = new ArrayList<>();
    for (Class<?> clientClass : clientData.clientClasses) {
        Instance<?> select = injectableClients.select(clientClass);
        String interfaceName = clientClass.getName();
        if (select.isResolvable()) {
            String configKey = RestClientRecorder.getConfigKeys().get(interfaceName);
            if (configKey == null) {
                configKey = String.format("\"%s\"", interfaceName);
            }
            restClients.add(new RestClientInfo(interfaceName, true, configKey));
        } else {
            restClients.add(new RestClientInfo(interfaceName, false, null));
        }
    }
    restClients.sort(Comparator.comparing(info -> info.interfaceClass));
    for (Map.Entry<Class<?>, String> clientEntry : clientData.failures.entrySet()) {
        possibleRestClients.add(new PossibleRestClientInfo(clientEntry.getKey().getName(), clientEntry.getValue()));
    }
    possibleRestClients.sort(Comparator.comparing(info -> info.interfaceClass));
    return new RestClientData(restClients, possibleRestClients);
}
Also used : ClientProxies(org.jboss.resteasy.reactive.client.impl.ClientProxies) RestClient(org.eclipse.microprofile.rest.client.inject.RestClient) ClientContextResolver(org.jboss.resteasy.reactive.client.spi.ClientContextResolver) RestClientRecorder(io.quarkus.rest.client.reactive.runtime.RestClientRecorder) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) List(java.util.List) Unremovable(io.quarkus.arc.Unremovable) IfBuildProfile(io.quarkus.arc.profile.IfBuildProfile) Map(java.util.Map) Comparator(java.util.Comparator) ClientContext(org.jboss.resteasy.reactive.client.spi.ClientContext) Instance(javax.enterprise.inject.Instance) ClientProxies(org.jboss.resteasy.reactive.client.impl.ClientProxies) ClientContext(org.jboss.resteasy.reactive.client.spi.ClientContext) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

Unremovable (io.quarkus.arc.Unremovable)1 IfBuildProfile (io.quarkus.arc.profile.IfBuildProfile)1 RestClientRecorder (io.quarkus.rest.client.reactive.runtime.RestClientRecorder)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Instance (javax.enterprise.inject.Instance)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 RestClient (org.eclipse.microprofile.rest.client.inject.RestClient)1 ClientProxies (org.jboss.resteasy.reactive.client.impl.ClientProxies)1 ClientContext (org.jboss.resteasy.reactive.client.spi.ClientContext)1 ClientContextResolver (org.jboss.resteasy.reactive.client.spi.ClientContextResolver)1