You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Sune Keller (JIRA)" <ji...@apache.org> on 2016/06/15 07:47:09 UTC

[jira] [Created] (CAMEL-10059) Add option to generate Java 1.8 Optional based DTOs

Sune Keller created CAMEL-10059:
-----------------------------------

             Summary: Add option to generate Java 1.8 Optional<?> based DTOs
                 Key: CAMEL-10059
                 URL: https://issues.apache.org/jira/browse/CAMEL-10059
             Project: Camel
          Issue Type: New Feature
          Components: camel-salesforce
            Reporter: Sune Keller
            Priority: Minor


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:
{code:xml}
		<dependency>
			<groupId>com.fasterxml.jackson.datatype</groupId>
			<artifactId>jackson-datatype-jdk8</artifactId>
		</dependency>
{code}

Then configure a custom {{ObjectMapper}} like the following snippet:
{code}
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;
	}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)