Skip to content

Commit

Permalink
added some binding examples
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-higgins committed Mar 16, 2024
1 parent 6dd95cf commit 856fc87
Showing 6 changed files with 159 additions and 0 deletions.
21 changes: 21 additions & 0 deletions reference-examples/generation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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>com.fluxtion.example</groupId>
<artifactId>reference-examples</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>generation</artifactId>
<name>reference-example :: generation</name>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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");
}
}
1 change: 1 addition & 0 deletions reference-examples/pom.xml
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
<modules>
<module>racing</module>
<module>runtime-execution</module>
<module>generation</module>
</modules>

<!-- <dependencies>-->

0 comments on commit 856fc87

Please sign in to comment.