camunda / camunda-bpm-platform

Flexible framework for workflow and decision automation with BPMN and DMN. Integration with Quarkus, Spring, Spring Boot, CDI.
https://camunda.com/
Apache License 2.0
4.11k stars 1.55k forks source link

SpinPlugin: Accept list of DataFormatConfigurators #2742

Closed ThorbenLindhauer closed 1 year ago

ThorbenLindhauer commented 2 years ago

This issue was imported from JIRA:

Field Value
JIRA Link CAM-14605
Reporter Q2R5dDB
What is this name? This pseudonym name was generated based on the user name in JIRA to protect the personal data of our JIRA users. You can use this identifier to search for issues by the same reporter.
Has restricted visibility comments true

User Story (Required on creation):

I use spin/jackson to serialize and deserialize complex process variables. I use spring boot. My jackson object mapper has a specific configuration of modules, mixins, ... I expose this mapper as singleton spring bean and inject it in any component that requires json. Works great.

But: I cannot register my jackson object mapper instance in the camunda spin plugin. I have to provide a service loader, a dataFormatConfigurator interface implementation and provide static access to (a copy of) my singleton objectMapper.

What I want to do: Provide a SpinPlugin bean in my spring context that gets my object mapper injected and registers a dataFormatConfigurator based on that mapper.

Functional Requirements (Required before implementation):

Technical Requirements (Required before implementation):

Extend the SpinProcessEnginePlugin so it accepts an optional list of dataFormatConfigurators. If configurators are passed they are used (in addition  to the service loader spi) to configure the DataFormats.INSTANCE. The methods already exist, just the constructor and the preInit() method of the plugin have to be extended. 

Hint:

I already did this locally by extending the plugin class and overwriting preInit(), but I would like to see this in the core to a) avoid additional implementation and b) avoid copying code fragments that might change in the core (call of super.preInit() did not work, had to copy the method.

I would provide a PR for this. It is a personal feature request by me as community member.

Links:

ThorbenLindhauer commented 2 years ago

This comment was imported from JIRA and written by user @koevskinikola


Hi Q2R5dDB,

Thanks for raising this topic.

I think we introduced some changes to Spin that made it possible to pass multiple instances of the DataFormatConfiguratior interface, but I have to re-check the code to confirm.

I'll provide you with more information next week.

Best, Nikola

ThorbenLindhauer commented 2 years ago

This comment was imported from JIRA and written by user @koevskinikola


Hi Q2R5dDB,

Sorry for the long delay with this response. I believe that something similar to what you require has already been implemented.

The SpinProcessEnginePlugin class is extended into the SpringBootSpinProcessEnginePlugin class and you can provide an optional list of DataFormatConfiguratior implementations with the DataFormats.loadDataFormats(Classloader, List<DataFormatConfigurator>) static method.

A bean of this class is then provided here: https://github.com/camunda/camunda-bpm-platform/blob/f5c2d559dd4016de4438bdb9c58222059a988b53/spring-boot-starter/starter/src/main/java/org/camunda/bpm/spring/boot/starter/CamundaBpmPluginConfiguration.java#L96

Would you be able to work with this?

Best, Nikola

tasso94 commented 1 year ago

It looks like Nikolas's solution works for the user, and the feature is already part of the product. As a result of this, I'm closing this issue.