Skip to content

Commit

Permalink
Merge pull request #18 from JanssenProject/resteasy_update
Browse files Browse the repository at this point in the history
chore: update resteasy
  • Loading branch information
yuriyz authored Nov 17, 2021
2 parents 4127fba + 4150c15 commit 12d247c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine;

import javax.ws.rs.core.UriBuilder;
import java.util.Base64;
Expand All @@ -32,17 +32,17 @@ public class NotifyClientFactory {

private NotifyClientFactory() {
// Create single connection client
this.client = new ResteasyClientBuilder().build();
this.client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).build();

// Create polled client
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(200); // Increase max total connection to 200
cm.setDefaultMaxPerRoute(20); // Increase default max connection per route to 20

CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine(httpClient);

this.pooledClient = new ResteasyClientBuilder().httpEngine(engine).build();
this.pooledClient = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
}

public static NotifyClientFactory instance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@

package io.jans.notify.client;

import javax.ws.rs.core.UriBuilder;

import org.apache.commons.codec.binary.Base64;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import io.jans.notify.model.NotifyMetadata;
import org.jboss.resteasy.client.ClientExecutor;
import org.jboss.resteasy.client.ProxyFactory;
import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine;
/**
* Helper class which creates proxy
*
Expand All @@ -24,7 +27,8 @@
public class NotifyClientFactory {

private final static NotifyClientFactory instance = new NotifyClientFactory();
private ClientExecutor pooledClientExecutor;

private ApacheHttpClient43Engine engine;

private NotifyClientFactory() {
// Create polled client
Expand All @@ -34,21 +38,28 @@ private NotifyClientFactory() {

CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).setSslcontext(SSLContexts.createSystemDefault()).build();

this.pooledClientExecutor = new ApacheHttpClient4Executor(httpClient);
this.engine = new ApacheHttpClient43Engine(httpClient);
}

public static NotifyClientFactory instance() {
return instance;
}

public NotifyMetadataClientService createMetaDataConfigurationService(String issuer) {
ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
String metadataUri = issuer + "/.well-known/notify-configuration";
return ProxyFactory.create(NotifyMetadataClientService.class, metadataUri, pooledClientExecutor);
}
ResteasyWebTarget target = client.target(UriBuilder.fromPath(metadataUri));

return target.proxy(NotifyMetadataClientService.class);
}

public NotifyClientService createNotifyService(NotifyMetadata notifyMetadata) {
String targetUri = notifyMetadata.getNotifyEndpoint();
return ProxyFactory.create(NotifyClientService.class, targetUri, pooledClientExecutor);
ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();

String targetUri = notifyMetadata.getNotifyEndpoint();
ResteasyWebTarget target = client.target(UriBuilder.fromPath(targetUri));

return target.proxy(NotifyClientService.class);
}

public static String getAuthorization(String accessKeyId, String secretAccessKey) {
Expand Down

0 comments on commit 12d247c

Please sign in to comment.