Skip to content

Commit

Permalink
Added new simple example which uses simple polyflow view
Browse files Browse the repository at this point in the history
  • Loading branch information
p-wunderlich committed Jul 1, 2024
1 parent c76960c commit 239b164
Show file tree
Hide file tree
Showing 31 changed files with 2,530 additions and 0 deletions.
1 change: 1 addition & 0 deletions scenarios/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</properties>

<modules>
<module>single-node-simple</module>
<module>single-node-jpa</module>
<module>single-node-jpa-maria</module>
<module>distributed-axon-server</module>
Expand Down
141 changes: 141 additions & 0 deletions scenarios/single-node-simple/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-scenario-root</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>polyflow-example-scenario-single-node-simple</artifactId>
<name>examples/${project.artifactId}</name>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

<dependencies>
<!-- Frontends see below in the profile-->
<!-- Core -->
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-taskpool-core</artifactId>
</dependency>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-datapool-core</artifactId>
</dependency>

<!-- Tasklist -->
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-tasklist-backend</artifactId>
</dependency>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-form-url-resolver</artifactId>
</dependency>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-view-simple</artifactId>
</dependency>

<!-- Process application -->
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-approval-backend</artifactId>
<exclusions>
<exclusion>
<groupId>org.axonframework</groupId>
<artifactId>axon-server-connector</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-infrastructure</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<!-- for packaging springboot application -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-process-backend</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>frontend</id>
<activation>
<property>
<name>!skipFrontend</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-approval-forms</artifactId>
</dependency>
<dependency>
<groupId>io.holunda.polyflow</groupId>
<artifactId>polyflow-example-tasklist-angular</artifactId>
</dependency>
</dependencies>
</profile>

<profile>
<id>camunda-ce</id>
<activation>
<property>
<name>!camunda-ee</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
</dependency>
</dependencies>
</profile>

<profile>
<id>camunda-ee</id>
<activation>
<property>
<name>camunda-ee</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp-ee</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package io.holunda.polyflow.example.process.approval

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.thoughtworks.xstream.XStream
import com.thoughtworks.xstream.security.AnyTypePermission
import io.holixon.axon.gateway.query.RevisionValue
import io.holunda.polyflow.bus.jackson.config.FallbackPayloadObjectMapperAutoConfiguration
import io.holunda.polyflow.bus.jackson.configurePolyflowJacksonObjectMapper
import io.holunda.polyflow.datapool.core.EnablePolyflowDataPool
import io.holunda.polyflow.example.tasklist.EnableTasklist
import io.holunda.polyflow.example.users.EnableExampleUsers
import io.holunda.polyflow.taskpool.core.EnablePolyflowTaskPool
import io.holunda.polyflow.urlresolver.EnablePropertyBasedFormUrlResolver
import io.holunda.polyflow.view.simple.EnablePolyflowSimpleView
import org.axonframework.commandhandling.CommandMessage
import org.axonframework.common.jpa.EntityManagerProvider
import org.axonframework.common.transaction.TransactionManager
import org.axonframework.eventhandling.deadletter.jpa.DeadLetterEntry
import org.axonframework.eventhandling.tokenstore.jpa.TokenEntry
import org.axonframework.eventsourcing.eventstore.EventStorageEngine
import org.axonframework.eventsourcing.eventstore.jpa.DomainEventEntry
import org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine
import org.axonframework.messaging.correlation.CorrelationDataProvider
import org.axonframework.messaging.correlation.MessageOriginProvider
import org.axonframework.messaging.correlation.MultiCorrelationDataProvider
import org.axonframework.messaging.correlation.SimpleCorrelationDataProvider
import org.axonframework.modelling.saga.repository.jpa.SagaEntry
import org.axonframework.serialization.Serializer
import org.axonframework.serialization.xml.XStreamSerializer
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Primary

/**
* Starts the single node application.
*/
@Suppress("UNUSED_PARAMETER")
fun main(args: Array<String>) {
runApplication<SingleNodeSimpleExampleProcessApplication>().let { }
}

