Configuring Data Formats
To configure a data format detected by Spin, the SPI can be implemented. A configurator specifies which classes it can configure. Spin discovers a configurator by employing Java’s service loader mechanism and will then provide it with all data formats that match the specified class (or are a subclass thereof). The concrete configuration options depend on the actual data format. For example, a Jackson-based JSON data format can modify the ObjectMapper
that the data format uses.
- Provide a custom implementation of org.camunda.spin.spi.DataFormatConfigurator
- Ensure that the artifact containing the configurator is reachable from Spin’s classloader
Custom Dataformats
A Spin data format is an implementation of the interface . An implementation of this interface can be registered by implementing the SPI org.camunda.spin.spi.DataFormatProvider
. Spin uses the Java platform’s service loader mechanism to lookup provider implementations at runtime.
- Provide a custom implementation of org.camunda.spin.spi.DataFormat
- Add the provider’s fully qualified classname to a file named META-INF/services/org.camunda.spin.spi.DataFormatProvider
- Ensure that the artifact containing the provider is reachable from Spin’s classloader
If you now call , then the custom dataformat is returned along with the built-in dataformats. Furthermore,org.camunda.spin.DataFormats.getDataFormat(String dataFormatName)
can be used to explicity retrieve the data format by a specific provider.