Java Code Examples for org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#setFallbackSerializerFactory()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#setFallbackSerializerFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FallbackSerializerFactoryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testFallbackSerializer() {
  // given
  // that the process engine is configured with a fallback serializer factory
   ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration()
     .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
     .setProcessEngineName("engine-forceclose");

   engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());

   processEngine = engineConfiguration.buildProcessEngine();
   deployOneTaskProcess(processEngine);

   // when setting a variable that no regular serializer can handle
   ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();

   ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess",
       Variables.createVariables().putValueTyped("var", objectValue));

   ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);

   // then the fallback serializer is used
   Assert.assertNotNull(fetchedValue);
   Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
   Assert.assertEquals("foo", fetchedValue.getValue());
}
 
Example 2
Source File: FallbackSerializerFactoryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testFallbackSerializerDoesNotOverrideRegularSerializer() {
  // given
  // that the process engine is configured with a serializer for a certain format
  // and a fallback serializer factory for the same format
   ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration()
     .setJdbcUrl("jdbc:h2:mem:camunda-forceclose")
     .setProcessEngineName("engine-forceclose");

   engineConfiguration.setCustomPreVariableSerializers(Arrays.<TypedValueSerializer>asList(new ExampleConstantSerializer()));
   engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());

   processEngine = engineConfiguration.buildProcessEngine();
   deployOneTaskProcess(processEngine);

   // when setting a variable that no regular serializer can handle
   ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();

   ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess",
       Variables.createVariables().putValueTyped("var", objectValue));

   ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);

   // then the fallback serializer is used
   Assert.assertNotNull(fetchedValue);
   Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
   Assert.assertEquals(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.getValue());
}
 
Example 3
Source File: SpinProcessEnginePlugin.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void registerFallbackSerializer(ProcessEngineConfigurationImpl processEngineConfiguration) {
  processEngineConfiguration.setFallbackSerializerFactory(new SpinFallbackSerializerFactory());
}