/**
* Application being everything in one node:
* - process application
* - task pool core
* - data pool core
* - task list
*/
@SpringBootApplication
@EnableExampleUsers
@EnablePolyflowTaskPool
@EnablePolyflowDataPool
@EnableTasklist
@EnablePropertyBasedFormUrlResolver
@EnablePolyflowSimpleView
@EntityScan(
basePackageClasses = [
DomainEventEntry::class, SagaEntry::class, TokenEntry::class, DeadLetterEntry::class
]
)
class SingleNodeSimpleExampleProcessApplication {

/**
* Custom object mapper.
*/
@Bean
@Primary
@Qualifier(FallbackPayloadObjectMapperAutoConfiguration.PAYLOAD_OBJECT_MAPPER)
fun myObjectMapper(): ObjectMapper {
return jacksonObjectMapper()
.registerModule(JavaTimeModule())
.configurePolyflowJacksonObjectMapper()
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
}

/**
* Factory function creating correlation data provider for revision information.
* We don't want to explicitly pump revision meta data from command to event.
*/
@Bean
fun revisionAwareCorrelationDataProvider(): CorrelationDataProvider {
return MultiCorrelationDataProvider<CommandMessage<Any>>(
listOf(
MessageOriginProvider(),
SimpleCorrelationDataProvider(RevisionValue.REVISION_KEY)
)
)
}

@Bean
@Qualifier("eventSerializer")
fun mySerializer(): Serializer = XStreamSerializer.builder().xStream(XStream().apply { addPermission(AnyTypePermission.ANY) }).build()

@Bean
fun storageEngine(
emp: EntityManagerProvider,
txManager: TransactionManager,
@Qualifier("eventSerializer")
eventSerializer: Serializer
): EventStorageEngine = JpaEventStorageEngine.builder()
.entityManagerProvider(emp)
.eventSerializer(eventSerializer)
.snapshotSerializer(eventSerializer)
.transactionManager(txManager)
.build()
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package io.holunda.polyflow.serializer.gdpr

annotation class GdprData()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package io.holunda.polyflow.serializer.gdpr

class GdprSerializationPocConfiguration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.holunda.polyflow.serializer.gdpr

import org.axonframework.serialization.SerializedObject
import org.axonframework.serialization.Serializer


class GdprSerializer(
private val serializer: Serializer,
private val protectionDetection: ProtectionStrategy
) : Serializer by serializer {

override fun <T : Any?> serialize(`object`: Any?, expectedRepresentation: Class<T>): SerializedObject<T> {
val result = if(protectionDetection.shouldEncrypt(`object`)) {
protectionDetection.encrypt(`object`)
} else {
`object`
}
return serializer.serialize(result, expectedRepresentation)
}

override fun <S : Any?, T : Any?> deserialize(serializedObject: SerializedObject<S>): T {
val deserialized = serializer.deserialize<S, T>(serializedObject)
return protectionDetection.decrypt(deserialized)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.holunda.polyflow.serializer.gdpr

import mu.KLogging
import org.axonframework.eventhandling.EventMessage
import org.axonframework.messaging.MessageDispatchInterceptor
import java.util.function.BiFunction

class MYMessageInterceptor : MessageDispatchInterceptor<EventMessage<Any>> {

companion object: KLogging()

override fun handle(messages: MutableList<out EventMessage<Any>>): BiFunction<Int, EventMessage<Any>, EventMessage<Any>> {
return BiFunction { index, event -> event.apply {
logger.info { "Handling $index, $event" }
} }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.holunda.polyflow.serializer.gdpr

/**
* Strategy to detect the protection.
*/
sealed interface ProtectionStrategy {
fun shouldEncrypt(any: Any?): Boolean
fun <T> encrypt(value: T): T
fun <T> decrypt(value: T): T


class NoneProtectionStrategy: ProtectionStrategy {
override fun shouldEncrypt(any: Any?): Boolean = false
override fun <T> encrypt(value: T): T = value
override fun <T> decrypt(value: T): T = value
}
}
Loading

0 comments on commit 239b164

Please sign in to comment.