Example usage for com.fasterxml.jackson.jaxrs.json JacksonJaxbJsonProvider JacksonJaxbJsonProvider

List of usage examples for com.fasterxml.jackson.jaxrs.json JacksonJaxbJsonProvider JacksonJaxbJsonProvider

Introduction

In this page you can find the example usage for com.fasterxml.jackson.jaxrs.json JacksonJaxbJsonProvider JacksonJaxbJsonProvider.

Prototype

public JacksonJaxbJsonProvider() 

Source Link

Document

Default constructor, usually used when provider is automatically configured to be used with JAX-RS implementation.

Usage

From source file:com.tomitribe.jcache.examples.AppComposer.java

private WebClient getClient() throws URISyntaxException {
    final List<JacksonJaxbJsonProvider> pl = Arrays.asList(new JacksonJaxbJsonProvider());
    return WebClient.create("http://localhost:" + port + "/test", pl).type(MediaType.APPLICATION_JSON_TYPE)
            .accept(MediaType.APPLICATION_JSON_TYPE);
}

From source file:com.flipkart.flux.guice.module.ContainerModule.java

/**
 * Creates the Jetty server instance for the Flux API endpoint.
 * @param port where the service is available.
 * @return Jetty Server instance//w  w  w.j  av  a  2s.c  om
 */
@Named("APIJettyServer")
@Provides
@Singleton
Server getAPIJettyServer(@Named("Api.service.port") int port,
        @Named("APIResourceConfig") ResourceConfig resourceConfig, ObjectMapper objectMapper)
        throws URISyntaxException, UnknownHostException {
    //todo-ashish figure out some way of setting acceptor/worker threads
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(objectMapper);
    resourceConfig.register(provider);
    final Server server = JettyHttpContainerFactory.createServer(UriBuilder
            .fromUri(
                    "http://" + InetAddress.getLocalHost().getHostAddress() + RuntimeConstants.API_CONTEXT_PATH)
            .port(port).build(), resourceConfig);
    server.setStopAtShutdown(true);
    return server;
}

From source file:com.tomitribe.jcache.examples.InterceptedServiceTest.java

private WebClient getClient() throws URISyntaxException {
    final List<JacksonJaxbJsonProvider> pl = Arrays.asList(new JacksonJaxbJsonProvider());
    return WebClient.create(url.toURI().toASCIIString(), pl).type(MediaType.APPLICATION_JSON_TYPE)
            .accept(MediaType.APPLICATION_JSON_TYPE);
}

From source file:de.metas.procurement.webui.sync.SyncConfiguration.java

@Bean
public Server serverEndPoint(final SpringBus bus) {
    final JacksonJaxbJsonProvider jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider();

    final JMSConfigFeature jmsConfigFeature = createJMSConfigFeature();

    final JAXRSServerFactoryBean svrFactory = new JAXRSServerFactoryBean();
    svrFactory.setBus(bus);/*  ww  w.  j  av a 2  s .co  m*/
    svrFactory.setResourceClasses(AgentSync.class);

    svrFactory.getFeatures().add(jmsConfigFeature);
    svrFactory.getFeatures().add(loggingFeature);

    svrFactory.setProvider(jacksonJaxbJsonProvider);
    svrFactory.setAddress("/");
    svrFactory.setTransportId("http://cxf.apache.org/transports/jms");

    final Server server = svrFactory.create();
    return server;
}

From source file:com.alliander.osgp.shared.usermanagement.KeycloakClient.java

/**
 * Construct an AuthenticationClient instance.
 *
 * @param keyStoreSettings/*from  w  w w.j  a va  2s.  c  o  m*/
 *            Settings to determine a KeyStore and TrustManagerFactory.
 * @param KeycloakApiSettings
 *            Settings used accessing the Keycloak API.
 * @param loginClient
 *            The keycloak client used for application logins.
 * @param realm
 *            The keycloak realm with clients and users for external logins.
 *
 * @throws KeycloakClientException
 *             In case the construction fails.
 */
public KeycloakClient(final KeyStoreSettings keyStoreSettings, final KeycloakApiSettings keycloakApiSettings,
        final String loginClient, final String realm) throws KeycloakClientException {

    this.apiClient = keycloakApiSettings.getApiClient();
    this.apiClientSecret = keycloakApiSettings.getApiClientSecret();
    this.apiUser = keycloakApiSettings.getApiUser();
    this.apiPassword = keycloakApiSettings.getApiPassword();
    this.loginClient = loginClient;
    this.realm = realm;

    this.tokenPath = TOKEN_PATH_TEMPLATE.replace(PATH_ELEMENT_REALM, realm);
    this.usersPath = USERS_PATH_TEMPLATE.replace(PATH_ELEMENT_REALM, realm);
    this.userPath = USER_PATH_TEMPLATE.replace(PATH_ELEMENT_REALM, realm);
    this.userSessionsPath = USER_SESSIONS_PATH_TEMPLATE.replace(PATH_ELEMENT_REALM, realm);
    this.sessionPath = SESSION_PATH_TEMPLATE.replace(PATH_ELEMENT_REALM, realm);

    try {

        final TrustManagerFactory tmf = keyStoreSettings.getTrustManagerFactory();

        final List<Object> providers = new ArrayList<Object>();
        providers.add(new JacksonJaxbJsonProvider());

        this.webClient = WebClient.create(keycloakApiSettings.getBaseAddress(), providers, true);
        if (this.webClient == null) {
            throw new IllegalStateException("webclient is null");
        }

        final ClientConfiguration config = WebClient.getConfig(this.webClient);
        final HTTPConduit conduit = config.getHttpConduit();

        conduit.setTlsClientParameters(new TLSClientParameters());
        conduit.getTlsClientParameters().setTrustManagers(tmf.getTrustManagers());

        this.jacksonObjectMapper = new ObjectMapper();
    } catch (final Exception e) {
        LOGGER.error(CONSTRUCTION_FAILED, e);
        throw new KeycloakClientException(CONSTRUCTION_FAILED, e);
    }
}

