org.glassfish.jersey.client.ClientConfig Java Examples
The following examples show how to use
org.glassfish.jersey.client.ClientConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TlsToolkitGetStatus.java From nifi with Apache License 2.0 | 7 votes |
public void get(final GetStatusConfig config) { final SSLContext sslContext = config.getSslContext(); final ClientBuilder clientBuilder = ClientBuilder.newBuilder(); if (sslContext != null) { clientBuilder.sslContext(sslContext); } final ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 10000); clientConfig.property(ClientProperties.READ_TIMEOUT, 10000); clientBuilder.withConfig(clientConfig); final Client client = clientBuilder.build(); final WebTarget target = client.target(config.getUrl()); final Response response = target.request().get(); System.out.println("Response Code - " + response.getStatus()); }
Example #2
Source File: DockerClient.java From rapid with MIT License | 6 votes |
private void init() { final URI originalUri = URI.create(DEFAULT_UNIX_ENDPOINT); sanitizeUri = UnixFactory.sanitizeUri(originalUri); final RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.<ConnectionSocketFactory>create() .register("https", SSLConnectionSocketFactory.getSocketFactory()) .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("unix", new UnixFactory(originalUri)); final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registryBuilder.build()); final RequestConfig requestConfig = RequestConfig.custom() .setConnectionRequestTimeout((int) SECONDS.toMillis(5)) .setConnectTimeout((int) SECONDS.toMillis(5)) .setSocketTimeout((int) SECONDS.toMillis(30)) .build(); final ClientConfig config = new ClientConfig() .connectorProvider(new ApacheConnectorProvider()) .property(ApacheClientProperties.CONNECTION_MANAGER, cm) .property(ApacheClientProperties.REQUEST_CONFIG, requestConfig); client = ClientBuilder.newBuilder().withConfig(config).build(); }
Example #3
Source File: ParaClient.java From para with Apache License 2.0 | 6 votes |
/** * Default constructor. * @param accessKey app access key * @param secretKey app secret key */ public ParaClient(String accessKey, String secretKey) { this.accessKey = accessKey; this.secretKey = secretKey; if (StringUtils.length(secretKey) < 6) { logger.warn("Secret key appears to be invalid. Make sure you call 'signIn()' first."); } this.throwExceptionOnHTTPError = false; ObjectMapper mapper = ParaObjectUtils.getJsonMapper(); mapper.setSerializationInclusion(JsonInclude.Include.USE_DEFAULTS); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(GenericExceptionMapper.class); clientConfig.register(new JacksonJsonProvider(mapper)); clientConfig.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround()); SSLContext sslContext = SslConfigurator.newInstance().createSSLContext(); apiClient = ClientBuilder.newBuilder(). sslContext(sslContext). withConfig(clientConfig).build(); }
Example #4
Source File: RestDemoServiceIT.java From demo-restWS-spring-jersey-tomcat-mybatis with MIT License | 6 votes |
@Test public void testGetPodcast() throws JsonGenerationException, JsonMappingException, IOException { ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client .target("http://localhost:8888/demo-rest-spring-jersey-tomcat-mybatis-0.0.1-SNAPSHOT/podcasts/2"); Builder request = webTarget.request(MediaType.APPLICATION_JSON); Response response = request.get(); Assert.assertTrue(response.getStatus() == 200); Podcast podcast = response.readEntity(Podcast.class); ObjectMapper mapper = new ObjectMapper(); System.out .print("Received podcast from database *************************** " + mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(podcast)); }
Example #5
Source File: JerseyDockerHttpClient.java From docker-java with Apache License 2.0 | 6 votes |
private void configureProxy(ClientConfig clientConfig, URI originalUri, String protocol) { List<Proxy> proxies = ProxySelector.getDefault().select(originalUri); for (Proxy proxy : proxies) { InetSocketAddress address = (InetSocketAddress) proxy.address(); if (address != null) { String hostname = address.getHostName(); int port = address.getPort(); clientConfig.property(ClientProperties.PROXY_URI, "http://" + hostname + ":" + port); String httpProxyUser = System.getProperty(protocol + ".proxyUser"); if (httpProxyUser != null) { clientConfig.property(ClientProperties.PROXY_USERNAME, httpProxyUser); String httpProxyPassword = System.getProperty(protocol + ".proxyPassword"); if (httpProxyPassword != null) { clientConfig.property(ClientProperties.PROXY_PASSWORD, httpProxyPassword); } } } } }
Example #6
Source File: ApiClient.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); // turn off compliance validation to be able to send payloads with DELETE calls clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); if (debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } else { // suppress warnings for payloads with DELETE calls: java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE); } performAdditionalClientConfiguration(clientConfig); ClientBuilder clientBuilder = ClientBuilder.newBuilder(); customizeClientBuilder(clientBuilder); clientBuilder = clientBuilder.withConfig(clientConfig); return clientBuilder.build(); }
Example #7
Source File: NoSecuredClientGenerator.java From raml-java-client-generator with Apache License 2.0 | 6 votes |
@Override public JMethod createClientWithMultipart(JDefinedClass containerClass) { JCodeModel cm = new JCodeModel(); JMethod getClient = containerClass.method(JMod.PROTECTED, Client.class, "getClientWithMultipart"); JBlock body = getClient.body(); JClass ccRef = cm.ref(ClientConfig.class); final JVar ccVal = body.decl(cm.ref(ClientConfig.class), "cc", JExpr._new(ccRef)); body.add(ccVal.invoke("register").arg(cm.ref(MultiPartFeature.class).dotclass())); JClass cbRef = cm.ref(ClientBuilder.class); JInvocation init = cbRef.staticInvoke("newBuilder"); final JVar cbVal = body.decl(cbRef, "clientBuilder", init); body._return(cbVal.invoke("withConfig").arg(ccVal).invoke("build")); return getClient; }
Example #8
Source File: RestClientUtil.java From cloudbreak with Apache License 2.0 | 6 votes |
public static Client createClient(SSLContext sslContext, boolean debug) { ClientConfig config = new ClientConfig(); config.property(ClientProperties.FOLLOW_REDIRECTS, "false"); config.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT_MS); config.register(MultiPartFeature.class); ClientBuilder builder = ClientBuilder.newBuilder().withConfig(config); builder.sslContext(sslContext); builder.hostnameVerifier(CertificateTrustManager.hostnameVerifier()); if (debug) { builder = enableRestDebug(builder); } Client client = builder.build(); LOGGER.debug("Jax rs client has been constructed: {}, sslContext: {}", client, sslContext); return client; }
Example #9
Source File: ApiClient.java From cyberduck with GNU General Public License v3.0 | 6 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); if (debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } performAdditionalClientConfiguration(clientConfig); return ClientBuilder.newClient(clientConfig); }
Example #10
Source File: JerseyServerIT.java From tessera with Apache License 2.0 | 6 votes |
@Test public void param() { // URL.setURLStreamHandlerFactory(new UnixSocketURLStreamHandlerFactory()); ClientConfig config = new ClientConfig(); config.connectorProvider(new JerseyUnixSocketConnectorProvider()); Response result = newClient(unixfile) .target(unixfile) .path("param") .queryParam("queryParam", "QueryParamValue") .request() .header("headerParam", "HeaderParamValue") .get(); assertThat(result.getStatus()).isEqualTo(200); }
Example #11
Source File: RestDemoServiceIT.java From demo-rest-jersey-spring with MIT License | 6 votes |
@Test public void testGetPodcast() throws JsonGenerationException, JsonMappingException, IOException { ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client .target("http://localhost:8888/demo-rest-jersey-spring/podcasts/2"); Builder request = webTarget.request(MediaType.APPLICATION_JSON); Response response = request.get(); Assert.assertTrue(response.getStatus() == 200); Podcast podcast = response.readEntity(Podcast.class); ObjectMapper mapper = new ObjectMapper(); System.out .print("Received podcast from database *************************** " + mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(podcast)); }
Example #12
Source File: ApiClient.java From cyberduck with GNU General Public License v3.0 | 6 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); if(debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024 * 50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } performAdditionalClientConfiguration(clientConfig); return ClientBuilder.newClient(clientConfig); }
Example #13
Source File: BitmexRestClient.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
public BitmexRestClient(boolean useProduction) { if (useProduction) { apiURL = productionApiUrl; } else { apiURL = testnetApiUrl; } ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(mapper, new Annotations[0]); ClientConfig config = new ClientConfig(); config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); config.register(provider); config.register(JacksonFeature.class); client = ClientBuilder.newBuilder().withConfig(config).build(); }
Example #14
Source File: ApiClient.java From datacollector with Apache License 2.0 | 6 votes |
/** * Get an existing client or create a new client to handle HTTP request. */ private Client getClient() { if (!hostMap.containsKey(basePath)) { ClientConfig config = new ClientConfig(); config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); Client client; if (sslContext != null) { client = ClientBuilder.newBuilder().sslContext(sslContext).withConfig(config).build(); } else { client = ClientBuilder.newClient(config); } client.register(new CsrfProtectionFilter("CSRF")); hostMap.put(basePath, client); } return hostMap.get(basePath); }
Example #15
Source File: RestDemoServiceIT.java From demo-restWS-spring-jersey-jpa2-hibernate with MIT License | 5 votes |
@Test public void testGetLegacyPodcasts() throws JsonGenerationException, JsonMappingException, IOException { ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client .target("http://localhost:8888/demo-rest-spring-jersey-jpa2-hibernate-0.0.1-SNAPSHOT/legacy/podcasts/"); Builder request = webTarget.request(); request.header("Content-type", MediaType.APPLICATION_JSON); Response response = request.get(); Assert.assertTrue(response.getStatus() == 200); List<Podcast> podcasts = response .readEntity(new GenericType<List<Podcast>>() { }); ObjectMapper mapper = new ObjectMapper(); System.out.print(mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(podcasts)); Assert.assertTrue("At least one podcast is present in the LEGACY", podcasts.size() > 0); }
Example #16
Source File: ProxyStatsTest.java From pulsar with Apache License 2.0 | 5 votes |
/** * Validates proxy connection stats api. * * @throws Exception */ @Test public void testConnectionsStats() throws Exception { final String topicName1 = "persistent://sample/test/local/connections-stats"; PulsarClient client = PulsarClient.builder().serviceUrl(proxyService.getServiceUrl()).build(); Producer<byte[]> producer = client.newProducer(Schema.BYTES).topic(topicName1).enableBatching(false) .messageRoutingMode(MessageRoutingMode.SinglePartition).create(); // Create a consumer directly attached to broker Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(topicName1).subscriptionName("my-sub").subscribe(); int totalMessages = 10; for (int i = 0; i < totalMessages; i++) { producer.send("test".getBytes()); } for (int i = 0; i < totalMessages; i++) { Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS); checkNotNull(msg); consumer.acknowledge(msg); } Client httpClient = ClientBuilder.newClient(new ClientConfig().register(LoggingFeature.class)); Response r = httpClient.target(proxyWebServer.getServiceUri()).path("/proxy-stats/connections").request() .get(); Assert.assertEquals(r.getStatus(), Response.Status.OK.getStatusCode()); String response = r.readEntity(String.class).trim(); List<ConnectionStats> connectionStats = new Gson().fromJson(response, new TypeToken<List<ConnectionStats>>() { }.getType()); assertNotNull(connectionStats); consumer.close(); client.close(); }
Example #17
Source File: SchemaRegistryClient.java From nifi with Apache License 2.0 | 5 votes |
protected ClientConfig createClientConfig(Map<String, ?> conf) { ClientConfig config = new ClientConfig(); config.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); config.property(ClientProperties.READ_TIMEOUT, DEFAULT_READ_TIMEOUT); config.property(ClientProperties.FOLLOW_REDIRECTS, true); for (Map.Entry<String, ?> entry : conf.entrySet()) { config.property(entry.getKey(), entry.getValue()); } return config; }
Example #18
Source File: RxJerseyClientFeature.java From rx-jersey with MIT License | 5 votes |
private Client createClient() { int cores = Runtime.getRuntime().availableProcessors(); ClientConfig config = new ClientConfig(); config.connectorProvider(new GrizzlyConnectorProvider()); config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores); config.register(RxObservableInvokerProvider.class); return ClientBuilder.newClient(config); }
Example #19
Source File: RxJerseyClientFeature.java From rx-jersey with MIT License | 5 votes |
private Client defaultClient() { int cores = Runtime.getRuntime().availableProcessors(); ClientConfig config = new ClientConfig(); config.connectorProvider(new GrizzlyConnectorProvider()); config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores); config.register(RxFlowableInvokerProvider.class); return ClientBuilder.newClient(config); }
Example #20
Source File: RestClient.java From micro-server with Apache License 2.0 | 5 votes |
protected Client initClient(int rt, int ct) { ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, ct); clientConfig.property(ClientProperties.READ_TIMEOUT, rt); ClientBuilder.newBuilder().register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); client.register(JacksonFeature.class); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(JacksonUtil.getMapper()); client.register(provider); return client; }
Example #21
Source File: AuthenticationDevice.java From java-oauth-server with Apache License 2.0 | 5 votes |
private static Client createClient(int readTimeout, int connectTimeout) { // Client configuration. ClientConfig config = new ClientConfig(); // Read timeout. config.property(READ_TIMEOUT, readTimeout); // Connect timeout. config.property(CONNECT_TIMEOUT, connectTimeout); // The client that synchronously communicates with the authentication device simulator. return ClientBuilder.newClient(config); }
Example #22
Source File: WnsClient.java From java-wns with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void setProxyCredentials(ClientConfig clientConfig, WnsProxyProperties proxyProps) { if (proxyProps != null) { String proxyUri = proxyProps.getUri(); String proxyUser = proxyProps.getUser(); String proxyPass = proxyProps.getPass(); if (proxyUri != null) { clientConfig.property(ClientProperties.PROXY_URI, proxyUri); if ( (proxyUser != null) && !proxyUser.trim().isEmpty()) { clientConfig.property(ClientProperties.PROXY_USERNAME, proxyUser); clientConfig.property(ClientProperties.PROXY_PASSWORD, proxyPass); } } } }
Example #23
Source File: Tournament.java From acs-demos with MIT License | 5 votes |
@Override protected RoundResult playRound(Round round) { logger.info("Playing round: " + round.getName()); Iterator<GameTicket> itr = getStatus().getTickets().iterator(); while (itr.hasNext()) { GameTicket player = itr.next(); logger.debug("Requesting cards from " + player.getPlayerName()); // Ask player for cards Client client = ClientBuilder.newClient(new ClientConfig().register( LoggingFeature.class )); WebTarget webTarget = client.target(player.getPlayerEndpoint()).path("player/round"); Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); Response response = invocationBuilder.put(Entity.entity(round, MediaType.APPLICATION_JSON)); if (response.getStatus() != 200) { logger.warn("Response from " + player.getPlayerName() + " indicates a lack of success."); String msg = response.readEntity(String.class); logger.warn(response.getStatus() + " - " + msg); } PlayedCards cards = response.readEntity(PlayedCards.class); round.addCards(player, cards); } RoundResult results = round.getResults(); logger.info("Round is complete. Results:\n" + results.toString()); return results; }
Example #24
Source File: Player.java From acs-demos with MIT License | 5 votes |
/** * Request to join a game. * * This sends a request to the game engine (via REST API at * `engineEndpoint`) to join a game. When a game is ready the engine will * call back to the player via the player API and the game can start. * */ public void joinTournament(String engineEndpoint, int numOfPlayers) { this.getStatus().setState(PlayerStatus.State.Requesting); Client client = ClientBuilder.newClient(new ClientConfig().register( LoggingFeature.class )); WebTarget webTarget = client.target(engineEndpoint).path("api/v0.1/tournament/join"); Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); GameTicket ticket = new GameTicket(this, numOfPlayers); Response response = invocationBuilder.put(Entity.entity(ticket, MediaType.APPLICATION_JSON)); GameStatusResponse status = response.readEntity(GameStatusResponse.class); /* * FIXME: Saw this intermittent error circa 1/1/2017 * 1705 [main] DEBUG org.gardler.biglittlechallenge.trials.ai.AiPlayerApp - Waiting for 0ms before requesting to join a new game. * 1948 [main] INFO org.gardler.biglittlechallenge.trials.ai.DumbAIUI - Created Dumb AI Player UI * Exception in thread "main" java.lang.NullPointerException * at org.gardler.biglittlechallenge.core.model.Player.joinTournament(Player.java:146) * at org.gardler.biglittlechallenge.trials.ai.AiPlayerApp.main(AiPlayerApp.java:64) * */ if (status.getState() == GameStatus.State.WaitingForPlayers || status.getState() == GameStatus.State.Starting) { this.getStatus().setState(PlayerStatus.State.Waiting); } logger.debug("Request to join tournament - response (status " + response.getStatus() + "): " + status); }
Example #25
Source File: RestClientHelper.java From azure-devops-intellij with MIT License | 5 votes |
public static ClientConfig getClientConfig(final ServerContext.Type type, final AuthenticationInfo authenticationInfo, final boolean includeProxySettings) { final Credentials credentials = AuthHelper.getCredentials(type, authenticationInfo); return getClientConfig(type, credentials, authenticationInfo.getServerUri(), includeProxySettings); }
Example #26
Source File: RESTClient.java From TeaStore with Apache License 2.0 | 5 votes |
/** * Creates a new REST Client for an entity of Type T. The client interacts with a Server providing * CRUD functionalities * @param hostURL The url of the host. Common Pattern: "http://[hostname]:[port]/servicename/" * @param application The name of the rest application, usually {@link #DEFAULT_REST_APPLICATION} "rest" (no "/"!) * @param endpoint The name of the rest endpoint, typically the all lower case name of the entity in a plural form. * E.g., "products" for the entity "Product" (no "/"!) * @param entityClass Classtype of the Entitiy to send/receive. Note that the use of this Class type is * open for interpretation by the inheriting REST clients. */ public RESTClient(String hostURL, String application, String endpoint, final Class<T> entityClass) { if (!hostURL.endsWith("/")) { hostURL += "/"; } if (!hostURL.contains("://")) { hostURL = "http://" + hostURL; } ClientConfig config = new ClientConfig(); config.property(ClientProperties.CONNECT_TIMEOUT, connectTimeout); config.property(ClientProperties.READ_TIMEOUT, readTimeout); //PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); //connectionManager.setMaxTotal(MAX_POOL_SIZE); //connectionManager.setDefaultMaxPerRoute(DEFAULT_POOL_SIZE); //config.property(ApacheClientProperties.CONNECTION_MANAGER, connectionManager); config.connectorProvider(new GrizzlyConnectorProvider()); client = ClientBuilder.newClient(config); service = client.target(UriBuilder.fromUri(hostURL).build()); applicationURI = application; endpointURI = endpoint; this.entityClass = entityClass; parameterizedGenericType = new ParameterizedType() { public Type[] getActualTypeArguments() { return new Type[] { entityClass }; } public Type getRawType() { return List.class; } public Type getOwnerType() { return List.class; } }; genericListType = new GenericType<List<T>>(parameterizedGenericType) { }; }
Example #27
Source File: ClassLoaderStageLibraryTask.java From datacollector with Apache License 2.0 | 5 votes |
private RepositoryManifestJson getRepositoryManifestFile(String repoUrl) { ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.READ_TIMEOUT, 2000); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 2000); RepositoryManifestJson repositoryManifestJson = null; try (Response response = ClientBuilder.newClient(clientConfig).target(repoUrl).request().get()) { InputStream inputStream = response.readEntity(InputStream.class); repositoryManifestJson = ObjectMapperFactory.get().readValue(inputStream, RepositoryManifestJson.class); } catch (Exception ex) { LOG.error("Failed to read repository manifest json", ex); } return repositoryManifestJson; }
Example #28
Source File: DefaultSchemaRegistryClient.java From ranger with Apache License 2.0 | 5 votes |
private ClientConfig createClientConfig(Map<String, ?> conf) { ClientConfig config = new ClientConfig(); config.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); config.property(ClientProperties.READ_TIMEOUT, DEFAULT_READ_TIMEOUT); config.property(ClientProperties.FOLLOW_REDIRECTS, true); for (Map.Entry<String, ?> entry : conf.entrySet()) { config.property(entry.getKey(), entry.getValue()); } return config; }
Example #29
Source File: AbstractTestClass.java From helix with Apache License 2.0 | 5 votes |
@Override protected TestContainerFactory getTestContainerFactory() throws TestContainerException { return new TestContainerFactory() { @Override public TestContainer create(final URI baseUri, DeploymentContext deploymentContext) { return new TestContainer() { @Override public ClientConfig getClientConfig() { return null; } @Override public URI getBaseUri() { return baseUri; } @Override public void start() { if (_helixRestServer == null) { _helixRestServer = startRestServer(); } } @Override public void stop() { } }; } }; }
Example #30
Source File: OrganizationTest.java From usergrid with Apache License 2.0 | 5 votes |
@Override protected TestContainerFactory getTestContainerFactory() { final URI baseURI = getBaseUri(); return new TestContainerFactory() { @Override public TestContainer create(URI uri, DeploymentContext deploymentContext) { return new TestContainer() { @Override public ClientConfig getClientConfig() { return clientConfig; } @Override public URI getBaseUri() { return baseURI; } @Override public void start() { // noop } @Override public void stop() { // noop } }; } }; }