Closed antonkomarev closed 11 months ago
Hi @antonkomarev,
Thank you for reaching out to us.
Below are the steps to add customPreVariableSerializers
or customPostVariableSerializers
to the engine.
Create a class (for example: MyCustomSerializer
) that implements TypedValueSerializer
interface. Write your implementation for a custom pre- or post-variable serializer in this class.
Create a custom plugin (for example: MyCustomPlugin
) that implements the ProcessEnginePlugin
interface. And add MyCustomSerializer
in the customPreVariableSerializers
or customPostVariableSerializers
property of the process engine configuration. Here is the sample code:
public class MyCustomPlugin implements ProcessEnginePlugin {
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
List<TypedValueSerializer> serializers = new ArrayList();
serializers.add(new MyCustomSerializer());
processEngineConfiguration.setCustomPreVariableSerializers(serializers);
}
public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
// TODO Auto-generated method stub
}
public void postProcessEngineBuild(ProcessEngine processEngine) {
// TODO Auto-generated method stub
}
}
Provide the custom plugin MyCustomPlugin
and custom serializer MyCustomSerializer
in the classpath of your process engine.
Configure the custom process engine plugin MyCustomPlugin
. For instance, for Tomcat, you can configure the plugin in the plugins section of your bpm-platform
file. For example:
<?xml version="1.0" encoding="UTF-8"?>
<bpm-platform xmlns="http://www.camunda.org/schema/1.0/BpmPlatform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.camunda.org/schema/1.0/BpmPlatform http://www.camunda.org/schema/1.0/BpmPlatform ">
<process-engine name="default">
<job-acquisition>default</job-acquisition>
<configuration>org.camunda.bpm.engine.impl.cfg.JtaProcessEngineConfiguration</configuration>
<datasource>jdbc/ProcessEngine</datasource>
<plugins>
<plugin>
<class>org.camunda.bpm.engine.MyCustomPlugin</class>
</plugin>
</plugins>
</process-engine>
Here is the link for configuring the process engine plugin for further reference https://docs.camunda.org/manual/7.20/user-guide/process-engine/process-engine-plugins/.
5. Restart the application server.
Does this work for you?
Best,
Tassilo
@tasso94 thank you for sharing. Is it correct to make validation of the input in serializers? I thought there are some kind of Request Validators.
User Story (Required on creation)
I want to create process instance with date interval variable.
Functional Requirements (Required before implementation)
On create process instance there should be available to pass variable of date interval type, it should be validated. If it is wrong formatted interval — process creation should fail.
Technical Requirements (Required before implementation)
POST http://localhost:8080/engine-rest/process-definition/key/:key/start
Limitations of Scope
Hints
Links
Breakdown
Dev2QA handover