-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add no spring example getting started tutorial 6
- Loading branch information
1 parent
049a3d8
commit 04f42f7
Showing
19 changed files
with
1,035 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,57 @@ | ||
<?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> | ||
<groupId>com.fluxtion.example</groupId> | ||
<artifactId>getting-started-tutorial6</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>getting-started :: tutorial 6 :: no spring</name> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<fluxtion.version>9.2.17</fluxtion.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.fluxtion</groupId> | ||
<artifactId>fluxtion-maven-plugin</artifactId> | ||
<version>3.0.14</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>scan</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<!-- RUNTIME SCOPE NO LONGER SUPPLIED BY FLUXTION COMPILER--> | ||
<dependency> | ||
<groupId>com.fluxtion</groupId> | ||
<artifactId>runtime</artifactId> | ||
<version>${fluxtion.version}</version> | ||
</dependency> | ||
<!-- PROVIDED SCOPE--> | ||
<dependency> | ||
<groupId>com.fluxtion</groupId> | ||
<artifactId>compiler</artifactId> | ||
<version>${fluxtion.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.30</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
60 changes: 60 additions & 0 deletions
60
...ial6-lottery-nospring/src/main/java/com/fluxtion/example/cookbook/lottery/LotteryApp.java
This file contains 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,60 @@ | ||
package com.fluxtion.example.cookbook.lottery; | ||
|
||
import com.fluxtion.example.cookbook.lottery.aot.LotteryProcessor; | ||
import com.fluxtion.example.cookbook.lottery.api.LotteryMachine; | ||
import com.fluxtion.example.cookbook.lottery.api.Ticket; | ||
import com.fluxtion.example.cookbook.lottery.api.TicketStore; | ||
import com.fluxtion.example.cookbook.lottery.auditor.FluxtionSlf4jAuditor; | ||
import com.fluxtion.runtime.EventProcessor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* A simple lottery game to demonstrate event processing logic built with Fluxtion | ||
*/ | ||
@Slf4j | ||
public class LotteryApp { | ||
|
||
private static LotteryMachine lotteryMachine; | ||
private static TicketStore ticketStore; | ||
private static EventProcessor<?> lotteryEventProcessor; | ||
|
||
public static void main(String[] args) { | ||
start(log::info, log::info); | ||
//try and buy a ticket - store is closed | ||
ticketStore.buyTicket(new Ticket(12_65_56)); | ||
|
||
//open store and buy ticket | ||
ticketStore.openStore(); | ||
ticketStore.buyTicket(new Ticket(12_65_56)); | ||
ticketStore.buyTicket(new Ticket(36_58_58)); | ||
ticketStore.buyTicket(new Ticket(73_00_12)); | ||
|
||
//bad numbers | ||
ticketStore.buyTicket(new Ticket(25)); | ||
|
||
//close the store and run the lottery | ||
ticketStore.closeStore(); | ||
|
||
//try and buy a ticket - store is closed | ||
ticketStore.buyTicket(new Ticket(12_65_56)); | ||
|
||
//run the lottery | ||
lotteryMachine.selectWinningTicket(); | ||
|
||
//teardown - should print stats | ||
lotteryEventProcessor.tearDown(); | ||
} | ||
|
||
public static void start(Consumer<String> ticketReceiptHandler, Consumer<String> resultsPublisher){ | ||
lotteryEventProcessor = new LotteryProcessor(); | ||
lotteryEventProcessor.init(); | ||
lotteryEventProcessor.setAuditLogProcessor(new FluxtionSlf4jAuditor()); | ||
lotteryMachine = lotteryEventProcessor.getExportedService(); | ||
ticketStore = lotteryEventProcessor.getExportedService(); | ||
lotteryMachine.setResultPublisher(resultsPublisher); | ||
ticketStore.setTicketSalesPublisher(ticketReceiptHandler); | ||
lotteryEventProcessor.start(); | ||
} | ||
} |
Oops, something went wrong.