!act,sam #3889 Adding Activator template FSM/become for Java with Lambda support
* Dining Hakkers Activator template for FSM and become * Cleaup of FSM event matchers to be more usable and consistent
This commit is contained in:
parent
6af33381b3
commit
07e361c684
30 changed files with 1026 additions and 103 deletions
73
akka-samples/akka-sample-fsm-java-lambda/tutorial/index.html
Normal file
73
akka-samples/akka-sample-fsm-java-lambda/tutorial/index.html
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<!-- <html> -->
|
||||
<head>
|
||||
<title>Akka FSM in Java with Lambdas</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div>
|
||||
<h2>Finite State Machine in Actors</h2>
|
||||
|
||||
<p>
|
||||
This sample is an adaptation of
|
||||
<a href="http://www.dalnefre.com/wp/2010/08/dining-philosophers-in-humus/" target="_blank">Dining Hakkers</a>.
|
||||
It illustrates how state and behavior can be managed within
|
||||
an Actor with two different approaches; using <code>become</code> and using
|
||||
the <code>AbstractFSM</code> class.
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h2>Dining Hakkers with Become</h2>
|
||||
|
||||
<p>
|
||||
Open <a href="#code/src/main/java/sample/become/DiningHakkersOnBecome.java" class="shortcut">DiningHakkersOnBecome.java</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It illustrates how current behavior can be replaced with <code>context.become</code>.
|
||||
Note that no <code>var</code> members are used, instead the state is encoded in the current
|
||||
behavior and its parameters.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Go to the <a href="#run" class="shortcut">Run</a> tab, and start the application main class
|
||||
<code>sample.become.DiningHakkersOnBecome</code>.
|
||||
In the log output you can see the actions of the <code>Hakker</code> actors.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Read more about <code>become</code> in
|
||||
<a href="http://doc.akka.io/docs/akka/2.3-SNAPSHOT/java/lambda-actors.html#Become_Unbecome" target="_blank">the documentation</a>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h2>Dining Hakkers with FSM</h2>
|
||||
|
||||
<p>
|
||||
Open <a href="#code/src/main/java/sample/fsm/DiningHakkersOnFsm.java" class="shortcut">DiningHakkersOnFsm.java</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It illustrates how the states and transitions can be defined with the <code>akka.actor.AbstractFSM</code> class.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Go to the <a href="#run" class="shortcut">Run</a> tab, and start the application main class
|
||||
<code>sample.fsm.DiningHakkersOnFsm</code>.
|
||||
In the log output you can see the actions of the <code>Hakker</code> actors.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Read more about <code>akka.actor.FSM</code> in
|
||||
<a href="http://doc.akka.io/docs/akka/2.3-SNAPSHOT/java/lambda-fsm.html" target="_blank">the documentation</a>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue