org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider Java Examples
The following examples show how to use
org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider.
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: 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 #2
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 #3
Source File: DockerRegistry.java From carnotzet with Apache License 2.0 | 6 votes |
private WebTarget getRegistryWebTarget(ImageRef imageRef) { if (!webTargets.containsKey(imageRef.getRegistryUrl())) { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); ClientConfig clientCOnfig = new ClientConfig(); clientCOnfig.connectorProvider(new HttpUrlConnectorProvider()); // TODO : This client doesn't handle mandatory Oauth2 Bearer token imposed by some registries implementations (ie : docker hub) Client client = ClientBuilder.newClient(clientCOnfig) .register(new JacksonJaxbJsonProvider(mapper, new Annotations[] {Annotations.JACKSON})) .register(JacksonFeature.class); String auth = config.getAuthFor(imageRef.getRegistryName()); if (auth != null) { String[] credentials = new String(Base64.getDecoder().decode(auth), StandardCharsets.UTF_8).split(":"); client.register(HttpAuthenticationFeature.basicBuilder().credentials(credentials[0], credentials[1])); } WebTarget webTarget = client.target(imageRef.getRegistryUrl()); webTargets.put(imageRef.getRegistryUrl(), webTarget); } return webTargets.get(imageRef.getRegistryUrl()); }
Example #4
Source File: App.java From jweb-cms with GNU Affero General Public License v3.0 | 5 votes |
protected void configure() { logger.info("init app, name={}, language={}, dir={}", name(), language(), dir()); binder = new ModuleBinder(); binder.bind(App.class).toInstance(this); binder.bind(MessageBundle.class).toInstance(message()); binder.bind(Configuration.class).toInstance(Validation.byDefaultProvider().configure() .messageInterpolator(new MessageInterpolatorImpl()) .addProperty("hibernate.validator.fail_fast", "true")); register(ValidationFeature.class); JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider(); jacksonProvider.setMapper(JSON.OBJECT_MAPPER); register(jacksonProvider); register(JacksonFeature.class); register(binder.raw()); register(new DefaultContainerLifecycleListener(this)); register(new AppEventListener()); register(DefaultExceptionMapper.class); validate(); for (String moduleName : orderedModules()) { ModuleNode moduleNode = moduleNode(moduleName).orElseThrow(); if (moduleNode.isOverrided()) { moduleNode.status = ModuleStatus.CONFIGURED; } else { try { Stopwatch w = Stopwatch.createStarted(); configure(moduleNode.module); moduleNode.status = ModuleStatus.CONFIGURED; } catch (Exception e) { throw new ApplicationException("failed to install module {}, type={}", moduleName, moduleNode.module.getClass().getCanonicalName(), e); } } } }
Example #5
Source File: LogSearchJerseyResourceConfig.java From ambari-logsearch with Apache License 2.0 | 4 votes |
public LogSearchJerseyResourceConfig() { packages(ServiceLogsResource.class.getPackage().getName()); register(JacksonJaxbJsonProvider.class); property(ServletProperties.FILTER_FORWARD_ON_404, true); }
Example #6
Source File: ZTSClient.java From athenz with Apache License 2.0 | 4 votes |
private void initClient(final String serverUrl, Principal identity, final String domainName, final String serviceName, final ServiceIdentityProvider siaProvider) { ztsUrl = (serverUrl == null) ? confZtsUrl : serverUrl; // verify if the url is ending with /zts/v1 and if it's // not we'll automatically append it if (ztsUrl != null && !ztsUrl.isEmpty()) { if (!ztsUrl.endsWith("/zts/v1")) { if (ztsUrl.charAt(ztsUrl.length() - 1) != '/') { ztsUrl += '/'; } ztsUrl += "zts/v1"; } } // determine to see if we need a host verifier for our ssl connections HostnameVerifier hostnameVerifier = null; if (x509CertDNSName != null && !x509CertDNSName.isEmpty()) { hostnameVerifier = new AWSHostNameVerifier(x509CertDNSName); } // if we don't have a ssl context specified, check the system // properties to see if we need to create one if (sslContext == null) { sslContext = createSSLContext(); } // setup our client config object with timeouts final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); final ClientConfig config = new ClientConfig(jacksonJsonProvider); PoolingHttpClientConnectionManager connManager = createConnectionManager(sslContext, hostnameVerifier); if (connManager != null) { config.property(ApacheClientProperties.CONNECTION_MANAGER, connManager); } config.connectorProvider(new ApacheConnectorProvider()); // if we're asked to use a proxy for our request // we're going to set the property that is supported // by the apache connector and use that if (proxyUrl != null) { config.property(ClientProperties.PROXY_URI, proxyUrl); } ClientBuilder builder = getClientBuilder(); if (sslContext != null) { builder = builder.sslContext(sslContext); enablePrefetch = true; } // JerseyClientBuilder::withConfig() replaces the existing config with the new client // config. Hence the client config should be added to the builder before the timeouts. // Otherwise the timeout settings would be overridden. Client rsClient = builder.withConfig(config) .hostnameVerifier(hostnameVerifier) .readTimeout(reqReadTimeout, TimeUnit.MILLISECONDS) .connectTimeout(reqConnectTimeout, TimeUnit.MILLISECONDS) .build(); ztsClient = new ZTSRDLGeneratedClient(ztsUrl, rsClient); principal = identity; domain = domainName; service = serviceName; this.siaProvider = siaProvider; // if we are given a principal object then we need // to update the domain/service settings if (principal != null) { domain = principal.getDomain(); service = principal.getName(); ztsClient.addCredentials(identity.getAuthority().getHeader(), identity.getCredentials()); } }
Example #7
Source File: WebUtils.java From nifi with Apache License 2.0 | 4 votes |
/** * A helper method for creating clients. The client will be created using * the given configuration and security context. Additionally, the client * will be automatically configured for JSON serialization/deserialization. * * @param config client configuration * @param ctx security context, which may be null for non-secure client * creation * @return a Client instance */ private static Client createClientHelper(final ClientConfig config, final SSLContext ctx) { ClientBuilder clientBuilder = ClientBuilder.newBuilder(); if (config != null) { clientBuilder = clientBuilder.withConfig(config); } if (ctx != null) { // Apache http DefaultHostnameVerifier that checks subject alternative names against the hostname of the URI clientBuilder = clientBuilder.sslContext(ctx).hostnameVerifier(new DefaultHostnameVerifier()); } clientBuilder = clientBuilder.register(ObjectMapperResolver.class).register(JacksonJaxbJsonProvider.class); return clientBuilder.build(); }