Example usage for com.fasterxml.jackson.datatype.jdk8 Jdk8Module Jdk8Module

List of usage examples for com.fasterxml.jackson.datatype.jdk8 Jdk8Module Jdk8Module

Introduction

In this page you can find the example usage for com.fasterxml.jackson.datatype.jdk8 Jdk8Module Jdk8Module.

Prototype

Jdk8Module

Source Link

Usage

From source file:keywhiz.testing.JsonHelpers.java

/**
 * Customized ObjectMapper for common settings.
 *
 * @return customized object mapper/*from w ww.j a v  a 2  s .  com*/
 */
private static ObjectMapper customizeObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());
    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new LogbackModule());
    mapper.registerModule(new GuavaExtrasModule());
    mapper.registerModule(new FuzzyEnumModule());
    mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
    mapper.setSubtypeResolver(new DiscoverableSubtypeResolver());
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}

From source file:net.aethersanctum.lilrest.server.JaxRsServerModule.java

public ObjectMapper customMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModules(new Jdk8Module(), new JSR310Module());
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return objectMapper;
}

From source file:keywhiz.cli.CliModule.java

@Provides
public ObjectMapper generalMapper() {
    /**/*from   w w  w.ja  v a  2 s.c  o  m*/
     * Customizes ObjectMapper for common settings.
     *
     * @param objectMapper to be customized
     * @return customized input factory
     */
    ObjectMapper objectMapper = Jackson.newObjectMapper();
    objectMapper.registerModule(new Jdk8Module());
    objectMapper.registerModules(new JavaTimeModule());
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return objectMapper;
}

From source file:com.addthis.codec.jackson.Jackson.java

public static ObjectMapper registerExtraModules(ObjectMapper objectMapper) {
    objectMapper.registerModule(new GuavaModule());
    objectMapper.registerModule(new Jdk8Module());
    // jsr310 is basically just the jdk 8 date/time classes split into its own module
    objectMapper.registerModule(new JSR310Module());
    objectMapper.registerModule(new JodaModule());
    objectMapper.registerModule(new ExecutorsModule());
    return objectMapper;
}

From source file:it.polimi.diceH2020.launcher.model.InteractiveExperiment.java

public Solution getSol() throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper().registerModule(new Jdk8Module())
            .enable(SerializationFeature.INDENT_OUTPUT);
    ;//from   www.  j  a  va  2s  . co  m
    return mapper.readValue(Compressor.decompress(finalSolution), Solution.class);
}

From source file:io.github.retz.scheduler.RetzScheduler.java

public RetzScheduler(Launcher.Configuration conf, Protos.FrameworkInfo frameworkInfo) {
    MAPPER.registerModule(new Jdk8Module());
    PLANNER = PlannerFactory.create(conf.getServerConfig().getPlannerName());
    this.conf = Objects.requireNonNull(conf);
    this.frameworkInfo = frameworkInfo;
    this.slaves = new ConcurrentHashMap<>();
    this.filters = Protos.Filters.newBuilder().setRefuseSeconds(conf.getServerConfig().getRefuseSeconds())
            .build();//from  w w w.  j av a2 s  .c o  m
    MAX_JOB_SIZE = conf.getServerConfig().getMaxJobSize();
}

From source file:io.github.retz.web.NoAuthWebConsoleTest.java

/**
 * Initializes the test./* www. jav  a  2  s  . c o m*/
 *
 * @throws Exception if some errors were occurred
 */
@Before
public void setUp() throws Exception {

    Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder().setUser("")
            .setName(RetzScheduler.FRAMEWORK_NAME).build();

    // Non-TLS tests are not to be done, I believe when it works with TLS tests, it should work
    // on Non-TLS setup too. I believe his is because Sparkjava does not cleanly clear TLS setting in
    // Spark.stop(), because with retz.properties it succeeds alone, but fails when right after TLS tests.
    // TODO: investigate and report this to sparkjava
    InputStream in = Launcher.class.getResourceAsStream("/retz-noauth.properties");
    Launcher.Configuration conf = new Launcher.Configuration(new ServerConfiguration(in));

    mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());

    RetzScheduler scheduler = new RetzScheduler(conf, frameworkInfo);
    config = conf.getServerConfig();
    webConsole = new WebConsole(config);
    WebConsole.setScheduler(scheduler);
    awaitInitialization();

    Database.getInstance().init(config);

    cliConfig = new ClientCLIConfig("src/test/resources/retz-noauth-client.properties");
    System.err.println(config.authenticationEnabled());
    System.err.println(config.toString());
    webClient = Client.newBuilder(cliConfig.getUri()).setAuthenticator(cliConfig.getAuthenticator())
            .checkCert(!cliConfig.insecure()).build();
}

From source file:com.netflix.genie.client.BaseGenieClient.java

/**
 * Constructor that takes the service url and a security interceptor implementation.
 *
 * @param url                       The url of the Genie Service.
 * @param interceptors              All desired interceptors for the client to be created
 * @param genieNetworkConfiguration A configuration object that provides network settings for HTTP calls.
 * @throws GenieClientException If there is any problem creating the constructor.
 *//* w  w w.  jav  a2 s.c o  m*/
public BaseGenieClient(@NotEmpty final String url, @Nullable final List<Interceptor> interceptors,
        @Nullable final GenieNetworkConfiguration genieNetworkConfiguration) throws GenieClientException {

    if (StringUtils.isBlank(url)) {
        throw new GenieClientException("Service URL cannot be empty or null");
    }

    final OkHttpClient.Builder builder = new OkHttpClient.Builder();

    if (genieNetworkConfiguration != null) {
        this.addConfigParamsFromConfig(builder, genieNetworkConfiguration);
    }

    this.mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .setDateFormat(new GenieDateFormat()).setTimeZone(TimeZone.getTimeZone("UTC"))
            .registerModule(new Jdk8Module());

    // Add the interceptor to map the retrofit response code to corresponding Genie Exceptions in case of
    // 4xx and 5xx errors.
    builder.addInterceptor(new ResponseMappingInterceptor());
    if (interceptors != null) {
        interceptors.forEach(builder::addInterceptor);
    }
    final OkHttpClient client = builder.build();

    this.retrofit = new Retrofit.Builder().baseUrl(url)
            .addConverterFactory(JacksonConverterFactory.create(this.mapper)).client(client).build();
}

From source file:io.github.retz.web.WebConsoleCommonTests.java

@Before
public void setUp() throws Exception {

    Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder().setUser("")
            .setName(RetzScheduler.FRAMEWORK_NAME).build();

    // Non-TLS tests are not to be done, I believe when it works with TLS tests, it should work
    // on Non-TLS setup too. I believe his is because Sparkjava does not cleanly clear TLS setting in
    // Spark.stop(), because with retz.properties it succeeds alone, but fails when right after TLS tests.
    // TODO: investigate and report this to sparkjava
    Launcher.Configuration conf = makeConfig();

    mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());

    RetzScheduler scheduler = new RetzScheduler(conf, frameworkInfo);
    config = conf.getServerConfig();/*from   www  .j av a  2s. c o m*/
    Database.getInstance().init(config);
    assertTrue(Database.getInstance().allTableExists());

    WebConsole.set(scheduler, null);
    WebConsole.start(config);
    awaitInitialization();

    cliConfig = makeClientConfig();
    System.err.println(config.authenticationEnabled());
    System.err.println(config.toString());
    webClient = Client.newBuilder(cliConfig.getUri()).setAuthenticator(cliConfig.getAuthenticator())
            .checkCert(!cliConfig.insecure()).setVerboseLog(true).build();
}