Setup a new Java sc project Create sc folder mkdir ./sc Create `sc.yaml' with the following content module : " " language : " java" importPathSeparator : " ." enableFileCapitalization : true forceUnitSetupRegeneration : true ctlDir : " src/controller" templates :
- dir : " sc/templates" imports :
- repoOwner : " SoenkeD" repoName : " sc-java-templates" repoPath : " sc/templates/" localPath : " sc/templates/" Create controller folder mkdir -p ./src/controller/myctl Create PlantUML file ./src/controller/myctl/myctl.plantuml
(must have the same name as the controller) with the following content @startuml Demo
[*] --> DemoState: [ CheckAlwaysTrue ]
[*] -[bold]-> [*]: / Print(The guard needs to be implemented)
DemoState: do / AddMsg(Hello)
DemoState: do / AddMsg(World)
DemoState: do / AddMsg(!)
DemoState --> BurnState: [ CheckAlwaysTrue ] / Print(Go to BurnState)
DemoState -[bold]-> [*]
BurnState: do / Print(Got messages)
BurnState: do / PrintMsgs
BurnState -[bold]-> [*]
(optional) Create a Makefile with the following content sc=~/go/bin/sc
.PHONY: sc
sc:
$(sc) gen --root $(PWD) --name myctl
.PHONY: import
import:
$(sc) import --root $(PWD)
.PHONY: export
export:
$(sc) export --root $(PWD)
.PHONY: compile
compile:
javac -d bin src/*.java
.PHONY: run
run:
java -cp ./bin src/Main
.PHONY: exec
exec: compile run
Create src/Main.java with the following content package src ;
import src .controller .myctl .Initctl ;
import src .controller .myctl .controller .*;
public class Main {
public static void main (String [] args ) {
Ctl ctl = Initctl .initCtl ();
Reconciler reconciler = new Reconciler (
ctl , new ReconcilerInput ()
);
try {
reconciler .reconcile ();
} catch (CtlErr e ) {
System .err .println (e );
}
}
}Import the base templates make import Generate the state machine by running make sc Implement at least the Print action in src/controller/myctl/actions/Print.java Execute your first running state machine with make exec