diff --git a/reference-examples/generation/pom.xml b/reference-examples/generation/pom.xml new file mode 100644 index 0000000..9e76aff --- /dev/null +++ b/reference-examples/generation/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.fluxtion.example + reference-examples + 1.0.0-SNAPSHOT + + + generation + reference-example :: generation + + + 21 + 21 + UTF-8 + + + \ No newline at end of file diff --git a/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImperativeAdd.java b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImperativeAdd.java new file mode 100644 index 0000000..7a9c2c8 --- /dev/null +++ b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImperativeAdd.java @@ -0,0 +1,21 @@ +package com.fluxtion.example.reference; + +import com.fluxtion.compiler.Fluxtion; +import com.fluxtion.runtime.annotations.OnEventHandler; + +public class ImperativeAdd { + + public static class MyNode { + @OnEventHandler + public boolean handleStringEvent(String stringToProcess) { + System.out.println("received:" + stringToProcess); + return true; + } + } + + public static void main(String[] args) { + var processor = Fluxtion.interpret(cfg -> cfg.addNode(new MyNode())); + processor.init(); + processor.onEvent("TEST"); + } +} diff --git a/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImperativeAddMultiple.java b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImperativeAddMultiple.java new file mode 100644 index 0000000..c4bff40 --- /dev/null +++ b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImperativeAddMultiple.java @@ -0,0 +1,32 @@ +package com.fluxtion.example.reference; + +import com.fluxtion.compiler.Fluxtion; +import com.fluxtion.runtime.annotations.OnEventHandler; + +public class ImperativeAddMultiple { + + public static class MyNode { + + private final String name; + + public MyNode(String name) { + this.name = name; + } + + @OnEventHandler + public boolean handleStringEvent(String stringToProcess) { + System.out.println(name + " received:" + stringToProcess); + return true; + } + } + + public static void main(String[] args) { + var processor = Fluxtion.interpret(cfg -> { + cfg.addNode(new MyNode("node_1")); + cfg.addNode(new MyNode("node_2")); + cfg.addNode(new MyNode("node_3")); + }); + processor.init(); + processor.onEvent("TEST"); + } +} diff --git a/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImplicitAdd.java b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImplicitAdd.java new file mode 100644 index 0000000..8173207 --- /dev/null +++ b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/ImplicitAdd.java @@ -0,0 +1,36 @@ +package com.fluxtion.example.reference; + +import com.fluxtion.compiler.Fluxtion; +import com.fluxtion.runtime.annotations.OnEventHandler; +import com.fluxtion.runtime.annotations.OnTrigger; + +public class ImplicitAdd { + + public static class MyNode { + @OnEventHandler + public boolean handleStringEvent(String stringToProcess) { + System.out.println("MyNode::received:" + stringToProcess); + return true; + } + } + + public static class Root1 { + private final MyNode myNode; + + public Root1(MyNode myNode) { + this.myNode = myNode; + } + + @OnTrigger + public boolean trigger() { + System.out.println("Root1::triggered"); + return true; + } + } + + public static void main(String[] args) { + var processor = Fluxtion.interpret(cfg -> cfg.addNode(new Root1(new MyNode()))); + processor.init(); + processor.onEvent("TEST"); + } +} diff --git a/reference-examples/generation/src/main/java/com/fluxtion/example/reference/SharedReference.java b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/SharedReference.java new file mode 100644 index 0000000..6a8f5e4 --- /dev/null +++ b/reference-examples/generation/src/main/java/com/fluxtion/example/reference/SharedReference.java @@ -0,0 +1,48 @@ +package com.fluxtion.example.reference; + +import com.fluxtion.compiler.Fluxtion; +import com.fluxtion.runtime.annotations.OnEventHandler; +import com.fluxtion.runtime.annotations.OnTrigger; + +public class SharedReference { + + public static class MyNode { + private final String name; + + public MyNode(String name) { + this.name = name; + } + + @OnEventHandler + public boolean handleStringEvent(String stringToProcess) { + System.out.println(name + "::received:" + stringToProcess); + return true; + } + } + + public static class Root1 { + private final String name; + private final MyNode myNode; + + public Root1(String name, MyNode myNode) { + this.name = name; + this.myNode = myNode; + } + + @OnTrigger + public boolean trigger() { + System.out.println(name + "::triggered"); + return true; + } + } + + public static void main(String[] args) { + var processor = Fluxtion.interpret(cfg -> { + MyNode myNode1 = new MyNode("myNode_1"); + cfg.addNode(new Root1("root_1", myNode1)); + cfg.addNode(new Root1("root_2", myNode1)); + }); + processor.init(); + processor.onEvent("TEST"); + } +} diff --git a/reference-examples/pom.xml b/reference-examples/pom.xml index 935fe3e..5530f84 100644 --- a/reference-examples/pom.xml +++ b/reference-examples/pom.xml @@ -24,6 +24,7 @@ racing runtime-execution + generation