#22903 Fix code snippeds

* move scala and java sources out of paradox sources
* replace relative paths with $code$ and $akka$
* fix broken includes
This commit is contained in:
Martynas Mickevičius 2017-05-11 11:59:28 +03:00
parent 7bee495749
commit 81df4ff417
384 changed files with 1609 additions and 1602 deletions

View file

@ -0,0 +1,30 @@
package jdocs.pattern;
import akka.actor.ActorRef;
import akka.actor.ActorRefFactory;
import akka.actor.Props;
import akka.actor.AbstractActor;
import akka.util.Timeout;
import scala.concurrent.duration.FiniteDuration;
import java.util.concurrent.CompletionStage;
public class SupervisedAskSpec {
public Object execute(Class<? extends AbstractActor> someActor,
Object message, Timeout timeout, ActorRefFactory actorSystem)
throws Exception {
// example usage
try {
ActorRef supervisorCreator = SupervisedAsk
.createSupervisorCreator(actorSystem);
CompletionStage<Object> finished = SupervisedAsk.askOf(supervisorCreator,
Props.create(someActor), message, timeout);
FiniteDuration d = timeout.duration();
return finished.toCompletableFuture().get(d.length(), d.unit());
} catch (Exception e) {
// exception propagated by supervision
throw e;
}
}
}