use of com.sun.jersey.api.client.config.DefaultClientConfig in project coprhd-controller by CoprHD.
the class GlanceApiFactory method getApi.
/**
* Return Glance API client, create if not present
*
* @param provider Storage Provider URI
* @return
*/
public GlanceApi getApi(URI provider, GlanceEndPointInfo endPoint) {
boolean isNew = false;
GlanceApi glanceApi = _clientMap.get(provider.toString());
if (glanceApi == null) {
isNew = true;
ClientConfig config = new DefaultClientConfig();
Client jerseyClient = Client.create(config);
glanceApi = new GlanceApi(endPoint, jerseyClient);
_clientMap.putIfAbsent(provider.toString(), glanceApi);
}
if (!isNew) {
// Token gets expired, if the instance is not new refresh it.
glanceApi.getClient().setAuthTokenHeader(endPoint.getGlanceToken());
}
return glanceApi;
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project opennms by OpenNMS.
the class RestClientTest method setUp.
@Before
public void setUp() {
ClientConfig config = new DefaultClientConfig();
m_client = Client.create(config);
m_client.addFilter(new HTTPBasicAuthFilter("demo", "demo"));
m_resource = m_client.resource("http://demo.opennms.org/opennms/rest/alarms");
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project ORCID-Source by ORCID.
the class OrcidJerseyClientHandler method create.
public static Client create(boolean isDevelopmentMode, Map<String, Object> properties) {
ClientConfig config = null;
if (isDevelopmentMode) {
// DANGER!!! Trust all certs
LOGGER.info("TRUSTING ALL SSL CERTS IN DEV MODE!!!");
config = new DevJerseyClientConfig();
} else {
config = new DefaultClientConfig();
}
Set<String> keyset = properties.keySet();
for (String key : keyset) {
config.getProperties().put(key, properties.get(key));
}
config.getClasses().add(JacksonJaxbJsonProvider.class);
return Client.create(config);
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project nhin-d by DirectProject.
the class BaseTestPlan method getResource.
public static WebResource getResource(String serviceURL) {
final ClientConfig config = new DefaultClientConfig();
config.getSingletons().add(new ConfigJSONProvider());
// need to set timeouts so we don't block forever in the event of a bad URL or hung web server
config.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, CONNECTION_TIMEOUT);
config.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, READ_TIMEOUT);
final Client client = Client.create(config);
WebResource resource = client.resource(serviceURL);
return resource;
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project hadoop by apache.
the class TimelineConnector method serviceInit.
@Override
protected void serviceInit(Configuration conf) throws Exception {
super.serviceInit(conf);
ClientConfig cc = new DefaultClientConfig();
cc.getClasses().add(YarnJacksonJaxbJsonProvider.class);
sslFactory = getSSLFactory(conf);
connConfigurator = getConnConfigurator(sslFactory);
if (UserGroupInformation.isSecurityEnabled()) {
authenticator = new KerberosDelegationTokenAuthenticator();
} else {
authenticator = new PseudoDelegationTokenAuthenticator();
}
authenticator.setConnectionConfigurator(connConfigurator);
connectionRetry = new TimelineClientConnectionRetry(conf);
client = new Client(new URLConnectionClientHandler(new TimelineURLConnectionFactory(authUgi, authenticator, connConfigurator, token, doAsUser)), cc);
if (requireConnectionRetry) {
TimelineJerseyRetryFilter retryFilter = new TimelineJerseyRetryFilter(connectionRetry);
client.addFilter(retryFilter);
}
}
Aggregations