Merge branch 'master' into wip-2053d-actorbased-remote-drewhk

This commit is contained in:
Endre Sándor Varga 2012-11-21 11:44:39 +01:00
commit 0f0c5cb17a
160 changed files with 2071 additions and 1089 deletions

View file

@ -27,10 +27,11 @@ import akka.testkit.ErrorFilter;
import akka.testkit.EventFilter;
import akka.testkit.TestEvent;
import static java.util.concurrent.TimeUnit.SECONDS;
import static akka.japi.Util.immutableSeq;
import akka.japi.Function;
import scala.Option;
import scala.collection.JavaConverters;
import scala.collection.Seq;
import scala.collection.immutable.Seq;
import org.junit.Test;
import org.junit.BeforeClass;
@ -219,8 +220,7 @@ public class FaultHandlingTestBase {
//#testkit
public <A> Seq<A> seq(A... args) {
return JavaConverters.collectionAsScalaIterableConverter(
java.util.Arrays.asList(args)).asScala().toSeq();
return immutableSeq(args);
}
//#testkit
}

View file

@ -351,24 +351,23 @@ public class UntypedActorDocTestBase {
static
//#stash
public class ActorWithProtocol extends UntypedActorWithStash {
private Boolean isOpen = false;
public void onReceive(Object msg) {
if (isOpen) {
if (msg.equals("write")) {
// do writing...
} else if (msg.equals("close")) {
unstashAll();
isOpen = false;
} else {
stash();
}
if (msg.equals("open")) {
unstashAll();
getContext().become(new Procedure<Object>() {
public void apply(Object msg) throws Exception {
if (msg.equals("write")) {
// do writing...
} else if (msg.equals("close")) {
unstashAll();
getContext().unbecome();
} else {
stash();
}
}
}, false); // add behavior on top instead of replacing
} else {
if (msg.equals("open")) {
unstashAll();
isOpen = true;
} else {
stash();
}
stash();
}
}
}

View file

@ -32,9 +32,9 @@ public class UntypedActorSwapper {
@Override
public void apply(Object message) {
log.info("Ho");
getContext().unbecome(); // resets the latest 'become' (just for fun)
getContext().unbecome(); // resets the latest 'become'
}
});
}, false); // this signals stacking of the new behavior
} else {
unhandled(message);
}

View file

@ -119,5 +119,4 @@ public class LoggingDocTestBase {
}
}
//#deadletter-actor
}

View file

@ -11,6 +11,7 @@ import static docs.jrouting.CustomRouterDocTestBase.Message.RepublicanVote;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.After;
@ -69,7 +70,7 @@ public class CustomRouterDocTestBase {
//#supervision
final SupervisorStrategy strategy =
new OneForOneStrategy(5, Duration.create("1 minute"),
new Class<?>[] { Exception.class });
Collections.<Class<? extends Throwable>>singletonList(Exception.class));
final ActorRef router = system.actorOf(new Props(MyActor.class)
.withRouter(new RoundRobinRouter(5).withSupervisorStrategy(strategy)));
//#supervision
@ -179,16 +180,14 @@ public class CustomRouterDocTestBase {
//#crRoutingLogic
return new CustomRoute() {
@Override
public Iterable<Destination> destinationsFor(ActorRef sender, Object msg) {
public scala.collection.immutable.Seq<Destination> destinationsFor(ActorRef sender, Object msg) {
switch ((Message) msg) {
case DemocratVote:
case DemocratCountResult:
return Arrays.asList(
new Destination[] { new Destination(sender, democratActor) });
return akka.japi.Util.immutableSingletonSeq(new Destination(sender, democratActor));
case RepublicanVote:
case RepublicanCountResult:
return Arrays.asList(
new Destination[] { new Destination(sender, republicanActor) });
return akka.japi.Util.immutableSingletonSeq(new Destination(sender, republicanActor));
default:
throw new IllegalArgumentException("Unknown message: " + msg);
}