Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10059

Add option to generate Java 1.8 Optional<?> based DTOs

    XMLWordPrintableJSON

Details

    Description

      See GitHub PR: https://github.com/apache/camel/pull/1033

      Also upgrades to Jackson 2.x to allow injecting a custom ObjectMapper into SalesforceEndpointConfig, which in turn allows registering the Jdk8Module when using Java 1.8, which handles (de)serializing of Optional<?> in a reasonable manner. Jackson 1.x does not have the Jdk8Module.

      Note that this requires that the project using the plugin is itself using Java 1.8+.

      To use Jdk8Module, add this dependency:

      		<dependency>
      			<groupId>com.fasterxml.jackson.datatype</groupId>
      			<artifactId>jackson-datatype-jdk8</artifactId>
      		</dependency>
      

      Then configure a custom ObjectMapper like the following snippet:

      import org.apache.camel.component.salesforce.SalesforceEndpointConfig;
      ...
      import com.fasterxml.jackson.databind.ObjectMapper;
      import com.fasterxml.jackson.databind.SerializationFeature;
      import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
      ...
      	@Bean
      	public SalesforceEndpointConfig salesforceEndpointConfig() {
      		SalesforceEndpointConfig salesforceEndpointConfig = new SalesforceEndpointConfig();
      		...
      		ObjectMapper objectMapper = new ObjectMapper();
      		objectMapper.registerModule(new Jdk8Module());
      		objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
      		salesforceEndpointConfig.setObjectMapper(objectMapper);
      		return salesforceEndpointConfig;
      	}
      

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            sirlatrom Sune Keller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: