Issue 24594: Integration with sbt-headers and initial header population

This commit is contained in:
Konrad `ktoso` Malawski 2018-03-13 23:45:55 +09:00 committed by Johan Andrén
parent 95afa04a7a
commit 563c7fbcf0
1558 changed files with 2995 additions and 490 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (C) 2016-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs
import org.scalatest.junit.JUnitSuite

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
import akka.actor.ActorRef;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
import jdocs.AbstractJavaTest;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
//#all

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
import akka.actor.*;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
import java.util.ArrayList;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
import akka.actor.AbstractActor;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
//#my-stopping-actor

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
//#imports1

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.actor;
//#imports

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.agent;
import static org.junit.Assert.*;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#CamelActivation
import akka.actor.ActorRef;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
import akka.actor.ActorSystem;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Consumer1
import akka.camel.CamelMessage;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Consumer2
import akka.camel.CamelMessage;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Consumer3
import akka.actor.Status;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Consumer4
import akka.camel.CamelMessage;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#CustomRoute
import akka.actor.ActorRef;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
import akka.actor.ActorRef;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#ErrorThrowingConsumer
import akka.actor.Status;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Producer1

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#RouteResponse
import akka.actor.ActorRef;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#ProducerTemplate
import akka.actor.UntypedAbstractActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Consumer-mina

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
import akka.actor.*;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Oneway
import akka.camel.javaapi.UntypedProducerActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Producer
import akka.camel.javaapi.UntypedProducerActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#Producer1
import akka.camel.javaapi.UntypedProducerActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
import java.util.HashMap;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#RequestProducerTemplate
import akka.actor.AbstractActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#CustomRoute
import akka.actor.UntypedAbstractActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#RouteResponse
import akka.actor.UntypedAbstractActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.camel;
//#TransformOutgoingMessage
import akka.camel.CamelMessage;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.circuitbreaker;
//#imports1

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.circuitbreaker;
import akka.actor.AbstractActor;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.circuitbreaker;
import akka.actor.ActorRef;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import akka.testkit.javadsl.TestKit;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.math.BigInteger;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.util.Arrays;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.util.concurrent.TimeUnit;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.math.BigInteger;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
//#metrics-listener

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import akka.actor.AbstractActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import akka.actor.AbstractActor;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.util.ArrayList;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.io.Serializable;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.util.ArrayList;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import com.typesafe.config.ConfigFactory;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import com.typesafe.config.Config;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import akka.cluster.routing.ClusterRouterGroup;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.util.HashMap;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import static jdocs.cluster.TransformationMessages.BACKEND_REGISTRATION;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import static jdocs.cluster.TransformationMessages.BACKEND_REGISTRATION;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.cluster;
import java.io.Serializable;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.config;
import akka.actor.ActorSystem;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata;
//#data-bot

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata;
import java.util.HashSet;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata;
import static java.util.concurrent.TimeUnit.SECONDS;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata;
import java.util.HashSet;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata.protobuf;
//#serializer

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata.protobuf;
//#serializer

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.ddata.protobuf;
import jdocs.ddata.TwoPhaseSet;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.dispatcher;
import akka.dispatch.ControlMessage;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.dispatcher;
//#mailbox-implementation-example

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.event;
import akka.event.japi.EventBus;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.event;
//#imports

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.extension;
//#imports

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.extension;
//#imports

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.future;
//#context-dispatcher

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.future;
//#imports1

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.io;
import akka.actor.ActorRef;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.io.japi;
import java.util.concurrent.CountDownLatch;

View file

