Search in sources :

Example 51 with ResteasyWebTarget

use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project motan by weibocom.

the class AbstractEndpointFactory method createClient.

@Override
public ResteasyWebTarget createClient(URL url) {
    String ipPort = url.getServerPortStr();
    String protocolKey = MotanFrameworkUtil.getProtocolKey(url);
    LoggerUtil.info(this.getClass().getSimpleName() + " create share_channel client: url={}", url);
    synchronized (ipPort2ClientShareChannel) {
        ResteasyWebTarget client = ipPort2ClientShareChannel.get(ipPort);
        if (client != null) {
            saveEndpoint2Urls(client2UrlsShareChannel, client, protocolKey);
            return client;
        }
        client = innerCreateClient(url);
        ipPort2ClientShareChannel.put(ipPort, client);
        saveEndpoint2Urls(client2UrlsShareChannel, client, protocolKey);
        return client;
    }
}
Also used : ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Example 52 with ResteasyWebTarget

use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project oxAuth by GluuFederation.

the class Utils method post.

public static String post(String endpoint, String payload) throws HttpException {
    String data = null;
    try {
        ResteasyWebTarget target = rsClient.target(endpoint);
        logger.info("Sending payload to {}", endpoint);
        logger.debug("{}", payload);
        Response response = target.request().post(Entity.json(payload));
        response.bufferEntity();
        int status = response.getStatus();
        data = response.readEntity(String.class);
        logger.debug("Response code was {} and body:\n{}", status, data);
        if (status == 200) {
            return data;
        } else {
            throw new HttpException(status, "Unsuccessful response obtained", data);
        }
    } catch (Exception e) {
        throw new HttpException(e.getMessage(), e.getCause(), data);
    }
}
Also used : Response(javax.ws.rs.core.Response) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException)

Example 53 with ResteasyWebTarget

use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project oxAuth by GluuFederation.

the class FidoU2fClientFactory method createMetaDataConfigurationService.

public U2fConfigurationService createMetaDataConfigurationService(String u2fMetaDataUri) {
    ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
    ResteasyWebTarget target = client.target(UriBuilder.fromPath(u2fMetaDataUri));
    U2fConfigurationService proxy = target.proxy(U2fConfigurationService.class);
    return proxy;
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Example 54 with ResteasyWebTarget

use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project oxAuth by GluuFederation.

the class UmaClientFactory method createRptStatusService.

public UmaRptIntrospectionService createRptStatusService(UmaMetadata metadata, ClientHttpEngine engine) {
    ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
    ResteasyWebTarget target = client.target(UriBuilder.fromPath(metadata.getIntrospectionEndpoint()));
    UmaRptIntrospectionService proxy = target.proxy(UmaRptIntrospectionService.class);
    return proxy;
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Example 55 with ResteasyWebTarget

use of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget in project oxAuth by GluuFederation.

the class UmaClientFactory method createResourceService.

public UmaResourceService createResourceService(UmaMetadata metadata, ClientHttpEngine engine) {
    ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
    ResteasyWebTarget target = client.target(UriBuilder.fromPath(metadata.getResourceRegistrationEndpoint()));
    UmaResourceService proxy = target.proxy(UmaResourceService.class);
    return proxy;
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)

Aggregations

ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)59 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)42 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)20 Response (javax.ws.rs.core.Response)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)10 Test (org.junit.Test)9 WebTarget (javax.ws.rs.client.WebTarget)8 Client (javax.ws.rs.client.Client)7 ServicesInterface (com.baeldung.client.ServicesInterface)6 IOException (java.io.IOException)6 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)5 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)5 TimeUnit (java.util.concurrent.TimeUnit)4 Invocation (javax.ws.rs.client.Invocation)4 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)4 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Locale (java.util.Locale)3 Map (java.util.Map)3