Java style accessors for AbstractFSM #22592
This commit is contained in:
parent
363ca39f52
commit
07e88300bc
24 changed files with 85 additions and 58 deletions
|
|
@ -398,7 +398,7 @@ public class ActorDocTest extends AbstractJavaTest {
|
|||
getSender().tell("service unavailable, shutting down", getSelf())
|
||||
)
|
||||
.match(Terminated.class, t -> t.actor().equals(worker), t ->
|
||||
getContext().stop(self())
|
||||
getContext().stop(getSelf())
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
|
@ -716,7 +716,7 @@ public class ActorDocTest extends AbstractJavaTest {
|
|||
getContext().become(active(ref));
|
||||
})
|
||||
.match(ActorIdentity.class, id -> !id.getActorRef().isPresent(), id -> {
|
||||
getContext().stop(self());
|
||||
getContext().stop(getSelf());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
@ -724,7 +724,7 @@ public class ActorDocTest extends AbstractJavaTest {
|
|||
final AbstractActor.Receive active(final ActorRef another) {
|
||||
return receiveBuilder()
|
||||
.match(Terminated.class, t -> t.actor().equals(another), t ->
|
||||
getContext().stop(self())
|
||||
getContext().stop(getSelf())
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
package jdocs.actor.japi;
|
||||
package jdocs.actor;
|
||||
|
||||
//#all
|
||||
//#imports
|
||||
|
|
@ -14,6 +14,7 @@ import akka.actor.*;
|
|||
import akka.dispatch.Mapper;
|
||||
import akka.event.LoggingReceive;
|
||||
import akka.japi.pf.DeciderBuilder;
|
||||
import akka.pattern.Patterns;
|
||||
import akka.util.Timeout;
|
||||
import com.typesafe.config.Config;
|
||||
import com.typesafe.config.ConfigFactory;
|
||||
|
|
@ -27,10 +28,10 @@ import static akka.actor.SupervisorStrategy.escalate;
|
|||
import static akka.pattern.Patterns.ask;
|
||||
import static akka.pattern.Patterns.pipe;
|
||||
|
||||
import static jdocs.actor.japi.FaultHandlingDocSample.WorkerApi.*;
|
||||
import static jdocs.actor.japi.FaultHandlingDocSample.CounterServiceApi.*;
|
||||
import static jdocs.actor.japi.FaultHandlingDocSample.CounterApi.*;
|
||||
import static jdocs.actor.japi.FaultHandlingDocSample.StorageApi.*;
|
||||
import static jdocs.actor.FaultHandlingDocSample.WorkerApi.*;
|
||||
import static jdocs.actor.FaultHandlingDocSample.CounterServiceApi.*;
|
||||
import static jdocs.actor.FaultHandlingDocSample.CounterApi.*;
|
||||
import static jdocs.actor.FaultHandlingDocSample.StorageApi.*;
|
||||
|
||||
//#imports
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ public class FaultHandlingDocSample {
|
|||
counterService.tell(new Increment(1), getSelf());
|
||||
counterService.tell(new Increment(1), getSelf());
|
||||
// Send current progress to the initial sender
|
||||
pipe(ask(counterService, GetCurrentCount, askTimeout)
|
||||
pipe(Patterns.ask(counterService, GetCurrentCount, askTimeout)
|
||||
.mapTo(classTag(CurrentCount.class))
|
||||
.map(new Mapper<CurrentCount, Progress>() {
|
||||
public Progress apply(CurrentCount c) {
|
||||
|
|
@ -39,7 +39,7 @@ public class Buncher extends AbstractFSM<State, Data> {
|
|||
// reuse this matcher
|
||||
final UnitMatch<Data> m = UnitMatch.create(
|
||||
matchData(Todo.class,
|
||||
todo -> todo.getTarget().tell(new Batch(todo.getQueue()), self())));
|
||||
todo -> todo.getTarget().tell(new Batch(todo.getQueue()), getSelf())));
|
||||
m.match(stateData());
|
||||
}).
|
||||
state(Idle, Active, () -> {/* Do something here */}));
|
||||
|
|
|
|||
|
|
@ -131,10 +131,10 @@ public class FSMDocTest extends AbstractJavaTest {
|
|||
log().warning("Failure in state " + state + " with data " + data + "\n" +
|
||||
"Events leading up to this point:\n\t" + lastEvents);
|
||||
//#logging-fsm
|
||||
target.tell(reason.cause(), self());
|
||||
target.tell(state, self());
|
||||
target.tell(data, self());
|
||||
target.tell(lastEvents, self());
|
||||
target.tell(reason.cause(), getSelf());
|
||||
target.tell(state, getSelf());
|
||||
target.tell(data, getSelf());
|
||||
target.tell(lastEvents, getSelf());
|
||||
//#logging-fsm
|
||||
})
|
||||
);
|
||||
|
|
@ -143,11 +143,11 @@ public class FSMDocTest extends AbstractJavaTest {
|
|||
startWith(SomeState, Data.Foo);
|
||||
when(SomeState, matchEvent(ActorRef.class, Data.class, (ref, data) -> {
|
||||
target = ref;
|
||||
target.tell("going active", self());
|
||||
target.tell("going active", getSelf());
|
||||
return goTo(Active);
|
||||
}));
|
||||
when(Active, matchEventEquals("stop", (event, data) -> {
|
||||
target.tell("stopping", self());
|
||||
target.tell("stopping", getSelf());
|
||||
return stop(new Failure("This is not the error you're looking for"));
|
||||
}));
|
||||
initialize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue