-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac059c9
commit b129526
Showing
9 changed files
with
68 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Human Adapter | ||
|
||
The Human Adapter is a Gateway Framework example that treats the user as the external system. Once configured and running The Human Adapter creates a GUI window for interaction. Users can publish a value, and they can set and get the current service state. The example illustrates how to publish values and correctly react to service state changes. | ||
|
||
![A running Human Adapter service](screen-shot.png) | ||
|
||
## Configuration | ||
|
||
Configuration is deliberately simple. A service takes two parameters. | ||
|
||
1. `greeting`'` - a string greeting to display in the GUI so the user can differentiate multiple services | ||
2. `topic` - A Diffusion topic path to which values should be published./ |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
15 changes: 7 additions & 8 deletions
15
...iffusion-adapter/src/main/java/com/diffusiondata/example/adapter/human/EventHandlers.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 |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package com.diffusiondata.example.adapter.human; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public class EventHandlers<T> extends ArrayList<Consumer<T>> { | ||
public EventHandlers(int initialCapacity) { | ||
super(initialCapacity); | ||
} | ||
public class EventHandlers<T> { | ||
private List<Consumer<T>> consumers = new ArrayList<>(); | ||
|
||
public EventHandlers() { | ||
this(1); | ||
void dispatch(T event) { | ||
consumers.forEach(l -> l.accept(event)); | ||
} | ||
|
||
void dispatch(T event) { | ||
this.forEach(l -> l.accept(event)); | ||
public void add(Consumer<T> handler) { | ||
consumers.add(handler); | ||
} | ||
} |
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