From 60ec33db38deec87415d4da45cb96f56ed31238f Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 26 Apr 2024 11:54:10 +0200 Subject: [PATCH] minor additions --- .../taskpool/core/JacksonExtensions.kt | 13 ------------ .../core/TaskPoolCoreConfiguration.kt | 21 +++++++++++++++++++ .../ProcessInstanceVariablesChangeHandler.kt | 2 +- .../taskpool/core/task/TaskAggregate.kt | 5 ++++- 4 files changed, 26 insertions(+), 15 deletions(-) delete mode 100644 core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/JacksonExtensions.kt diff --git a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/JacksonExtensions.kt b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/JacksonExtensions.kt deleted file mode 100644 index 090af6d87..000000000 --- a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/JacksonExtensions.kt +++ /dev/null @@ -1,13 +0,0 @@ -package io.holunda.polyflow.taskpool.core - -import com.fasterxml.jackson.databind.ObjectMapper -import io.holunda.polyflow.bus.jackson.configurePolyflowJacksonObjectMapper - -/** - * Configures object mapper. - */ -@Deprecated( - replaceWith = ReplaceWith("io.holunda.polyflow.bus.jackson.configurePolyflowJacksonObjectMapper()"), - message = "Moved to separate artifact polyflow-bus-jackson" -) -fun ObjectMapper.configureTaskpoolJacksonObjectMapper(): ObjectMapper = configurePolyflowJacksonObjectMapper() diff --git a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt index 6b31cffed..5fe428ddc 100755 --- a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt +++ b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt @@ -1,13 +1,18 @@ package io.holunda.polyflow.taskpool.core +import com.fasterxml.jackson.databind.ObjectMapper +import io.holunda.polyflow.bus.jackson.JsonAutoDetectAnyVisibility import io.holunda.polyflow.taskpool.core.process.ProcessDefinitionAggregate import io.holunda.polyflow.taskpool.core.process.ProcessInstanceAggregate import io.holunda.polyflow.taskpool.core.task.TaskAggregate +import org.axonframework.common.caching.Cache +import org.axonframework.common.caching.WeakReferenceCache import org.axonframework.eventsourcing.EventSourcingRepository import org.axonframework.eventsourcing.eventstore.EventStore import org.axonframework.messaging.annotation.ParameterResolverFactory import org.axonframework.modelling.command.Aggregate import org.axonframework.modelling.command.AggregateNotFoundException +import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration @@ -22,6 +27,7 @@ class TaskPoolCoreConfiguration { companion object { const val TASK_AGGREGATE_REPOSITORY = "taskAggregateRepository" + const val TASK_CACHE = "taskCache" const val PROCESS_DEFINITION_AGGREGATE_REPOSITORY = "processDefinitionAggregateRepository" const val PROCESS_INSTANCE_AGGREGATE_REPOSITORY = "processInstanceAggregateRepository" } @@ -62,6 +68,16 @@ class TaskPoolCoreConfiguration { .build() } + @Autowired + fun configureJackson(objectMapper: ObjectMapper) { + objectMapper.configurePolyflowJacksonObjectMapperForTaskPool() + } + + /** + * Use weak reference cache. + */ + @Bean(TASK_CACHE) + fun taskCache(): Cache = WeakReferenceCache() } /** @@ -89,3 +105,8 @@ fun Optional.ifPresentOrElse(presentConsumer: (T) -> Unit, missingCallbac } } +fun ObjectMapper.configurePolyflowJacksonObjectMapperForTaskPool(): ObjectMapper { + addMixIn(TaskAggregate::class.java, JsonAutoDetectAnyVisibility::class.java) + return this +} + diff --git a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/process/ProcessInstanceVariablesChangeHandler.kt b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/process/ProcessInstanceVariablesChangeHandler.kt index b5cfb745c..aa15b0904 100644 --- a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/process/ProcessInstanceVariablesChangeHandler.kt +++ b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/process/ProcessInstanceVariablesChangeHandler.kt @@ -7,7 +7,7 @@ import org.springframework.context.annotation.Lazy import org.springframework.stereotype.Component /** - * This handler makes sure that an update of variables can be send without a create of the process instance.. + * This handler makes sure that an update of variables can be sent without a create of the process instance. */ @Component class ProcessInstanceVariablesChangeHandler( diff --git a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/task/TaskAggregate.kt b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/task/TaskAggregate.kt index b7554eaa2..087d1d4cf 100755 --- a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/task/TaskAggregate.kt +++ b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/task/TaskAggregate.kt @@ -15,7 +15,10 @@ import org.axonframework.spring.stereotype.Aggregate /** * Main representation of the tasks available in the system. */ -@Aggregate(repository = TaskPoolCoreConfiguration.TASK_AGGREGATE_REPOSITORY) +@Aggregate( + repository = TaskPoolCoreConfiguration.TASK_AGGREGATE_REPOSITORY, + cache = TaskPoolCoreConfiguration.TASK_CACHE, +) class TaskAggregate() { companion object : KLogging()