@ -1,49 +1,50 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.pattern;
import akka.actor.*;
import akka.pattern.Backoff;
import akka.pattern.BackoffSupervisor;
import akka.testkit.TestActors.EchoActor;
//#backoff-imports
import scala.concurrent.duration.Duration;
//#backoff-imports
import java.util.concurrent.TimeUnit;
public class BackoffSupervisorDocTest {
void exampleStop (ActorSystem system) {
//#backoff-stop
final Props childProps = Props.create(EchoActor.class);
final Props supervisorProps = BackoffSupervisor.props(
Backoff.onStop(
childProps,
"myEcho",
Duration.create(3, TimeUnit.SECONDS),
Duration.create(30, TimeUnit.SECONDS),
0.2)); // adds 20% "noise" to vary the intervals slightly
system.actorOf(supervisorProps, "echoSupervisor");
//#backoff-stop
}
void exampleFailure (ActorSystem system) {
//#backoff-fail
final Props childProps = Props.create(EchoActor.class);
final Props supervisorProps = BackoffSupervisor.props(
Backoff.onFailure(
childProps,
"myEcho",
Duration.create(3, TimeUnit.SECONDS),
Duration.create(30, TimeUnit.SECONDS),
0.2)); // adds 20% "noise" to vary the intervals slightly
system.actorOf(supervisorProps, "echoSupervisor");
//#backoff-fail
}
}
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.pattern;
import akka.actor.*;
import akka.pattern.Backoff;
import akka.pattern.BackoffSupervisor;
import akka.testkit.TestActors.EchoActor;
//#backoff-imports
import scala.concurrent.duration.Duration;
//#backoff-imports
import java.util.concurrent.TimeUnit;
public class BackoffSupervisorDocTest {
void exampleStop (ActorSystem system) {
//#backoff-stop
final Props childProps = Props.create(EchoActor.class);
final Props supervisorProps = BackoffSupervisor.props(
Backoff.onStop(
childProps,
"myEcho",
Duration.create(3, TimeUnit.SECONDS),
Duration.create(30, TimeUnit.SECONDS),
0.2)); // adds 20% "noise" to vary the intervals slightly
system.actorOf(supervisorProps, "echoSupervisor");
//#backoff-stop
}
void exampleFailure (ActorSystem system) {
//#backoff-fail
final Props childProps = Props.create(EchoActor.class);
final Props supervisorProps = BackoffSupervisor.props(
Backoff.onFailure(
childProps,
"myEcho",
Duration.create(3, TimeUnit.SECONDS),
Duration.create(30, TimeUnit.SECONDS),
0.2)); // adds 20% "noise" to vary the intervals slightly
system.actorOf(supervisorProps, "echoSupervisor");
//#backoff-fail
}
}

View file

