Search in sources :

Example 1 with ClientConfig

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

the class TestTimelineReaderWebServicesHBaseStorage method createClient.

private static Client createClient() {
    ClientConfig cfg = new DefaultClientConfig();
    cfg.getClasses().add(YarnJacksonJaxbJsonProvider.class);
    return new Client(new URLConnectionClientHandler(new DummyURLConnectionFactory()), cfg);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) 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)

Example 2 with ClientConfig

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

the class TestTimelineReaderWebServices method createClient.

private static Client createClient() {
    ClientConfig cfg = new DefaultClientConfig();
    cfg.getClasses().add(YarnJacksonJaxbJsonProvider.class);
    return new Client(new URLConnectionClientHandler(new DummyURLConnectionFactory()), cfg);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) 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)

Example 3 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig in project commons by twitter.

the class HttpStatsFilterIntegrationTest method setUp.

@Before
public void setUp() {
    Stats.flush();
    server = new JettyHttpServerDispatch();
    server.listen(0);
    server.registerFilter(GuiceFilter.class, "/*");
    clock = new FakeClock();
    final Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(TestServlet.class).in(Singleton.class);
            bind(Clock.class).toInstance(clock);
            bind(HttpStatsFilter.class).in(Singleton.class);
        }
    }, new JerseyServletModule() {

        @Override
        protected void configureServlets() {
            filter("/*").through(HttpStatsFilter.class);
            serve("/*").with(GuiceContainer.class, ImmutableMap.of(PROPERTY_CONTAINER_RESPONSE_FILTERS, HttpStatsFilter.class.getName()));
        }
    });
    server.getRootContext().addEventListener(new GuiceServletContextListener() {

        @Override
        protected Injector getInjector() {
            return injector;
        }
    });
    ClientConfig config = new DefaultClientConfig();
    client = Client.create(config);
}
Also used : JettyHttpServerDispatch(com.twitter.common.net.http.JettyHttpServerDispatch) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) FakeClock(com.twitter.common.util.testing.FakeClock) Injector(com.google.inject.Injector) Singleton(com.google.inject.Singleton) JerseyServletModule(com.sun.jersey.guice.JerseyServletModule) GuiceContainer(com.sun.jersey.guice.spi.container.servlet.GuiceContainer) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) GuiceServletContextListener(com.google.inject.servlet.GuiceServletContextListener) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Example 4 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig in project nhin-d by DirectProject.

the class TestUtils method getResource.

public static WebResource getResource(String serviceURL) {
    final ClientConfig config = new DefaultClientConfig();
    config.getSingletons().add(new TxJSONProvider());
    // 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) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client) TxJSONProvider(org.nhindirect.monitor.providers.TxJSONProvider)

Example 5 with ClientConfig

use of com.sun.jersey.api.client.config.ClientConfig in project ORCID-Source by ORCID.

the class CrossRefManagerImpl method createClient.

private Client createClient() {
    Set<Class<?>> providers = new HashSet<Class<?>>();
    providers.add(JacksonJsonProvider.class);
    ClientConfig config = new DefaultClientConfig(providers);
    config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    Client client = ApacheHttpClient4.create(config);
    client.setFollowRedirects(true);
    client.addFilter(new ContentTypeFromTextToJsonClientFilter());
    return client;
}
Also used : ContentTypeFromTextToJsonClientFilter(org.orcid.core.utils.ContentTypeFromTextToJsonClientFilter) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client) HashSet(java.util.HashSet)

Aggregations

ClientConfig (com.sun.jersey.api.client.config.ClientConfig)9 DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)9 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