Search in sources :

Example 6 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig in project nutch by apache.

the class NutchClientImpl method createClient.

public void createClient() {
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
    this.client = Client.create(clientConfig);
    this.nutchResource = client.resource(instance.getUrl());
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig)

Example 7 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig 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");
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter) Before(org.junit.Before)

Example 8 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig 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);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DevJerseyClientConfig(org.orcid.util.DevJerseyClientConfig) DevJerseyClientConfig(org.orcid.util.DevJerseyClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig)

Example 9 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig 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;
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) WebResource(com.sun.jersey.api.client.WebResource) ConfigJSONProvider(org.nhindirect.config.providers.ConfigJSONProvider) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client)

Example 10 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig 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);
    }
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) PseudoDelegationTokenAuthenticator(org.apache.hadoop.security.token.delegation.web.PseudoDelegationTokenAuthenticator) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) Client(com.sun.jersey.api.client.Client) KerberosDelegationTokenAuthenticator(org.apache.hadoop.security.token.delegation.web.KerberosDelegationTokenAuthenticator)

Aggregations

ClientConfig (com.sun.jersey.api.client.config.ClientConfig)10 DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)10 Client (com.sun.jersey.api.client.Client)6 URLConnectionClientHandler (com.sun.jersey.client.urlconnection.URLConnectionClientHandler)3 WebResource (com.sun.jersey.api.client.WebResource)2 Before (org.junit.Before)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Singleton (com.google.inject.Singleton)1 GuiceServletContextListener (com.google.inject.servlet.GuiceServletContextListener)1 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)1 JerseyServletModule (com.sun.jersey.guice.JerseyServletModule)1 GuiceContainer (com.sun.jersey.guice.spi.container.servlet.GuiceContainer)1 JettyHttpServerDispatch (com.twitter.common.net.http.JettyHttpServerDispatch)1 FakeClock (com.twitter.common.util.testing.FakeClock)1 HashSet (java.util.HashSet)1 KerberosDelegationTokenAuthenticator (org.apache.hadoop.security.token.delegation.web.KerberosDelegationTokenAuthenticator)1 PseudoDelegationTokenAuthenticator (org.apache.hadoop.security.token.delegation.web.PseudoDelegationTokenAuthenticator)1 ConfigJSONProvider (org.nhindirect.config.providers.ConfigJSONProvider)1 TxJSONProvider (org.nhindirect.monitor.providers.TxJSONProvider)1