use of org.projectnessie.client.NessieClientBuilder in project nessie by projectnessie.
the class GCUtil method getApi.
/**
* Builds the client builder; default({@link HttpClientBuilder}) or custom, based on the
* configuration provided.
*
* @param configuration map of client builder configurations.
* @return {@link NessieApiV1} object.
*/
static NessieApiV1 getApi(Map<String, String> configuration) {
String clientBuilderClassName = configuration.get(NessieConfigConstants.CONF_NESSIE_CLIENT_BUILDER_IMPL);
NessieClientBuilder builder;
if (clientBuilderClassName == null) {
// Use the default HttpClientBuilder
builder = HttpClientBuilder.builder();
} else {
// Use the custom client builder
try {
builder = (NessieClientBuilder) Class.forName(clientBuilderClassName).getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(String.format("No custom client builder class found for '%s' ", clientBuilderClassName));
} catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
throw new IllegalArgumentException(String.format("Could not initialize '%s': ", clientBuilderClassName), e);
}
}
return (NessieApiV1) builder.fromConfig(configuration::get).build(NessieApiV1.class);
}
Aggregations