From source file:org.apache.archiva.redback.rest.services.AbstractRestServicesTest.java

protected UserService getUserService(String authzHeader) {
    UserService service = JAXRSClientFactory.create(
            "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", UserService.class,
            Collections.singletonList(new JacksonJaxbJsonProvider()));

    // time out for debuging purpose
    WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(getTimeout());

    if (authzHeader != null) {
        WebClient.client(service).header("Authorization", authzHeader);
    }//from  w ww  .j  a v  a 2 s  . c o m
    WebClient.client(service).accept(MediaType.APPLICATION_JSON_TYPE);
    WebClient.client(service).type(MediaType.APPLICATION_JSON_TYPE);

    return service;
}

From source file:org.apache.archiva.redback.rest.services.UserServiceTest.java

@Test
public void registerNoUrl() throws Exception {
    try {// w w w  .j  a v  a2s  . com
        UserService service = getUserService();
        User u = new User();
        u.setFullName("the toto");
        u.setUsername("toto");
        u.setEmail("toto@toto.fr");
        u.setPassword("toto123");
        u.setConfirmPassword("toto123");
        String key = service.registerUser(new UserRegistrationRequest(u, null)).getKey();

        assertFalse(key.equals("-1"));

        ServicesAssert assertService = JAXRSClientFactory.create(
                "http://localhost:" + port + "/" + getRestServicesPath() + "/testsService/",
                ServicesAssert.class, Collections.singletonList(new JacksonJaxbJsonProvider()));

        List<EmailMessage> emailMessages = assertService.getEmailMessageSended();
        assertEquals(1, emailMessages.size());
        assertEquals("toto@toto.fr", emailMessages.get(0).getTos().get(0));

        assertEquals("Welcome", emailMessages.get(0).getSubject());
        String messageContent = emailMessages.get(0).getText();

        log.info("messageContent: {}", messageContent);

        assertThat(messageContent).contains("Use the following URL to validate your account.")
                .contains("http://localhost:" + port).containsIgnoringCase("toto");

        assertTrue(service.validateUserFromKey(key));

        service = getUserService(authorizationHeader);

        u = service.getUser("toto");

        assertNotNull(u);
        assertTrue(u.isValidated());
        assertTrue(u.isPasswordChangeRequired());

        assertTrue(service.validateUserFromKey(key));

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw e;
    } finally {
        deleteUserQuietly("toto");
    }

}

From source file:org.apache.archiva.redback.rest.services.AbstractRestServicesTest.java

protected RoleManagementService getRoleManagementService(String authzHeader) {
    RoleManagementService service = JAXRSClientFactory.create(
            "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/",
            RoleManagementService.class, Collections.singletonList(new JacksonJaxbJsonProvider()));

    // for debuging purpose
    WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(getTimeout());

    if (authzHeader != null) {
        WebClient.client(service).header("Authorization", authzHeader);
    }//from www  .  ja va 2s  .com

    WebClient.client(service).accept(MediaType.APPLICATION_JSON_TYPE);
    WebClient.client(service).type(MediaType.APPLICATION_JSON_TYPE);

    return service;
}

From source file:uk.dsxt.voting.common.utils.web.JettyRunner.java

public static void configureMapper(ResourceConfig resourceConfig) {
    // create custom ObjectMapper
    ObjectMapper mapper = new ObjectMapper();
    mapper.setNodeFactory(JsonNodeFactory.withExactBigDecimals(true));
    mapper.enable(SerializationFeature.INDENT_OUTPUT);

    // create JsonProvider to provide custom ObjectMapper
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(mapper);//  w  ww.  j a v  a 2  s  . c o  m
    resourceConfig.register(provider);
}

From source file:org.apache.archiva.redback.rest.services.AbstractRestServicesTest.java

protected LoginService getLoginService(String authzHeader) {
    LoginService service = JAXRSClientFactory.create(
            "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", LoginService.class,
            Collections.singletonList(new JacksonJaxbJsonProvider()));

    // for debuging purpose
    WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(getTimeout());

    if (authzHeader != null) {
        WebClient.client(service).header("Authorization", authzHeader);
    }//from   w w w  . j a  v a 2s  .  com

    WebClient.client(service).accept(MediaType.APPLICATION_JSON_TYPE);
    WebClient.client(service).type(MediaType.APPLICATION_JSON_TYPE);

    return service;
}