Removing akka.actor.Actors since they were deprecated in 2.0.2

This commit is contained in:
Viktor Klang 2012-05-07 20:37:56 +02:00
parent 5c9dff8ad2
commit 57c5dd00e0
11 changed files with 19 additions and 82 deletions

View file

@ -86,9 +86,5 @@ class ReceiveTimeoutSpec extends AkkaSpec {
intercept[TimeoutException] { Await.ready(timeoutLatch, 1 second) } intercept[TimeoutException] { Await.ready(timeoutLatch, 1 second) }
system.stop(timeoutActor) system.stop(timeoutActor)
} }
"have ReceiveTimeout eq to Actors ReceiveTimeout" in {
akka.actor.Actors.receiveTimeout must be theSameInstanceAs (ReceiveTimeout)
}
} }
} }

View file

@ -1,51 +0,0 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor;
/**
* JAVA API for - creating actors, - creating remote actors, - locating actors
*/
public class Actors {
/**
* The message that is sent when an Actor gets a receive timeout.
*
* <pre>
* if (message == receiveTimeout()) {
* // Timed out
* }
* </pre>
*
* @return the single instance of ReceiveTimeout
*/
public final static ReceiveTimeout$ receiveTimeout() {
return ReceiveTimeout$.MODULE$;
}
/**
* The message that when sent to an Actor kills it by throwing an exception.
*
* <pre>
* actor.tell(kill());
* </pre>
*
* @return the single instance of Kill
*/
public final static Kill$ kill() {
return Kill$.MODULE$;
}
/**
* The message that when sent to an Actor shuts it down by calling 'stop'.
*
* <pre>
* actor.tell(poisonPill());
* </pre>
*
* @return the single instance of PoisonPill
*/
public final static PoisonPill$ poisonPill() {
return PoisonPill$.MODULE$;
}
}

View file

