From 967ef8493638aed74be16dfe20c3b0cd814788f0 Mon Sep 17 00:00:00 2001 From: Stephan Pelikan Date: Mon, 29 Jan 2024 09:42:50 +0100 Subject: [PATCH] Improve startup performance --- spring-boot/pom.xml | 2 +- .../camunda7/Camunda7AdapterConfiguration.java | 13 +++++++++++++ .../camunda7/wiring/Camunda7TaskWiring.java | 4 +++- .../wiring/Camunda7UserTaskEventHandler.java | 8 ++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 52e482f..00ba7d7 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -20,7 +20,7 @@ io.vanillabp spring-boot-support - 1.0.7 + 1.0.8-SNAPSHOT org.camunda.bpm.springboot diff --git a/spring-boot/src/main/java/io/vanillabp/camunda7/Camunda7AdapterConfiguration.java b/spring-boot/src/main/java/io/vanillabp/camunda7/Camunda7AdapterConfiguration.java index 5142fe4..0dd92ff 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda7/Camunda7AdapterConfiguration.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda7/Camunda7AdapterConfiguration.java @@ -10,6 +10,7 @@ import io.vanillabp.camunda7.wiring.ProcessEntityAwareExpressionManager; import io.vanillabp.camunda7.wiring.TaskWiringBpmnParseListener; import io.vanillabp.springboot.adapter.AdapterConfigurationBase; +import io.vanillabp.springboot.adapter.SpringBeanUtil; import io.vanillabp.springboot.adapter.SpringDataUtil; import io.vanillabp.springboot.adapter.VanillaBpProperties; import jakarta.annotation.PostConstruct; @@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigurationPackage; import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; @@ -108,11 +110,13 @@ public Camunda7UserTaskEventHandler userTaskEventHandler() { @Bean public Camunda7TaskWiring taskWiring( + final SpringBeanUtil springBeanUtil, final ProcessEntityAwareExpressionManager processEntityAwareExpressionManager, final Camunda7UserTaskEventHandler userTaskEventHandler) { return new Camunda7TaskWiring( applicationContext, + springBeanUtil, processEntityAwareExpressionManager, userTaskEventHandler, getConnectableServices()); @@ -219,4 +223,13 @@ public StartProcessJobHandler startProcessJobHandler() { return new StartProcessJobHandler(); } + @Bean + @ConditionalOnMissingBean + public SpringBeanUtil vanillabpSpringBeanUtil( + final ApplicationContext applicationContext) { + + return new SpringBeanUtil(applicationContext); + + } + } diff --git a/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7TaskWiring.java b/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7TaskWiring.java index be12d10..bb45822 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7TaskWiring.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7TaskWiring.java @@ -3,6 +3,7 @@ import io.vanillabp.camunda7.service.Camunda7ProcessService; import io.vanillabp.spi.process.ProcessService; import io.vanillabp.spi.service.WorkflowTask; +import io.vanillabp.springboot.adapter.SpringBeanUtil; import io.vanillabp.springboot.adapter.TaskWiringBase; import io.vanillabp.springboot.parameters.MethodParameter; import io.vanillabp.springboot.parameters.MethodParameterFactory; @@ -25,11 +26,12 @@ public class Camunda7TaskWiring extends TaskWiringBase> connectableServices) { - super(applicationContext); + super(applicationContext, springBeanUtil); this.processEntityAwareExpressionManager = processEntityAwareExpressionManager; this.userTaskEventHandler = userTaskEventHandler; this.connectableServices = connectableServices; diff --git a/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7UserTaskEventHandler.java b/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7UserTaskEventHandler.java index e35d123..d0e07a3 100644 --- a/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7UserTaskEventHandler.java +++ b/spring-boot/src/main/java/io/vanillabp/camunda7/wiring/Camunda7UserTaskEventHandler.java @@ -1,8 +1,5 @@ package io.vanillabp.camunda7.wiring; -import java.util.HashMap; -import java.util.Map; - import org.camunda.bpm.engine.delegate.DelegateTask; import org.camunda.bpm.engine.delegate.TaskListener; import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; @@ -10,6 +7,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.HashMap; +import java.util.Map; + public class Camunda7UserTaskEventHandler implements TaskListener { private static final Logger logger = LoggerFactory @@ -61,7 +61,7 @@ public void notify( .filter(entry -> entry.getValue().eventApplies(delegateTask.getEventName())) // found handler-reference .findFirst() - .map(entry -> entry.getValue()) + .map(Map.Entry::getValue) .ifPresentOrElse( handler -> handler.notify(delegateTask), () -> logger.debug(