use of org.jboss.resteasy.client.jaxrs.internal.LocalResteasyProviderFactory in project java by wavefrontHQ.
the class APIContainer method createProviderFactory.
private ResteasyProviderFactory createProviderFactory() {
ResteasyProviderFactory factory = new LocalResteasyProviderFactory(ResteasyProviderFactory.getInstance());
factory.registerProvider(JsonNodeWriter.class);
if (!factory.getClasses().contains(ResteasyJackson2Provider.class)) {
factory.registerProvider(ResteasyJackson2Provider.class);
}
factory.register(GZIPDecodingInterceptor.class);
if (proxyConfig.isGzipCompression()) {
WriterInterceptor interceptor = new GZIPEncodingInterceptorWithVariableCompression(proxyConfig.getGzipCompressionLevel());
factory.register(interceptor);
} else {
factory.register(DisableGZIPEncodingInterceptor.class);
}
factory.register(AcceptEncodingGZIPFilter.class);
// add authorization header for all proxy endpoints, except for /checkin - since it's also
// passed as a parameter, it's creating duplicate headers that cause the entire request to be
// rejected by nginx. unfortunately, RESTeasy is not smart enough to handle that automatically.
factory.register((ClientRequestFilter) context -> {
if ((context.getUri().getPath().contains("/v2/wfproxy") || context.getUri().getPath().contains("/v2/source") || context.getUri().getPath().contains("/event")) && !context.getUri().getPath().endsWith("checkin")) {
context.getHeaders().add("Authorization", "Bearer " + proxyConfig.getToken());
}
});
return factory;
}
use of org.jboss.resteasy.client.jaxrs.internal.LocalResteasyProviderFactory in project syndesis by syndesisio.
the class ExternalVerifierService method verify.
@Override
public List<Result> verify(String connectorId, Map<String, String> options) {
final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
resteasyJacksonProvider.setMapper(MAPPER);
final ResteasyProviderFactory providerFactory = ResteasyProviderFactory.newInstance();
providerFactory.register(resteasyJacksonProvider);
final Configuration configuration = new LocalResteasyProviderFactory(providerFactory);
Client client = ClientBuilder.newClient(configuration);
WebTarget target = client.target(String.format("http://%s/api/v1/verifier/%s", config.getService(), connectorId));
return target.request(MediaType.APPLICATION_JSON).post(Entity.entity(options, MediaType.APPLICATION_JSON), new GenericType<List<Result>>() {
});
}
use of org.jboss.resteasy.client.jaxrs.internal.LocalResteasyProviderFactory in project syndesis by syndesisio.
the class HttpClient method createClient.
/* default */
private Client createClient() {
final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
resteasyJacksonProvider.setMapper(MAPPER);
final ResteasyProviderFactory providerFactory = ResteasyProviderFactory.newInstance();
providerFactory.register(resteasyJacksonProvider);
final Configuration configuration = new LocalResteasyProviderFactory(providerFactory);
return ClientBuilder.newClient(configuration);
}
use of org.jboss.resteasy.client.jaxrs.internal.LocalResteasyProviderFactory in project syndesis-qe by syndesisio.
the class EndpointClient method getClient.
public static Client getClient(ResteasyJackson2Provider jackson2Provider) {
final ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine(createAllTrustingClient());
final ResteasyProviderFactory providerFactory = new LocalResteasyProviderFactory();
providerFactory.register(jackson2Provider).register(// needed for GET application/octet-stream in PublicAPI to export zip
new InputStreamProvider()).register(// needed to POST mutipart form data (necessary for API provider + PublicAPI)
new MultipartFormDataWriter()).register(// needed to serialize text/plain (again for API provider)
new StringTextStar()).register(new ErrorLogger());
ResteasyClientBuilder clientBuilder = (ResteasyClientBuilder) ResteasyClientBuilder.newBuilder();
clientBuilder.providerFactory(providerFactory);
clientBuilder.httpEngine(engine);
return clientBuilder.build();
}
Aggregations