-
Notifications
You must be signed in to change notification settings - Fork 9
[#29] Feature/aggregate with immutable identifier #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zambrovski
wants to merge
19
commits into
AxonFramework:master
Choose a base branch
from
holixon:feature/immutable_aggregate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5501a9f
wip: working manual configuration, no tests for autoconfigure, no spb…
zambrovski 63944ac
forgot starter
zambrovski 7813f8a
Merge branch 'master' into feature/immutable_aggregate
zambrovski b9b2879
move example, all-open for spring
zambrovski d1a3d31
get rid of unneeded annotation
zambrovski 9818081
socs
zambrovski d77d1d2
adopted to changes
zambrovski 7f6c3ad
creation callbacks
zambrovski 5af77a8
adopted changes
zambrovski 73cdbe6
add factory method
zambrovski 892f57b
fix docs, add helper method
zambrovski 62a4e4d
Merge branch 'master' into feature/immutable_aggregate
zambrovski 0065514
feature: reacted to comments of @smcvb
zambrovski 1b5df0a
Merge branch 'master' into feature/immutable_aggregate
zambrovski c1a7041
Merge branch 'master' into feature/immutable_aggregate
zambrovski 091cceb
Merge branch 'master' into feature/immutable_aggregate
zambrovski 5c05225
Merge pull request #6 from AxonFramework/master
zambrovski 32d1b8e
Merge branch 'AxonFramework:master' into master
zambrovski fa62102
Merge branch 'master' into feature/immutable_aggregate
zambrovski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2010-2020. Axon Framework | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<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> | ||
|
||
<name>Axon Framework - Kotlin Extension Example</name> | ||
<description>Module for the Kotlin Extension Example of Axon Framework</description> | ||
|
||
<parent> | ||
<groupId>org.axonframework.extensions.kotlin</groupId> | ||
<artifactId>axon-kotlin-parent</artifactId> | ||
<version>0.3.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>axon-kotlin-example</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.axonframework.extensions.kotlin</groupId> | ||
<artifactId>axon-kotlin-springboot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.axonframework</groupId> | ||
<artifactId>axon-spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.microutils</groupId> | ||
<artifactId>kotlin-logging-jvm</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
74 changes: 74 additions & 0 deletions
74
...rc/main/kotlin/org/axonframework/extension/kotlin/example/AxonKotlinExampleApplication.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2020. Axon Framework | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.axonframework.extension.kotlin.example | ||
|
||
import mu.KLogging | ||
import org.axonframework.config.Configurer | ||
import org.axonframework.eventhandling.EventBus | ||
import org.axonframework.eventhandling.EventMessage | ||
import org.axonframework.eventhandling.interceptors.EventLoggingInterceptor | ||
import org.axonframework.eventhandling.tokenstore.TokenStore | ||
import org.axonframework.eventhandling.tokenstore.inmemory.InMemoryTokenStore | ||
import org.axonframework.eventsourcing.eventstore.EmbeddedEventStore | ||
import org.axonframework.eventsourcing.eventstore.EventStore | ||
import org.axonframework.eventsourcing.eventstore.inmemory.InMemoryEventStorageEngine | ||
import org.axonframework.extension.kotlin.spring.EnableAggregateWithImmutableIdentifierScan | ||
import org.axonframework.messaging.interceptors.LoggingInterceptor | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.SpringApplication | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.context.annotation.Bean | ||
|
||
/** | ||
* Starting point. | ||
* @param args CLI parameters. | ||
*/ | ||
fun main(args: Array<String>) { | ||
SpringApplication.run(AxonKotlinExampleApplication::class.java, *args) | ||
} | ||
|
||
/** | ||
* Main example application class. | ||
*/ | ||
@SpringBootApplication | ||
@EnableAggregateWithImmutableIdentifierScan | ||
class AxonKotlinExampleApplication { | ||
|
||
companion object : KLogging() | ||
|
||
/** | ||
* Configures to use in-memory embedded event store. | ||
*/ | ||
@Bean | ||
fun eventStore(): EventStore = EmbeddedEventStore.builder().storageEngine(InMemoryEventStorageEngine()).build() | ||
|
||
/** | ||
* Configure logging interceptor. | ||
*/ | ||
@Autowired | ||
fun configureEventHandlingInterceptors(eventBus: EventBus) { | ||
eventBus.registerDispatchInterceptor(EventLoggingInterceptor()) | ||
} | ||
|
||
/** | ||
* Configures to use in-memory token store. | ||
*/ | ||
@Bean | ||
fun tokenStore(): TokenStore = InMemoryTokenStore() | ||
|
||
} | ||
|
||
|
68 changes: 68 additions & 0 deletions
68
kotlin-example/src/main/kotlin/org/axonframework/extension/kotlin/example/api/Commands.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2020. Axon Framework | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.axonframework.extension.kotlin.example.api | ||
|
||
import org.axonframework.extension.kotlin.example.core.BankAccountIdentifier | ||
import org.axonframework.modelling.command.TargetAggregateIdentifier | ||
import javax.validation.constraints.Min | ||
|
||
/** | ||
* Create account. | ||
*/ | ||
data class CreateBankAccountCommand( | ||
@TargetAggregateIdentifier | ||
val bankAccountId: String, | ||
@Min(value = 0, message = "Overdraft limit must not be less than zero") | ||
val overdraftLimit: Long | ||
) | ||
|
||
/** | ||
* Create advanced account. | ||
*/ | ||
data class CreateAdvancedBankAccountCommand( | ||
@TargetAggregateIdentifier | ||
val bankAccountId: BankAccountIdentifier, | ||
@Min(value = 0, message = "Overdraft limit must not be less than zero") | ||
val overdraftLimit: Long | ||
) | ||
|
||
|
||
/** | ||
* Deposit money. | ||
*/ | ||
data class DepositMoneyCommand( | ||
@TargetAggregateIdentifier | ||
val bankAccountId: String, | ||
val amountOfMoney: Long | ||
) | ||
|
||
/** | ||
* Withdraw money. | ||
*/ | ||
data class WithdrawMoneyCommand( | ||
@TargetAggregateIdentifier | ||
val bankAccountId: String, | ||
val amountOfMoney: Long | ||
) | ||
|
||
/** | ||
* Return money if transfer is not possible. | ||
*/ | ||
data class ReturnMoneyOfFailedBankTransferCommand( | ||
@TargetAggregateIdentifier | ||
val bankAccountId: String, | ||
val amount: Long | ||
) |
80 changes: 80 additions & 0 deletions
80
kotlin-example/src/main/kotlin/org/axonframework/extension/kotlin/example/api/Events.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2020. Axon Framework | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.axonframework.extension.kotlin.example.api | ||
|
||
import org.axonframework.extension.kotlin.example.core.BankAccountIdentifier | ||
|
||
/** | ||
* Account created. | ||
*/ | ||
data class BankAccountCreatedEvent( | ||
val id: String, | ||
val overdraftLimit: Long | ||
) | ||
|
||
/** | ||
* Advanced account created. | ||
*/ | ||
data class AdvancedBankAccountCreatedEvent( | ||
val id: BankAccountIdentifier, | ||
val overdraftLimit: Long | ||
) | ||
|
||
/** | ||
* Collecting event for increasing amount. | ||
*/ | ||
sealed class MoneyAddedEvent( | ||
open val bankAccountId: String, | ||
open val amount: Long | ||
) | ||
|
||
/** | ||
* Money deposited. | ||
*/ | ||
data class MoneyDepositedEvent(override val bankAccountId: String, override val amount: Long) : MoneyAddedEvent(bankAccountId, amount) | ||
|
||
/** | ||
* Money returned. | ||
*/ | ||
data class MoneyOfFailedBankTransferReturnedEvent(override val bankAccountId: String, override val amount: Long) : MoneyAddedEvent(bankAccountId, amount) | ||
|
||
/** | ||
* Money received via transfer. | ||
*/ | ||
data class DestinationBankAccountCreditedEvent(override val bankAccountId: String, override val amount: Long, val bankTransferId: String) : MoneyAddedEvent(bankAccountId, amount) | ||
|
||
/** | ||
* Collecting event for decreasing amount. | ||
*/ | ||
sealed class MoneySubtractedEvent( | ||
open val bankAccountId: String, | ||
open val amount: Long | ||
) | ||
|
||
/** | ||
* Money withdrawn. | ||
*/ | ||
data class MoneyWithdrawnEvent(override val bankAccountId: String, override val amount: Long) : MoneySubtractedEvent(bankAccountId, amount) | ||
|
||
/** | ||
* Money transferred. | ||
*/ | ||
data class SourceBankAccountDebitedEvent(override val bankAccountId: String, override val amount: Long, val bankTransferId: String) : MoneySubtractedEvent(bankAccountId, amount) | ||
|
||
/** | ||
* Money transfer rejected. | ||
*/ | ||
data class SourceBankAccountDebitRejectedEvent(val bankTransferId: String) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.