Skip to content

Commit

Permalink
minor additions
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Apr 26, 2024
1 parent c40728d commit 60ec33d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
}
Expand Down Expand Up @@ -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()
}

/**
Expand Down Expand Up @@ -89,3 +105,8 @@ fun <T> Optional<T>.ifPresentOrElse(presentConsumer: (T) -> Unit, missingCallbac
}
}

fun ObjectMapper.configurePolyflowJacksonObjectMapperForTaskPool(): ObjectMapper {
addMixIn(TaskAggregate::class.java, JsonAutoDetectAnyVisibility::class.java)
return this
}

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 60ec33d

Please sign in to comment.