@ -1,106 +1,110 @@
package jdocs.pattern;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeoutException;
import scala.concurrent.duration.Duration;
import akka.actor.ActorKilledException;
import akka.actor.ActorRef;
import akka.actor.ActorRefFactory;
import akka.actor.Cancellable;
import akka.actor.OneForOneStrategy;
import akka.actor.Props;
import akka.actor.Scheduler;
import akka.actor.Status;
import akka.actor.SupervisorStrategy;
import akka.actor.Terminated;
import akka.actor.AbstractActor;
import akka.pattern.PatternsCS;
import akka.util.Timeout;
public class SupervisedAsk {
private static class AskParam {
Props props;
Object message;
Timeout timeout;
AskParam(Props props, Object message, Timeout timeout) {
this.props = props;
this.message = message;
this.timeout = timeout;
}
}
private static class AskTimeout {
}
public static class AskSupervisorCreator extends AbstractActor {
@Override
public Receive createReceive() {
return receiveBuilder()
.match(AskParam.class, message -> {
ActorRef supervisor = getContext().actorOf(
Props.create(AskSupervisor.class));
supervisor.forward(message, getContext());
})
.build();
}
}
public static class AskSupervisor extends AbstractActor {
private ActorRef targetActor;
private ActorRef caller;
private AskParam askParam;
private Cancellable timeoutMessage;
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(0, Duration.Zero(), cause -> {
caller.tell(new Status.Failure(cause), getSelf());
return SupervisorStrategy.stop();
});
}
@Override
public Receive createReceive() {
return receiveBuilder()
.match(AskParam.class, message -> {
askParam = message;
caller = getSender();
targetActor = getContext().actorOf(askParam.props);
getContext().watch(targetActor);
targetActor.forward(askParam.message, getContext());
Scheduler scheduler = getContext().getSystem().scheduler();
timeoutMessage = scheduler.scheduleOnce(askParam.timeout.duration(),
getSelf(), new AskTimeout(), getContext().dispatcher(), null);
})
.match(Terminated.class, message -> {
Throwable ex = new ActorKilledException("Target actor terminated.");
caller.tell(new Status.Failure(ex), getSelf());
timeoutMessage.cancel();
getContext().stop(getSelf());
})
.match(AskTimeout.class, message -> {
Throwable ex = new TimeoutException("Target actor timed out after "
+ askParam.timeout.toString());
caller.tell(new Status.Failure(ex), getSelf());
getContext().stop(getSelf());
})
.build();
}
}
public static CompletionStage<Object> askOf(ActorRef supervisorCreator, Props props,
Object message, Timeout timeout) {
AskParam param = new AskParam(props, message, timeout);
return PatternsCS.ask(supervisorCreator, param, timeout);
}
synchronized public static ActorRef createSupervisorCreator(
ActorRefFactory factory) {
return factory.actorOf(Props.create(AskSupervisorCreator.class));
}
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.pattern;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeoutException;
import scala.concurrent.duration.Duration;
import akka.actor.ActorKilledException;
import akka.actor.ActorRef;
import akka.actor.ActorRefFactory;
import akka.actor.Cancellable;
import akka.actor.OneForOneStrategy;
import akka.actor.Props;
import akka.actor.Scheduler;
import akka.actor.Status;
import akka.actor.SupervisorStrategy;
import akka.actor.Terminated;
import akka.actor.AbstractActor;
import akka.pattern.PatternsCS;
import akka.util.Timeout;
public class SupervisedAsk {
private static class AskParam {
Props props;
Object message;
Timeout timeout;
AskParam(Props props, Object message, Timeout timeout) {
this.props = props;
this.message = message;
this.timeout = timeout;
}
}
private static class AskTimeout {
}
public static class AskSupervisorCreator extends AbstractActor {
@Override
public Receive createReceive() {
return receiveBuilder()
.match(AskParam.class, message -> {
ActorRef supervisor = getContext().actorOf(
Props.create(AskSupervisor.class));
supervisor.forward(message, getContext());
})
.build();
}
}
public static class AskSupervisor extends AbstractActor {
private ActorRef targetActor;
private ActorRef caller;
private AskParam askParam;
private Cancellable timeoutMessage;
@Override
public SupervisorStrategy supervisorStrategy() {
return new OneForOneStrategy(0, Duration.Zero(), cause -> {
caller.tell(new Status.Failure(cause), getSelf());
return SupervisorStrategy.stop();
});
}
@Override
public Receive createReceive() {
return receiveBuilder()
.match(AskParam.class, message -> {
askParam = message;
caller = getSender();
targetActor = getContext().actorOf(askParam.props);
getContext().watch(targetActor);
targetActor.forward(askParam.message, getContext());
Scheduler scheduler = getContext().getSystem().scheduler();
timeoutMessage = scheduler.scheduleOnce(askParam.timeout.duration(),
getSelf(), new AskTimeout(), getContext().dispatcher(), null);
})
.match(Terminated.class, message -> {
Throwable ex = new ActorKilledException("Target actor terminated.");
caller.tell(new Status.Failure(ex), getSelf());
timeoutMessage.cancel();
getContext().stop(getSelf());
})
.match(AskTimeout.class, message -> {
Throwable ex = new TimeoutException("Target actor timed out after "
+ askParam.timeout.toString());
caller.tell(new Status.Failure(ex), getSelf());
getContext().stop(getSelf());
})
.build();
}
}
public static CompletionStage<Object> askOf(ActorRef supervisorCreator, Props props,
Object message, Timeout timeout) {
AskParam param = new AskParam(props, message, timeout);
return PatternsCS.ask(supervisorCreator, param, timeout);
}
synchronized public static ActorRef createSupervisorCreator(
ActorRefFactory factory) {
return factory.actorOf(Props.create(AskSupervisorCreator.class));
}
}

View file

@ -1,30 +1,34 @@
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;
}
}
}
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
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;
}
}
}

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.persistence;
import akka.actor.*;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.remoting;
import akka.testkit.AkkaJUnitActorSystemResource;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.routing;
import akka.testkit.AkkaJUnitActorSystemResource;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.routing;
import akka.routing.FromConfig;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.routing;
//#group

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.routing;
import akka.testkit.AkkaJUnitActorSystemResource;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.serialization;
import java.io.UnsupportedEncodingException;

View file

@ -1,6 +1,7 @@
/*
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.actor.ActorRef;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import java.nio.ByteOrder;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import java.util.Arrays;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <http://www.lightbend.com/>
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import static org.junit.Assert.assertEquals;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import static org.junit.Assert.assertEquals;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <http://www.lightbend.com/>
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <http://www.lightbend.com/>
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.NotUsed;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import java.util.Arrays;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import static org.junit.Assert.*;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.Done;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.Done;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.NotUsed;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
//#main-app

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import java.util.stream.Stream;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2016-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
//#stream-imports

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.NotUsed;

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import akka.actor.ActorRef;

View file

@ -1,6 +1,7 @@
/**
* Copyright (C) 2014-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream;
import java.util.Arrays;

Some files were not shown because too many files have changed in this diff Show more