Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide DataflowTemplate Constructor without the RestTemplate #870

Closed
ghillert opened this issue Sep 12, 2016 · 1 comment
Closed

Provide DataflowTemplate Constructor without the RestTemplate #870

ghillert opened this issue Sep 12, 2016 · 1 comment
Assignees
Labels
type/enhancement Is an enhancement request
Milestone

Comments

@ghillert
Copy link
Contributor

ghillert commented Sep 12, 2016

In order to improve the UX when using DataFlowTemplate, we should provide a constructor that does not require a RestTemplate to be passed in. Currently, not only must a RestTemplate be presently provided, but it also must fulfill the specific requirements of the DataFlowTemplate:

    @Bean
    public static RestTemplate restTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.setErrorHandler(new VndErrorResponseErrorHandler(restTemplate.getMessageConverters()));
        for(HttpMessageConverter<?> converter : restTemplate.getMessageConverters()) {
            if (converter instanceof MappingJackson2HttpMessageConverter) {
                final MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
                jacksonConverter.getObjectMapper().registerModule(new Jackson2HalModule());
                jacksonConverter.getObjectMapper().addMixIn(JobExecution.class, JobExecutionJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(JobParameters.class, JobParametersJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(JobParameter.class, JobParameterJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(JobInstance.class, JobInstanceJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(ExitStatus.class, ExitStatusJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(StepExecution.class, StepExecutionJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(ExecutionContext.class, ExecutionContextJacksonMixIn.class);
                jacksonConverter.getObjectMapper().addMixIn(StepExecutionHistory.class, StepExecutionHistoryJacksonMixIn.class);
            }
        }
        return restTemplate;
    }

This configuration is taken from the Spring Cloud Dataflow Shell module.

@ghillert
Copy link
Contributor Author

See also: pring-cloud/spring-cloud-dataflow/issues/871

@sabbyanandan sabbyanandan added this to the 1.1.0.M1 milestone Sep 12, 2016
@sabbyanandan sabbyanandan modified the milestones: 1.1.0.M2, 1.1.0.M1 Sep 13, 2016
ericbottard pushed a commit that referenced this issue Sep 29, 2016
gh-870 Add Jackson Mixins to provided RestTemplates

* Add JavaDoc
* Add JUnit Tests
@ghillert ghillert removed the in pr label Sep 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Is an enhancement request
Projects
None yet
Development

No branches or pull requests

2 participants