+act,sam,doc #3940 Added receive setter for Java Lambda actors

* Added a setter for Java lambda actors to "hide" the not so nice looking type signature of the "receive" method.
* Updated docs to reflect the changes.
* Converted samples to use the new setter.
This commit is contained in:
Björn Antonsson 2014-03-20 12:05:32 +01:00
parent 30ae25a90c
commit 723c931d16
23 changed files with 683 additions and 570 deletions

View file

@ -64,12 +64,12 @@ public class FaultHandlingTest {
//#strategy
@Override
public PartialFunction<Object, BoxedUnit> receive() {
return ReceiveBuilder.
public Supervisor() {
receive(ReceiveBuilder.
match(Props.class, props -> {
sender().tell(context().actorOf(props), self());
}).build();
}).build()
);
}
}
@ -94,12 +94,12 @@ public class FaultHandlingTest {
//#strategy2
@Override
public PartialFunction<Object, BoxedUnit> receive() {
return ReceiveBuilder.
public Supervisor2() {
receive(ReceiveBuilder.
match(Props.class, props -> {
sender().tell(context().actorOf(props), self());
}).build();
}).build()
);
}
@Override
@ -115,12 +115,12 @@ public class FaultHandlingTest {
public class Child extends AbstractActor {
int state = 0;
@Override
public PartialFunction<Object, BoxedUnit> receive() {
return ReceiveBuilder.
public Child() {
receive(ReceiveBuilder.
match(Exception.class, exception -> { throw exception; }).
match(Integer.class, i -> state = i).
matchEquals("get", s -> sender().tell(state, self())).build();
matchEquals("get", s -> sender().tell(state, self())).build()
);
}
}