@ -217,8 +217,8 @@ trait FSM[S, D] extends Listeners with ActorLogging {
* @param timeout state timeout for the initial state, overriding the default timeout for that state * @param timeout state timeout for the initial state, overriding the default timeout for that state
*/ */
protected final def startWith(stateName: S, protected final def startWith(stateName: S,
stateData: D, stateData: D,
timeout: Timeout = None): Unit = timeout: Timeout = None): Unit =
currentState = FSM.State(stateName, stateData, timeout) currentState = FSM.State(stateName, stateData, timeout)
/** /**

View file

@ -5,7 +5,7 @@ package akka.docs.actor;
import akka.actor.ActorRef; import akka.actor.ActorRef;
import akka.actor.Props; import akka.actor.Props;
import static akka.actor.Actors.*; import akka.actor.PoisonPill;
import akka.actor.UntypedActor; import akka.actor.UntypedActor;
//#context-actorOf //#context-actorOf
@ -16,6 +16,6 @@ public class FirstUntypedActor extends UntypedActor {
public void onReceive(Object message) { public void onReceive(Object message) {
myActor.forward(message, getContext()); myActor.forward(message, getContext());
myActor.tell(poisonPill()); myActor.tell(PoisonPill.getInstance());
} }
} }

View file

@ -4,7 +4,6 @@
package akka.docs.actor; package akka.docs.actor;
//#receive-timeout //#receive-timeout
import akka.actor.Actors;
import akka.actor.ReceiveTimeout; import akka.actor.ReceiveTimeout;
import akka.actor.UntypedActor; import akka.actor.UntypedActor;
import akka.util.Duration; import akka.util.Duration;
@ -18,7 +17,7 @@ public class MyReceivedTimeoutUntypedActor extends UntypedActor {
public void onReceive(Object message) { public void onReceive(Object message) {
if (message.equals("Hello")) { if (message.equals("Hello")) {
getSender().tell("Hello world"); getSender().tell("Hello world");
} else if (message == Actors.receiveTimeout()) { } else if (message == ReceiveTimeout.getInstance()) {
throw new RuntimeException("received timeout"); throw new RuntimeException("received timeout");
} else { } else {
unhandled(message); unhandled(message);

View file

@ -19,7 +19,8 @@ import akka.util.Timeout;
//#import-future //#import-future
//#import-actors //#import-actors
import static akka.actor.Actors.*; import akka.actor.PoisonPill;
import akka.actor.Kill;
//#import-actors //#import-actors
//#import-procedure //#import-procedure
@ -158,7 +159,7 @@ public class UntypedActorDocTestBase {
ActorSystem system = ActorSystem.create("MySystem"); ActorSystem system = ActorSystem.create("MySystem");
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class)); ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
//#poison-pill //#poison-pill
myActor.tell(poisonPill()); myActor.tell(PoisonPill.getInstance());
//#poison-pill //#poison-pill
system.shutdown(); system.shutdown();
} }
@ -168,7 +169,7 @@ public class UntypedActorDocTestBase {
ActorSystem system = ActorSystem.create("MySystem"); ActorSystem system = ActorSystem.create("MySystem");
ActorRef victim = system.actorOf(new Props(MyUntypedActor.class)); ActorRef victim = system.actorOf(new Props(MyUntypedActor.class));
//#kill //#kill
victim.tell(kill()); victim.tell(Kill.getInstance());
//#kill //#kill
system.shutdown(); system.shutdown();
} }

View file

@ -72,7 +72,7 @@ public class FaultHandlingDocSample {
log.info("That's all, shutting down"); log.info("That's all, shutting down");
getContext().system().shutdown(); getContext().system().shutdown();
} }
} else if (msg == Actors.receiveTimeout()) { } else if (msg == ReceiveTimeout.getInstance()) {
// No progress within 15 seconds, ServiceUnavailable // No progress within 15 seconds, ServiceUnavailable
log.error("Shutting down due to unavailable service"); log.error("Shutting down due to unavailable service");
getContext().system().shutdown(); getContext().system().shutdown();

View file

@ -4,27 +4,22 @@
package akka.docs.dispatcher; package akka.docs.dispatcher;
//#imports //#imports
import akka.actor.*;
import akka.actor.ActorRef; import akka.actor.ActorRef;
import akka.actor.Props; import akka.actor.Props;
import akka.dispatch.MessageDispatcher; import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
//#imports //#imports
//#imports-prio //#imports-prio
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.actor.Actors;
import akka.event.Logging; import akka.event.Logging;
import akka.event.LoggingAdapter; import akka.event.LoggingAdapter;
//#imports-prio //#imports-prio
//#imports-prio-mailbox //#imports-prio-mailbox
import akka.actor.ActorContext;
import akka.dispatch.PriorityGenerator; import akka.dispatch.PriorityGenerator;
import akka.dispatch.UnboundedPriorityMailbox; import akka.dispatch.UnboundedPriorityMailbox;
import akka.dispatch.MailboxType;
import akka.dispatch.MessageQueue;
import com.typesafe.config.Config; import com.typesafe.config.Config;
//#imports-prio-mailbox //#imports-prio-mailbox
@ -37,7 +32,6 @@ import static org.junit.Assert.*;
import com.typesafe.config.ConfigFactory; import com.typesafe.config.ConfigFactory;
import akka.actor.ActorSystem;
import akka.docs.actor.MyUntypedActor; import akka.docs.actor.MyUntypedActor;
import akka.docs.actor.UntypedActorDocTestBase.MyActor; import akka.docs.actor.UntypedActorDocTestBase.MyActor;
import akka.testkit.AkkaSpec; import akka.testkit.AkkaSpec;
@ -93,7 +87,7 @@ public class DispatcherDocTestBase {
getSelf().tell("pigdog2"); getSelf().tell("pigdog2");
getSelf().tell("pigdog3"); getSelf().tell("pigdog3");
getSelf().tell("highpriority"); getSelf().tell("highpriority");
getSelf().tell(Actors.poisonPill()); getSelf().tell(PoisonPill.getInstance());
} }
public void onReceive(Object message) { public void onReceive(Object message) {
@ -133,7 +127,7 @@ public class DispatcherDocTestBase {
return 0; // 'highpriority messages should be treated first if possible return 0; // 'highpriority messages should be treated first if possible
else if (message.equals("lowpriority")) else if (message.equals("lowpriority"))
return 2; // 'lowpriority messages should be treated last if possible return 2; // 'lowpriority messages should be treated last if possible
else if (message.equals(Actors.poisonPill())) else if (message.equals(PoisonPill.getInstance()))
return 3; // PoisonPill when no other left return 3; // PoisonPill when no other left
else else
return 1; // By default they go between high and low prio return 1; // By default they go between high and low prio

View file

@ -3,26 +3,26 @@ package akka.docs.camel
object Consumers { object Consumers {
{ {
//#Consumer1 //#Consumer1
import akka.camel.{CamelMessage, Consumer} import akka.camel.{ CamelMessage, Consumer }
class Consumer1 extends Consumer { class Consumer1 extends Consumer {
def endpointUri = "file:data/input/actor" def endpointUri = "file:data/input/actor"
def receive = { def receive = {
case msg: CamelMessage => println("received %s" format msg.bodyAs[String]) case msg: CamelMessage println("received %s" format msg.bodyAs[String])
} }
} }
//#Consumer1 //#Consumer1
} }
{ {
//#Consumer2 //#Consumer2
import akka.camel.{CamelMessage, Consumer} import akka.camel.{ CamelMessage, Consumer }
class Consumer2 extends Consumer { class Consumer2 extends Consumer {
def endpointUri = "jetty:http://localhost:8877/camel/default" def endpointUri = "jetty:http://localhost:8877/camel/default"
def receive = { def receive = {
case msg: CamelMessage => sender ! ("Hello %s" format msg.bodyAs[String]) case msg: CamelMessage sender ! ("Hello %s" format msg.bodyAs[String])
} }
} }
//#Consumer2 //#Consumer2

View file

@ -1,6 +1,5 @@
package akka.spring.foo; package akka.spring.foo;
import static akka.actor.Actors.*;
import akka.actor.ActorRef; import akka.actor.ActorRef;
import akka.actor.UntypedActor; import akka.actor.UntypedActor;

View file

@ -5,7 +5,6 @@
package akka.transactor; package akka.transactor;
import akka.actor.ActorRef; import akka.actor.ActorRef;
import akka.actor.Actors;
import akka.actor.UntypedActor; import akka.actor.UntypedActor;
import scala.concurrent.stm.Ref; import scala.concurrent.stm.Ref;
import scala.concurrent.stm.japi.STM; import scala.concurrent.stm.japi.STM;