Skip to content

Commit

Permalink
allow to customize ProcessEngineConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
l0co authored and tobiasschaefer committed Jul 14, 2020
1 parent 0d3c137 commit 65b9132
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ You may use the following properties (typically in application.yml) to configure
| camunda.bpm | .history-level | auto | Camunda history level, use one of [`full`, `audit`, `activity`, `none`, `auto`]. `auto` uses the level already present in the database, defaulting to `full`. |
| camunda.bpm.database | .schema-update | true | If automatic schema update should be applied, use one of [`true`, `false`, `create`, `create-drop`, `drop-create`] |

### Custom Process Engine Configuration

Internally, to build Camunda `ProcessEngine` we use `ProcessEngineConfiguration`. This process can be intercepted for detailed configuration customization with the following bean:

```java
@Singleton
@Replaces(DefaultProcessEngineConfigurationCustomizer.class)
public class MyProcessEngineConfigurationCustomizer implements ProcessEngineConfigurationCustomizer {

@Override
public void customize(ProcessEngineConfiguration configuration) {
// configure ProcessEngineConfiguration here, e.g.:
configuration.setProcessEngineName("CustomizedEngine");
}

}
```

## Compatibility Matrix

The following compatibility matrix shows the officially supported Micronaut and Camunda BPM versions for each release.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package info.novatec.micronaut.camunda.bpm.feature;

import org.camunda.bpm.engine.ProcessEngineConfiguration;

import javax.annotation.Nonnull;
import javax.inject.Singleton;

@Singleton
public class DefaultProcessEngineConfigurationCustomizer implements ProcessEngineConfigurationCustomizer {

@Override
public void customize(@Nonnull ProcessEngineConfiguration configuration) {
// no customization
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ public class MicronautProcessEngineConfiguration {

private final DatasourceConfiguration datasourceConfiguration;

public MicronautProcessEngineConfiguration(ApplicationContext applicationContext, Configuration configuration, DatasourceConfiguration datasourceConfiguration) {
private final ProcessEngineConfigurationCustomizer processEngineConfigurationCustomizer;

public MicronautProcessEngineConfiguration(ApplicationContext applicationContext, Configuration configuration,
DatasourceConfiguration datasourceConfiguration,
ProcessEngineConfigurationCustomizer processEngineConfigurationCustomizer) {
this.applicationContext = applicationContext;
this.configuration = configuration;
this.datasourceConfiguration = datasourceConfiguration;
this.processEngineConfigurationCustomizer = processEngineConfigurationCustomizer;
}

/**
Expand All @@ -59,6 +64,8 @@ public HistoryLevel getDefaultHistoryLevel() {
.setJobExecutorActivate(true)
.setExpressionManager(new MicronautExpressionManager(new ApplicationContextElResolver(applicationContext)));

processEngineConfigurationCustomizer.customize(processEngineConfiguration);

ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
log.info("Successfully created process engine which is connected to database {}", datasourceConfiguration.getUrl());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package info.novatec.micronaut.camunda.bpm.feature;

import org.camunda.bpm.engine.ProcessEngineConfiguration;

import javax.annotation.Nonnull;

/**
* @author Lukasz Frankowski
*/
@FunctionalInterface
interface ProcessEngineConfigurationCustomizer {

void customize(@Nonnull ProcessEngineConfiguration configuration);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package info.novatec.micronaut.camunda.bpm.feature;

import io.micronaut.context.annotation.Replaces;
import org.camunda.bpm.engine.ProcessEngineConfiguration;

import javax.annotation.Nonnull;
import javax.inject.Singleton;

@Singleton
@Replaces(DefaultProcessEngineConfigurationCustomizer.class)
public class MicronautProcessEngineConfigurationCustomizer implements ProcessEngineConfigurationCustomizer {

public static final String PROCESS_ENGINE_NAME = "CustomizedEngine";

@Override
public void customize(@Nonnull ProcessEngineConfiguration configuration) {
configuration.setProcessEngineName(PROCESS_ENGINE_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ void allBeansAreAvailableInApplicationContext() {
void testDeploymentName() {
assertEquals(MicronautProcessEngineConfiguration.MICRONAUT_AUTO_DEPLOYMENT_NAME, repositoryService.createDeploymentQuery().singleResult().getName());
}
}

@Test
void testConfigurationCustomizer() {
assertEquals(MicronautProcessEngineConfigurationCustomizer.PROCESS_ENGINE_NAME, processEngine.getName());
}
}

0 comments on commit 65b9132

Please sign in to comment.