From 70db2a59f2a45f7b8017f53dbba35d5e394fa58a Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 8 May 2010 00:26:05 +0200 Subject: [PATCH 01/14] Closing ticket 150 --- project/build/AkkaProject.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index f96ff598e8..9f3f120b13 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -337,6 +337,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { mainResources +++ mainDependencies.scalaJars +++ descendents(info.projectPath, "*.conf") +++ + descendents(info.projectPath / "scripts", "run_akka.sh") +++ descendents(info.projectPath / "dist", "*.jar") +++ descendents(info.projectPath / "deploy", "*.jar") +++ descendents(path("lib") ##, "*.jar") +++ From 17e5a126c45fabe2ae17c24fe6117f9e4751643e Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 8 May 2010 02:00:40 +0200 Subject: [PATCH 02/14] Fixing the test --- akka-core/src/test/scala/ActorPatternsTest.scala | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/akka-core/src/test/scala/ActorPatternsTest.scala b/akka-core/src/test/scala/ActorPatternsTest.scala index d300578c05..ea49d370e4 100644 --- a/akka-core/src/test/scala/ActorPatternsTest.scala +++ b/akka-core/src/test/scala/ActorPatternsTest.scala @@ -12,13 +12,14 @@ import org.scalatest.junit.JUnitRunner import org.scalatest.matchers.MustMatchers import org.junit.{Before, After, Test} import scala.collection.mutable.HashSet +import java.util.concurrent.{ CountDownLatch, TimeUnit } @RunWith(classOf[JUnitRunner]) class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMatchers with Logging { import Patterns._ @Test def testDispatcher = { val (testMsg1,testMsg2,testMsg3,testMsg4) = ("test1","test2","test3","test4") - + val latch = new CountDownLatch(1) var targetOk = 0 val t1 = actor { case `testMsg1` => targetOk += 2 @@ -26,7 +27,9 @@ class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMat } val t2 = actor { - case `testMsg3` => targetOk += 8 + case `testMsg3` => + targetOk += 8 + latch.countDown } val d = dispatcherActor { @@ -37,7 +40,8 @@ class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMat d ! testMsg1 d ! testMsg2 d ! testMsg3 - Thread.sleep(1000) + val done = latch.await(5,TimeUnit.SECONDS) + done must be (true) targetOk must be(14) t1.stop t2.stop @@ -54,7 +58,6 @@ class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMat val bar : Any = "bar" l ! foo l ! bar - Thread.sleep(1000) msgs must ( have size (2) and contain (foo) and contain (bar) ) t1.stop l.stop @@ -81,9 +84,7 @@ class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMat d.stop } - @Test def testListener = { - import java.util.concurrent.{ CountDownLatch, TimeUnit } - + @Test def testListener = { val latch = new CountDownLatch(2) val num = new AtomicInteger(0) val i = newActor(() => new Actor with Listeners { From fcc1591f297d6749483a9843e0e0fee0f3ae0f7f Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 8 May 2010 13:31:59 +0200 Subject: [PATCH 03/14] Refactored Actor --- akka-core/src/main/scala/actor/Actor.scala | 53 +++++++--------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/akka-core/src/main/scala/actor/Actor.scala b/akka-core/src/main/scala/actor/Actor.scala index 76fcfa0f15..c82a0dce0a 100644 --- a/akka-core/src/main/scala/actor/Actor.scala +++ b/akka-core/src/main/scala/actor/Actor.scala @@ -423,43 +423,22 @@ final class ActorRef private[akka] () { * If you are sending messages using !! then you have to use reply(..) * to send a reply message to the original sender. If not then the sender will block until the timeout expires. */ - def !![T](message: Any, timeout: Long): Option[T] = { - if (actor.isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages") - if (actor.isRunning) { - val future = actor.postMessageToMailboxAndCreateFutureResultWithTimeout[T](message, timeout, None) - val isActiveObject = message.isInstanceOf[Invocation] - if (isActiveObject && message.asInstanceOf[Invocation].isVoid) - future.asInstanceOf[CompletableFuture[Option[_]]].completeWithResult(None) - try { - future.await - } catch { - case e: FutureTimeoutException => - if (isActiveObject) throw e - else None - } - - if (future.exception.isDefined) throw future.exception.get._2 - else future.result + def !![T](message: Any, timeout: Long = actor.timeout): Option[T] = { + val future = !!![T](message,timeout) + val isActiveObject = message.isInstanceOf[Invocation] + if (isActiveObject && message.asInstanceOf[Invocation].isVoid) + future.asInstanceOf[CompletableFuture[Option[_]]].completeWithResult(None) + try { + future.await + } catch { + case e: FutureTimeoutException => + if (isActiveObject) throw e + else None } - else throw new IllegalStateException( - "Actor has not been started, you need to invoke 'actor.start' before using it") - } - /** - * Sends a message asynchronously and waits on a future for a reply message. - * Uses the time-out defined in the Actor. - *

- * It waits on the reply either until it receives it (in the form of Some(replyMessage)) - * or until the timeout expires (which will return None). E.g. send-and-receive-eventually semantics. - *

- * NOTE: - * Use this method with care. In most cases it is better to use '!' together with the 'sender' member field to - * implement request/response message exchanges. - *

- * If you are sending messages using !! then you have to use reply(..) - * to send a reply message to the original sender. If not then the sender will block until the timeout expires. - */ - def !![T](message: Any)(implicit sender: Option[ActorRef] = None): Option[T] = !![T](message, actor.timeout) + if (future.exception.isDefined) throw future.exception.get._2 + else future.result + } /** * Sends a message asynchronously returns a future holding the eventual reply message. @@ -470,10 +449,10 @@ final class ActorRef private[akka] () { * If you are sending messages using !!! then you have to use reply(..) * to send a reply message to the original sender. If not then the sender will block until the timeout expires. */ - def !!![T](message: Any): Future[T] = { + def !!![T](message: Any, timeout : Long = actor.timeout): Future[T] = { if (actor.isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages") if (actor.isRunning) { - actor.postMessageToMailboxAndCreateFutureResultWithTimeout[T](message, actor.timeout, None) + actor.postMessageToMailboxAndCreateFutureResultWithTimeout[T](message, timeout, None) } else throw new IllegalStateException( "Actor has not been started, you need to invoke 'actor.start' before using it") } From fbefcee8aeaf2acb9b94f30ac49e564451c674d2 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 8 May 2010 15:59:11 +0200 Subject: [PATCH 04/14] newActor(() => refactored --- akka-amqp/src/main/scala/AMQP.scala | 4 ++-- akka-camel/src/main/scala/service/CamelService.scala | 2 +- akka-camel/src/test/scala/ProducerFeatureTest.scala | 12 ++++++------ .../src/test/scala/component/ActorProducerTest.scala | 8 ++++---- .../test/scala/service/CamelServiceFeatureTest.scala | 4 ++-- .../test/scala/service/PublishRequestorTest.scala | 6 +++--- akka-core/src/main/scala/actor/Actor.scala | 6 +++--- akka-core/src/main/scala/routing/Patterns.scala | 6 +++--- akka-core/src/main/scala/stm/DataFlowVariable.scala | 6 +++--- .../test/scala/ActorFireForgetRequestReplySpec.scala | 4 ++-- akka-core/src/test/scala/ActorPatternsTest.scala | 2 +- ...xecutorBasedEventDrivenDispatcherActorsSpec.scala | 4 ++-- ...rBasedEventDrivenWorkStealingDispatcherSpec.scala | 4 ++-- akka-core/src/test/scala/InMemoryActorSpec.scala | 12 ++++++------ ...sedThreadPoolEventDrivenDispatcherActorSpec.scala | 2 +- akka-core/src/test/scala/ThreadBasedActorSpec.scala | 2 +- .../src/test/scala/ThreadBasedDispatcherSpec.scala | 6 +++--- .../akka-sample-camel/src/main/scala/Boot.scala | 10 +++++----- .../akka-sample-chat/src/main/scala/ChatServer.scala | 2 +- .../src/main/scala/RedisPubSub.scala | 4 ++-- 20 files changed, 53 insertions(+), 53 deletions(-) diff --git a/akka-amqp/src/main/scala/AMQP.scala b/akka-amqp/src/main/scala/AMQP.scala index 84f52088e7..96d6584df1 100644 --- a/akka-amqp/src/main/scala/AMQP.scala +++ b/akka-amqp/src/main/scala/AMQP.scala @@ -94,7 +94,7 @@ object AMQP { returnListener: Option[ReturnListener], shutdownListener: Option[ShutdownListener], initReconnectDelay: Long): ActorRef = { - val producer = newActor(() => new Producer( + val producer = actorOf( new Producer( new ConnectionFactory(config), hostname, port, exchangeName, @@ -117,7 +117,7 @@ object AMQP { durable: Boolean, autoDelete: Boolean, configurationArguments: Map[String, AnyRef]): ActorRef = { - val consumer = newActor(() => new Consumer( + val consumer = actorOf( new Consumer( new ConnectionFactory(config), hostname, port, exchangeName, diff --git a/akka-camel/src/main/scala/service/CamelService.scala b/akka-camel/src/main/scala/service/CamelService.scala index 42cae6f44f..fbd1a4cb93 100644 --- a/akka-camel/src/main/scala/service/CamelService.scala +++ b/akka-camel/src/main/scala/service/CamelService.scala @@ -21,7 +21,7 @@ trait CamelService extends Bootable with Logging { import CamelContextManager._ private[camel] val consumerPublisher = newActor[ConsumerPublisher] - private[camel] val publishRequestor = newActor(() => new PublishRequestor(consumerPublisher)) + private[camel] val publishRequestor = actorOf(new PublishRequestor(consumerPublisher)) /** * Starts the CamelService. Any started actor that is a consumer actor will be (asynchronously) diff --git a/akka-camel/src/test/scala/ProducerFeatureTest.scala b/akka-camel/src/test/scala/ProducerFeatureTest.scala index fdd14edda3..acba99fde9 100644 --- a/akka-camel/src/test/scala/ProducerFeatureTest.scala +++ b/akka-camel/src/test/scala/ProducerFeatureTest.scala @@ -36,7 +36,7 @@ class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with Before scenario("produce message sync and receive response") { given("a registered synchronous two-way producer for endpoint direct:producer-test-2") - val producer = newActor(() => new TestProducer("direct:producer-test-2") with Sync) + val producer = actorOf(new TestProducer("direct:producer-test-2") with Sync) producer.start when("a test message is sent to the producer") @@ -50,7 +50,7 @@ class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with Before scenario("produce message async and receive response") { given("a registered asynchronous two-way producer for endpoint direct:producer-test-2") - val producer = newActor(() => new TestProducer("direct:producer-test-2")) + val producer = actorOf(new TestProducer("direct:producer-test-2")) producer.start when("a test message is sent to the producer") @@ -64,7 +64,7 @@ class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with Before scenario("produce message sync and receive failure") { given("a registered synchronous two-way producer for endpoint direct:producer-test-2") - val producer = newActor(() => new TestProducer("direct:producer-test-2") with Sync) + val producer = actorOf(new TestProducer("direct:producer-test-2") with Sync) producer.start when("a fail message is sent to the producer") @@ -80,7 +80,7 @@ class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with Before scenario("produce message async and receive failure") { given("a registered asynchronous two-way producer for endpoint direct:producer-test-2") - val producer = newActor(() => new TestProducer("direct:producer-test-2")) + val producer = actorOf(new TestProducer("direct:producer-test-2")) producer.start when("a fail message is sent to the producer") @@ -96,7 +96,7 @@ class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with Before scenario("produce message sync oneway") { given("a registered synchronous one-way producer for endpoint direct:producer-test-1") - val producer = newActor(() => new TestProducer("direct:producer-test-1") with Sync with Oneway) + val producer = actorOf(new TestProducer("direct:producer-test-1") with Sync with Oneway) producer.start when("a test message is sent to the producer") @@ -109,7 +109,7 @@ class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with Before scenario("produce message async oneway") { given("a registered asynchronous one-way producer for endpoint direct:producer-test-1") - val producer = newActor(() => new TestProducer("direct:producer-test-1") with Oneway) + val producer = actorOf(new TestProducer("direct:producer-test-1") with Oneway) producer.start when("a test message is sent to the producer") diff --git a/akka-camel/src/test/scala/component/ActorProducerTest.scala b/akka-camel/src/test/scala/component/ActorProducerTest.scala index 5f7059295f..93f69d5255 100644 --- a/akka-camel/src/test/scala/component/ActorProducerTest.scala +++ b/akka-camel/src/test/scala/component/ActorProducerTest.scala @@ -18,7 +18,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll { @After def tearDown = ActorRegistry.shutdownAll @Test def shouldSendMessageToActor = { - val actor = newActor(() => new Tester with Retain with Countdown[Message]) + val actor = actorOf(new Tester with Retain with Countdown[Message]) val endpoint = mockEndpoint("actor:uuid:%s" format actor.uuid) val exchange = endpoint.createExchange(ExchangePattern.InOnly) actor.start @@ -31,7 +31,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll { } @Test def shouldSendMessageToActorAndReceiveResponse = { - val actor = newActor(() => new Tester with Respond { + val actor = actorOf(new Tester with Respond { override def response(msg: Message) = Message(super.response(msg), Map("k2" -> "v2")) }) val endpoint = mockEndpoint("actor:uuid:%s" format actor.uuid) @@ -45,7 +45,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll { } @Test def shouldSendMessageToActorAndReceiveFailure = { - val actor = newActor(() => new Tester with Respond { + val actor = actorOf(new Tester with Respond { override def response(msg: Message) = Failure(new Exception("testmsg"), Map("k3" -> "v3")) }) val endpoint = mockEndpoint("actor:uuid:%s" format actor.uuid) @@ -60,7 +60,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll { } @Test def shouldSendMessageToActorAndTimeout: Unit = { - val actor = newActor(() => new Tester { + val actor = actorOf(new Tester { timeout = 1 }) val endpoint = mockEndpoint("actor:uuid:%s" format actor.uuid) diff --git a/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala b/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala index b876fe14c8..951ce21fe8 100644 --- a/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala +++ b/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala @@ -38,7 +38,7 @@ class CamelServiceFeatureTest extends FeatureSpec with BeforeAndAfterAll with Gi override protected def beforeAll = { ActorRegistry.shutdownAll // register test consumer before starting the CamelService - newActor(() => new TestConsumer("direct:publish-test-1")).start + actorOf(new TestConsumer("direct:publish-test-1")).start // Consigure a custom camel route CamelContextManager.init CamelContextManager.context.addRoutes(new TestRoute) @@ -61,7 +61,7 @@ class CamelServiceFeatureTest extends FeatureSpec with BeforeAndAfterAll with Gi given("two consumer actors registered before and after CamelService startup") service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].expectPublishCount(1) - newActor(() => new TestConsumer("direct:publish-test-2")).start + actorOf(new TestConsumer("direct:publish-test-2")).start when("requests are sent to these actors") service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].awaitPublish diff --git a/akka-camel/src/test/scala/service/PublishRequestorTest.scala b/akka-camel/src/test/scala/service/PublishRequestorTest.scala index 59e9696ee4..985f18f142 100644 --- a/akka-camel/src/test/scala/service/PublishRequestorTest.scala +++ b/akka-camel/src/test/scala/service/PublishRequestorTest.scala @@ -24,12 +24,12 @@ class PublishRequestorTest extends JUnitSuite { @After def tearDown = ActorRegistry.shutdownAll @Test def shouldReceivePublishRequestOnActorRegisteredEvent = { - val consumer = newActor(() => new Actor with Consumer { + val consumer = actorOf(new Actor with Consumer { def endpointUri = "mock:test" protected def receive = null }).start - val publisher = newActor(() => new PublisherMock with Countdown[Publish]) - val requestor = newActor(() => new PublishRequestor(publisher)) + val publisher = actorOf(new PublisherMock with Countdown[Publish]) + val requestor = actorOf(new PublishRequestor(publisher)) publisher.start requestor.start requestor.!(ActorRegistered(consumer))(None) diff --git a/akka-core/src/main/scala/actor/Actor.scala b/akka-core/src/main/scala/actor/Actor.scala index c82a0dce0a..a39898879a 100644 --- a/akka-core/src/main/scala/actor/Actor.scala +++ b/akka-core/src/main/scala/actor/Actor.scala @@ -97,13 +97,13 @@ object Actor extends Logging { * This function should NOT be used for remote actors. *

    *   import Actor._
-   *   val actor = newActor(() => new MyActor)
+   *   val actor = actorOf(new MyActor)
    *   actor.start
    *   actor ! message
    *   actor.stop
    * 
*/ - def newActor(factory: () => Actor): ActorRef = new ActorRef(factory) + def actorOf(factory: => Actor): ActorRef = new ActorRef(() => factory) /** * Use to create an anonymous event-driven actor. @@ -288,7 +288,7 @@ object ActorRef { *
  *   import Actor._
  * 
- *   val actor = newActor(() => new MyActor(...))
+ *   val actor = actorOf(new MyActor(...))
  *   actor.start
  *   actor ! message
  *   actor.stop
diff --git a/akka-core/src/main/scala/routing/Patterns.scala b/akka-core/src/main/scala/routing/Patterns.scala
index 258847b3fc..cf3eb079ff 100644
--- a/akka-core/src/main/scala/routing/Patterns.scala
+++ b/akka-core/src/main/scala/routing/Patterns.scala
@@ -27,7 +27,7 @@ object Patterns {
   /** Creates a LoadBalancer from the thunk-supplied InfiniteIterator
    */
    def loadBalancerActor(actors: => InfiniteIterator[ActorRef]): ActorRef = 
-    newActor(() => new Actor with LoadBalancer {
+    actorOf(new Actor with LoadBalancer {
       start
       val seq = actors
     })
@@ -35,7 +35,7 @@ object Patterns {
   /** Creates a Dispatcher given a routing and a message-transforming function
    */
    def dispatcherActor(routing: PF[Any, ActorRef], msgTransformer: (Any) => Any): ActorRef = 
-    newActor(() => new Actor with Dispatcher {
+    actorOf(new Actor with Dispatcher {
       start
       override def transform(msg: Any) = msgTransformer(msg)
       def routes = routing
@@ -43,7 +43,7 @@ object Patterns {
 
   /** Creates a Dispatcher given a routing
    */
-   def dispatcherActor(routing: PF[Any, ActorRef]): ActorRef = newActor(() => new Actor with Dispatcher {
+   def dispatcherActor(routing: PF[Any, ActorRef]): ActorRef = actorOf(new Actor with Dispatcher {
     start
     def routes = routing
   })
diff --git a/akka-core/src/main/scala/stm/DataFlowVariable.scala b/akka-core/src/main/scala/stm/DataFlowVariable.scala
index 5b4826550a..8bd692b916 100644
--- a/akka-core/src/main/scala/stm/DataFlowVariable.scala
+++ b/akka-core/src/main/scala/stm/DataFlowVariable.scala
@@ -27,7 +27,7 @@ import se.scalablesolutions.akka.actor.Actor
 import se.scalablesolutions.akka.dispatch.CompletableFuture
 
   def thread(body: => Unit) = {
-    val thread = newActor(() => new IsolatedEventBasedThread(body)).start
+    val thread = actorOf(new IsolatedEventBasedThread(body)).start
     thread ! Start
     thread
   }
@@ -98,7 +98,7 @@ import se.scalablesolutions.akka.dispatch.CompletableFuture
       }
     }
 
-    private[this] val in = newActor(() => new In(this))
+    private[this] val in = actorOf(new In(this))
 
     def <<(ref: DataFlowVariable[T]) = in ! Set(ref())
 
@@ -108,7 +108,7 @@ import se.scalablesolutions.akka.dispatch.CompletableFuture
       val ref = value.get
       if (ref.isDefined) ref.get
       else {
-        val out = newActor(() => new Out(this))
+        val out = actorOf(new Out(this))
         blockedReaders.offer(out)
         val result = out !! Get
         out ! Exit
diff --git a/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala b/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala
index 50e655d97d..9b8cffae16 100644
--- a/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala
+++ b/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala
@@ -48,7 +48,7 @@ class ActorFireForgetRequestReplySpec extends JUnitSuite {
     state.finished.reset
     val replyActor = newActor[ReplyActor]
     replyActor.start
-    val senderActor = newActor(() => new SenderActor(replyActor))
+    val senderActor = actorOf(new SenderActor(replyActor))
     senderActor.start
     senderActor ! "Init"
     try { state.finished.await(1L, TimeUnit.SECONDS) } 
@@ -61,7 +61,7 @@ class ActorFireForgetRequestReplySpec extends JUnitSuite {
     state.finished.reset
     val replyActor = newActor[ReplyActor]
     replyActor.start
-    val senderActor = newActor(() => new SenderActor(replyActor))
+    val senderActor = actorOf(new SenderActor(replyActor))
     senderActor.start
     senderActor ! "InitImplicit"
     try { state.finished.await(1L, TimeUnit.SECONDS) } 
diff --git a/akka-core/src/test/scala/ActorPatternsTest.scala b/akka-core/src/test/scala/ActorPatternsTest.scala
index ea49d370e4..a85d1f66c8 100644
--- a/akka-core/src/test/scala/ActorPatternsTest.scala
+++ b/akka-core/src/test/scala/ActorPatternsTest.scala
@@ -87,7 +87,7 @@ class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMat
   @Test def testListener = {  
     val latch = new CountDownLatch(2)
     val num = new AtomicInteger(0)
-    val i = newActor(() => new Actor with Listeners {
+    val i = actorOf(new Actor with Listeners {
       def receive = listenerManagement orElse {
         case "foo" =>  gossip("bar")
       }
diff --git a/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorsSpec.scala b/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorsSpec.scala
index 91ba57d5c7..551e0484c2 100644
--- a/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorsSpec.scala
+++ b/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorsSpec.scala
@@ -39,8 +39,8 @@ class ExecutorBasedEventDrivenDispatcherActorsSpec extends JUnitSuite with MustM
   @Test def slowActorShouldntBlockFastActor = {
     val sFinished = new CountDownLatch(50)
     val fFinished = new CountDownLatch(10)
-    val s = newActor(() => new SlowActor(sFinished)).start
-    val f = newActor(() => new FastActor(fFinished)).start
+    val s = actorOf(new SlowActor(sFinished)).start
+    val f = actorOf(new FastActor(fFinished)).start
      
     // send a lot of stuff to s
     for (i <- 1 to 50) {
diff --git a/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala b/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala
index 6ab034d8ec..4a1bf52370 100644
--- a/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala
+++ b/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala
@@ -57,8 +57,8 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherSpec extends JUnitSuite with
   @Test def fastActorShouldStealWorkFromSlowActor = {
     val finishedCounter = new CountDownLatch(110)
 
-    val slow = newActor(() => new DelayableActor("slow", 50, finishedCounter)).start
-    val fast = newActor(() => new DelayableActor("fast", 10, finishedCounter)).start
+    val slow = actorOf(new DelayableActor("slow", 50, finishedCounter)).start
+    val fast = actorOf(new DelayableActor("fast", 10, finishedCounter)).start
 
     for (i <- 1 to 100) {
       // send most work to slow actor
diff --git a/akka-core/src/test/scala/InMemoryActorSpec.scala b/akka-core/src/test/scala/InMemoryActorSpec.scala
index c9380eb34f..a88e8c50c6 100644
--- a/akka-core/src/test/scala/InMemoryActorSpec.scala
+++ b/akka-core/src/test/scala/InMemoryActorSpec.scala
@@ -110,7 +110,7 @@ class InMemFailerActor extends Actor {
 class InMemoryActorSpec extends JUnitSuite {
   @Test
   def shouldOneWayMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor(() => new InMemStatefulActor(2))
+    val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
     stateful ! SetMapStateOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
     stateful ! SuccessOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -130,7 +130,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldOneWayMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor(() => new InMemStatefulActor(2))
+    val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
     val failer = newActor[InMemFailerActor]
     failer.start
@@ -157,7 +157,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldOneWayVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor(() => new InMemStatefulActor(2))
+    val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
     stateful ! SetVectorStateOneWay("init") // set init state
     stateful ! SuccessOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -177,7 +177,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldOneWayVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor(() => new InMemStatefulActor(2))
+    val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
     stateful ! SetVectorStateOneWay("init") // set init state
     Thread.sleep(1000)
@@ -205,7 +205,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldOneWayRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor(() => new InMemStatefulActor(2))
+    val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
     stateful ! SetRefStateOneWay("init") // set init state
     stateful ! SuccessOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -225,7 +225,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldOneWayRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor(() => new InMemStatefulActor(2))
+    val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
     stateful ! SetRefStateOneWay("init") // set init state
     Thread.sleep(1000)
diff --git a/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala b/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala
index 4e0b55f91b..6e0e1ca31e 100644
--- a/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala
+++ b/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala
@@ -26,7 +26,7 @@ class ReactorBasedThreadPoolEventDrivenDispatcherActorSpec extends JUnitSuite {
 
   @Test def shouldSendOneWay = {
     val oneWay = new CountDownLatch(1)
-    val actor = newActor(() => new Actor {
+    val actor = actorOf(new Actor {
       dispatcher = Dispatchers.newReactorBasedThreadPoolEventDrivenDispatcher(uuid)
       def receive = {
         case "OneWay" => oneWay.countDown
diff --git a/akka-core/src/test/scala/ThreadBasedActorSpec.scala b/akka-core/src/test/scala/ThreadBasedActorSpec.scala
index 6466e5749b..5d04393a22 100644
--- a/akka-core/src/test/scala/ThreadBasedActorSpec.scala
+++ b/akka-core/src/test/scala/ThreadBasedActorSpec.scala
@@ -27,7 +27,7 @@ class ThreadBasedActorSpec extends JUnitSuite {
 
   @Test def shouldSendOneWay = {
     var oneWay = new CountDownLatch(1)
-    val actor = newActor(() => new Actor {
+    val actor = actorOf(new Actor {
       dispatcher = Dispatchers.newThreadBasedDispatcher(this)
       def receive = {
         case "OneWay" => oneWay.countDown
diff --git a/akka-core/src/test/scala/ThreadBasedDispatcherSpec.scala b/akka-core/src/test/scala/ThreadBasedDispatcherSpec.scala
index f5b0235430..5ae9c9c786 100644
--- a/akka-core/src/test/scala/ThreadBasedDispatcherSpec.scala
+++ b/akka-core/src/test/scala/ThreadBasedDispatcherSpec.scala
@@ -14,9 +14,9 @@ import Actor._
 
 class ThreadBasedDispatcherSpec extends JUnitSuite {
   private var threadingIssueDetected: AtomicBoolean = null
-  val key1 = newActor(() => new Actor { def receive = { case _ => {}} })
-  val key2 = newActor(() => new Actor { def receive = { case _ => {}} })
-  val key3 = newActor(() => new Actor { def receive = { case _ => {}} })
+  val key1 = actorOf(new Actor { def receive = { case _ => {}} })
+  val key2 = actorOf(new Actor { def receive = { case _ => {}} })
+  val key3 = actorOf(new Actor { def receive = { case _ => {}} })
   
   class TestMessageHandle(handleLatch: CountDownLatch) extends MessageInvoker {
     val guardLock: Lock = new ReentrantLock
diff --git a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
index 81bf83801c..a51563e4a0 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
@@ -35,8 +35,8 @@ class Boot {
   // Routing example
 
   val producer = newActor[Producer1]
-  val mediator = newActor(() => new Transformer(producer))
-  val consumer = newActor(() => new Consumer3(mediator))
+  val mediator = actorOf(new Transformer(producer))
+  val consumer = actorOf(new Consumer3(mediator))
 
   producer.start
   mediator.start
@@ -55,9 +55,9 @@ class Boot {
   //val cometdPublisher = new Publisher("cometd-publisher", cometdUri).start
 
   val jmsUri = "jms:topic:test"
-  val jmsSubscriber1 = newActor(() => new Subscriber("jms-subscriber-1", jmsUri)).start
-  val jmsSubscriber2 = newActor(() => new Subscriber("jms-subscriber-2", jmsUri)).start
-  val jmsPublisher =   newActor(() => new Publisher("jms-publisher", jmsUri)).start
+  val jmsSubscriber1 = actorOf(new Subscriber("jms-subscriber-1", jmsUri)).start
+  val jmsSubscriber2 = actorOf(new Subscriber("jms-subscriber-2", jmsUri)).start
+  val jmsPublisher =   actorOf(new Publisher("jms-publisher", jmsUri)).start
 
   //val cometdPublisherBridge = new PublisherBridge("jetty:http://0.0.0.0:8877/camel/pub/cometd", cometdPublisher).start
   val jmsPublisherBridge = new PublisherBridge("jetty:http://0.0.0.0:8877/camel/pub/jms", jmsPublisher).start
diff --git a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
index c2ce76e1fa..77383a031b 100644
--- a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
+++ b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
@@ -130,7 +130,7 @@ trait SessionManagement { this: Actor =>
   protected def sessionManagement: PartialFunction[Any, Unit] = {
     case Login(username) => 
       log.info("User [%s] has logged in", username)
-      val session = newActor(() => new Session(username, storage))
+      val session = actorOf(new Session(username, storage))
       session.start
       sessions += (username -> session)
       
diff --git a/akka-samples/akka-sample-pubsub/src/main/scala/RedisPubSub.scala b/akka-samples/akka-sample-pubsub/src/main/scala/RedisPubSub.scala
index f0005ca919..44366d31a4 100644
--- a/akka-samples/akka-sample-pubsub/src/main/scala/RedisPubSub.scala
+++ b/akka-samples/akka-sample-pubsub/src/main/scala/RedisPubSub.scala
@@ -52,7 +52,7 @@ import se.scalablesolutions.akka.actor.Actor._
 object Pub {
   println("starting publishing service ..")
   val r = new RedisClient("localhost", 6379)
-  val p = newActor(() => new Publisher(r))
+  val p = actorOf(new Publisher(r))
   p.start
 
   def publish(channel: String, message: String) = {
@@ -63,7 +63,7 @@ object Pub {
 object Sub {
   println("starting subscription service ..")
   val r = new RedisClient("localhost", 6379)
-  val s = newActor(() => new Subscriber(r))
+  val s = actorOf(new Subscriber(r))
   s.start
   s ! Register(callback) 
 

From 7abb110b5c7939c3fc4afbc8f4bf521e510012bf Mon Sep 17 00:00:00 2001
From: Viktor Klang 
Date: Sat, 8 May 2010 19:01:12 +0200
Subject: [PATCH 05/14] Switched newActor for actorOf

---
 .../src/main/scala/service/CamelService.scala |  2 +-
 .../service/CamelServiceFeatureTest.scala     |  2 +-
 .../src/test/scala/service/PublishTest.scala  |  8 ++---
 akka-core/src/main/scala/actor/Actor.scala    |  6 ++--
 .../ActorFireForgetRequestReplySpec.scala     |  4 +--
 .../src/test/scala/ActorRegistrySpec.scala    | 36 +++++++++----------
 .../ClientInitiatedRemoteActorSpec.scala      | 10 +++---
 ...rBasedEventDrivenDispatcherActorSpec.scala |  8 ++---
 ...ventDrivenWorkStealingDispatcherSpec.scala |  4 +--
 .../src/test/scala/ForwardActorSpec.scala     | 10 +++---
 akka-core/src/test/scala/FutureSpec.scala     | 24 ++++++-------
 .../src/test/scala/InMemoryActorSpec.scala    | 24 ++++++-------
 ...rotobufActorMessageSerializationSpec.scala |  2 +-
 ...ThreadEventDrivenDispatcherActorSpec.scala |  8 ++---
 ...adPoolEventDrivenDispatcherActorSpec.scala |  6 ++--
 .../src/test/scala/RemoteSupervisorSpec.scala | 22 ++++++------
 .../ServerInitiatedRemoteActorSample.scala    |  2 +-
 .../ServerInitiatedRemoteActorSpec.scala      |  6 ++--
 akka-core/src/test/scala/ShutdownSpec.scala   |  2 +-
 akka-core/src/test/scala/SupervisorSpec.scala | 22 ++++++------
 .../src/test/scala/ThreadBasedActorSpec.scala |  6 ++--
 akka-http/src/test/scala/SecuritySpec.scala   |  2 +-
 .../scala/CassandraPersistentActorSpec.scala  | 18 +++++-----
 .../test/scala/MongoPersistentActorSpec.scala | 12 +++----
 .../test/scala/RedisPersistentActorSpec.scala | 12 +++----
 .../src/test/scala/RedisPersistentQSpec.scala | 12 +++----
 .../scala/RedisPersistentSortedSetSpec.scala  | 10 +++---
 .../src/main/scala/Application1.scala         |  2 +-
 .../src/main/scala/Application2.scala         |  2 +-
 .../src/main/scala/Boot.scala                 |  6 ++--
 akka-samples/akka-sample-chat/README          |  2 +-
 .../src/main/scala/ChatServer.scala           |  4 +--
 .../main/scala/bootstrap/liftweb/Boot.scala   |  4 +--
 .../ClientManagedRemoteActorSample.scala      |  2 +-
 .../ServerManagedRemoteActorSample.scala      |  2 +-
 .../src/main/scala/SimpleService.scala        |  8 ++---
 .../src/main/scala/SimpleService.scala        |  8 ++---
 37 files changed, 160 insertions(+), 160 deletions(-)

diff --git a/akka-camel/src/main/scala/service/CamelService.scala b/akka-camel/src/main/scala/service/CamelService.scala
index fbd1a4cb93..6dd2714e70 100644
--- a/akka-camel/src/main/scala/service/CamelService.scala
+++ b/akka-camel/src/main/scala/service/CamelService.scala
@@ -20,7 +20,7 @@ trait CamelService extends Bootable with Logging {
 
   import CamelContextManager._
 
-  private[camel] val consumerPublisher = newActor[ConsumerPublisher]
+  private[camel] val consumerPublisher = actorOf[ConsumerPublisher]
   private[camel] val publishRequestor =  actorOf(new PublishRequestor(consumerPublisher))
 
   /**
diff --git a/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala b/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala
index 951ce21fe8..34090aa9d5 100644
--- a/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala
+++ b/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala
@@ -79,7 +79,7 @@ class CamelServiceFeatureTest extends FeatureSpec with BeforeAndAfterAll with Gi
     scenario("access an actor from the custom Camel route") {
 
       given("a registered actor and a custom route to that actor")
-      val actor = newActor[TestActor].start
+      val actor = actorOf[TestActor].start
 
       when("sending a a message to that route")
       val response = CamelContextManager.template.requestBody("direct:custom-route-test-1", "msg3")
diff --git a/akka-camel/src/test/scala/service/PublishTest.scala b/akka-camel/src/test/scala/service/PublishTest.scala
index 69910254ec..22b8e1575b 100644
--- a/akka-camel/src/test/scala/service/PublishTest.scala
+++ b/akka-camel/src/test/scala/service/PublishTest.scala
@@ -29,23 +29,23 @@ class PublishTest extends JUnitSuite {
   import PublishTest._
   
   @Test def shouldCreatePublishRequestList = {
-    val publish = Publish.forConsumers(List(newActor[ConsumeAnnotatedActor]))
+    val publish = Publish.forConsumers(List(actorOf[ConsumeAnnotatedActor]))
     assert(publish === List(Publish("mock:test1", "test", false)))
   }
 
   @Test def shouldCreateSomePublishRequestWithActorId = {
-    val publish = Publish.forConsumer(newActor[ConsumeAnnotatedActor])
+    val publish = Publish.forConsumer(actorOf[ConsumeAnnotatedActor])
     assert(publish === Some(Publish("mock:test1", "test", false)))
   }
 
   @Test def shouldCreateSomePublishRequestWithActorUuid = {
-    val ca = newActor[ConsumerActor]
+    val ca = actorOf[ConsumerActor]
     val publish = Publish.forConsumer(ca)
     assert(publish === Some(Publish("mock:test2", ca.uuid, true)))
   }
 
   @Test def shouldCreateNone = {
-    val publish = Publish.forConsumer(newActor[PlainActor])
+    val publish = Publish.forConsumer(actorOf[PlainActor])
     assert(publish === None)
   }
 }
diff --git a/akka-core/src/main/scala/actor/Actor.scala b/akka-core/src/main/scala/actor/Actor.scala
index a39898879a..63ca1aa4c5 100644
--- a/akka-core/src/main/scala/actor/Actor.scala
+++ b/akka-core/src/main/scala/actor/Actor.scala
@@ -81,13 +81,13 @@ object Actor extends Logging {
    * Creates a new ActorRef out of the Actor with type T.
    * 
    *   import Actor._
-   *   val actor = newActor[MyActor]
+   *   val actor = actorOf[MyActor]
    *   actor.start
    *   actor ! message
    *   actor.stop
    * 
*/ - def newActor[T <: Actor: Manifest]: ActorRef = new ActorRef(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]]) + def actorOf[T <: Actor: Manifest]: ActorRef = new ActorRef(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]]) /** * Creates a new ActorRef out of the Actor. Allows you to pass in a factory function @@ -279,7 +279,7 @@ object ActorRef { *
  *   import Actor._
  * 
- *   val actor = newActor[MyActor]
+ *   val actor = actorOf[MyActor]
  *   actor.start
  *   actor ! message
  *   actor.stop
diff --git a/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala b/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala
index 9b8cffae16..b29a79ea23 100644
--- a/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala
+++ b/akka-core/src/test/scala/ActorFireForgetRequestReplySpec.scala
@@ -46,7 +46,7 @@ class ActorFireForgetRequestReplySpec extends JUnitSuite {
   @Test
   def shouldReplyToBangMessageUsingReply = {
     state.finished.reset
-    val replyActor = newActor[ReplyActor]
+    val replyActor = actorOf[ReplyActor]
     replyActor.start
     val senderActor = actorOf(new SenderActor(replyActor))
     senderActor.start
@@ -59,7 +59,7 @@ class ActorFireForgetRequestReplySpec extends JUnitSuite {
   @Test
   def shouldReplyToBangMessageUsingImplicitSender = {
     state.finished.reset
-    val replyActor = newActor[ReplyActor]
+    val replyActor = actorOf[ReplyActor]
     replyActor.start
     val senderActor = actorOf(new SenderActor(replyActor))
     senderActor.start
diff --git a/akka-core/src/test/scala/ActorRegistrySpec.scala b/akka-core/src/test/scala/ActorRegistrySpec.scala
index 024a111525..c799889c20 100644
--- a/akka-core/src/test/scala/ActorRegistrySpec.scala
+++ b/akka-core/src/test/scala/ActorRegistrySpec.scala
@@ -21,7 +21,7 @@ class ActorRegistrySpec extends JUnitSuite {
   
   @Test def shouldGetActorByIdFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val actors = ActorRegistry.actorsFor("MyID")
     assert(actors.size === 1)
@@ -32,7 +32,7 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetActorByUUIDFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     val uuid = actor.uuid
     actor.start
     val actorOrNone = ActorRegistry.actorFor(uuid)
@@ -43,7 +43,7 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetActorByClassFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val actors = ActorRegistry.actorsFor(classOf[TestActor])
     assert(actors.size === 1)
@@ -54,7 +54,7 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetActorByManifestFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val actors = ActorRegistry.actorsFor[TestActor]
     assert(actors.size === 1)
@@ -65,9 +65,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetActorsByIdFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val actors = ActorRegistry.actorsFor("MyID")
     assert(actors.size === 2)
@@ -81,9 +81,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetActorsByClassFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val actors = ActorRegistry.actorsFor(classOf[TestActor])
     assert(actors.size === 2)
@@ -97,9 +97,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetActorsByManifestFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val actors = ActorRegistry.actorsFor[TestActor]
     assert(actors.size === 2)
@@ -113,9 +113,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetAllActorsFromActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val actors = ActorRegistry.actors
     assert(actors.size === 2)
@@ -129,9 +129,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldGetResponseByAllActorsInActorRegistryWhenInvokingForeach = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     record = ""
     ActorRegistry.foreach(actor => actor !! "ping")
@@ -142,9 +142,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldShutdownAllActorsInActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     ActorRegistry.shutdownAll
     assert(ActorRegistry.actors.size === 0)
@@ -152,9 +152,9 @@ class ActorRegistrySpec extends JUnitSuite {
 
   @Test def shouldRemoveUnregisterActorInActorRegistry = {
     ActorRegistry.shutdownAll
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     assert(ActorRegistry.actors.size === 2)
     ActorRegistry.unregister(actor1)
diff --git a/akka-core/src/test/scala/ClientInitiatedRemoteActorSpec.scala b/akka-core/src/test/scala/ClientInitiatedRemoteActorSpec.scala
index 9b8b5e03e2..947d3a9688 100644
--- a/akka-core/src/test/scala/ClientInitiatedRemoteActorSpec.scala
+++ b/akka-core/src/test/scala/ClientInitiatedRemoteActorSpec.scala
@@ -90,7 +90,7 @@ class ClientInitiatedRemoteActorSpec extends JUnitSuite {
 
   @Test
   def shouldSendOneWay = {
-    val actor = newActor[RemoteActorSpecActorUnidirectional]
+    val actor = actorOf[RemoteActorSpecActorUnidirectional]
     actor.makeRemote(HOSTNAME, PORT1)
     actor.start
     actor ! "OneWay"
@@ -100,10 +100,10 @@ class ClientInitiatedRemoteActorSpec extends JUnitSuite {
 
   @Test
   def shouldSendOneWayAndReceiveReply = {
-    val actor = newActor[SendOneWayAndReplyReceiverActor]
+    val actor = actorOf[SendOneWayAndReplyReceiverActor]
     actor.makeRemote(HOSTNAME, PORT1)
     actor.start
-    val sender = newActor[SendOneWayAndReplySenderActor]
+    val sender = actorOf[SendOneWayAndReplySenderActor]
     sender.setReplyToAddress(HOSTNAME, PORT2)
     sender.actor.asInstanceOf[SendOneWayAndReplySenderActor].sendTo = actor
     sender.start
@@ -117,7 +117,7 @@ class ClientInitiatedRemoteActorSpec extends JUnitSuite {
 
   @Test
   def shouldSendBangBangMessageAndReceiveReply = {
-    val actor = newActor[RemoteActorSpecActorBidirectional]
+    val actor = actorOf[RemoteActorSpecActorBidirectional]
     actor.makeRemote(HOSTNAME, PORT1)
     actor.start
     val result = actor !! "Hello"
@@ -128,7 +128,7 @@ class ClientInitiatedRemoteActorSpec extends JUnitSuite {
   @Test
   def shouldSendAndReceiveRemoteException = {
     implicit val timeout = 500000000L
-    val actor = newActor[RemoteActorSpecActorBidirectional]
+    val actor = actorOf[RemoteActorSpecActorBidirectional]
     actor.makeRemote(HOSTNAME, PORT1)
     actor.start
     try {
diff --git a/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorSpec.scala b/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorSpec.scala
index 957bad5fe3..366277208a 100644
--- a/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorSpec.scala
+++ b/akka-core/src/test/scala/ExecutorBasedEventDrivenDispatcherActorSpec.scala
@@ -33,7 +33,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
   private val unit = TimeUnit.MILLISECONDS
 
   @Test def shouldSendOneWay = {
-    val actor = newActor[OneWayTestActor]
+    val actor = actorOf[OneWayTestActor]
     actor.start
     val result = actor ! "OneWay"
     assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS))
@@ -41,7 +41,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReplySync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result: String = (actor !! ("Hello", 10000)).get
     assert("World" === result)
@@ -49,7 +49,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReplyAsync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result = actor !! "Hello"
     assert("World" === result.get.asInstanceOf[String])
@@ -57,7 +57,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReceiveException = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     try {
       actor !! "Failure"
diff --git a/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala b/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala
index 4a1bf52370..000ec4f06c 100644
--- a/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala
+++ b/akka-core/src/test/scala/ExecutorBasedEventDrivenWorkStealingDispatcherSpec.scala
@@ -84,8 +84,8 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherSpec extends JUnitSuite with
   }
   
   @Test def canNotUseActorsOfDifferentTypesInSameDispatcher: Unit = {
-    val first = newActor[FirstActor]
-    val second = newActor[SecondActor]
+    val first = actorOf[FirstActor]
+    val second = actorOf[SecondActor]
 
     first.start
     intercept[IllegalStateException] {
diff --git a/akka-core/src/test/scala/ForwardActorSpec.scala b/akka-core/src/test/scala/ForwardActorSpec.scala
index 05d06df32b..3ccf7e0833 100644
--- a/akka-core/src/test/scala/ForwardActorSpec.scala
+++ b/akka-core/src/test/scala/ForwardActorSpec.scala
@@ -24,7 +24,7 @@ object ForwardActorSpec {
 
 
   class ForwardActor extends Actor {
-    val receiverActor = newActor[ReceiverActor]
+    val receiverActor = actorOf[ReceiverActor]
     receiverActor.start
     def receive = {
       case "SendBang" => receiverActor.forward("SendBang")
@@ -33,7 +33,7 @@ object ForwardActorSpec {
   }
 
   class BangSenderActor extends Actor {
-    val forwardActor = newActor[ForwardActor]
+    val forwardActor = actorOf[ForwardActor]
     forwardActor.start
     forwardActor ! "SendBang"
     def receive = {
@@ -43,7 +43,7 @@ object ForwardActorSpec {
 
   class BangBangSenderActor extends Actor {
     val latch = new CountDownLatch(1)
-    val forwardActor = newActor[ForwardActor]
+    val forwardActor = actorOf[ForwardActor]
     forwardActor.start
     (forwardActor !! "SendBangBang") match {
       case Some(_) => latch.countDown
@@ -60,7 +60,7 @@ class ForwardActorSpec extends JUnitSuite {
   
   @Test
   def shouldForwardActorReferenceWhenInvokingForwardOnBang {
-    val senderActor = newActor[BangSenderActor]
+    val senderActor = actorOf[BangSenderActor]
     val latch = senderActor.actor.asInstanceOf[BangSenderActor]
       .forwardActor.actor.asInstanceOf[ForwardActor]
       .receiverActor.actor.asInstanceOf[ReceiverActor]
@@ -73,7 +73,7 @@ class ForwardActorSpec extends JUnitSuite {
 
   @Test
   def shouldForwardActorReferenceWhenInvokingForwardOnBangBang {
-    val senderActor = newActor[BangBangSenderActor]
+    val senderActor = actorOf[BangBangSenderActor]
     senderActor.start
     val latch = senderActor.actor.asInstanceOf[BangBangSenderActor].latch
     assert(latch.await(1L, TimeUnit.SECONDS)) 
diff --git a/akka-core/src/test/scala/FutureSpec.scala b/akka-core/src/test/scala/FutureSpec.scala
index 4f9da6572f..0bbdaa48be 100644
--- a/akka-core/src/test/scala/FutureSpec.scala
+++ b/akka-core/src/test/scala/FutureSpec.scala
@@ -21,7 +21,7 @@ class FutureSpec extends JUnitSuite {
   import FutureSpec._
   
   @Test def shouldActorReplyResultThroughExplicitFuture {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val future = actor !!! "Hello"
     future.await
@@ -31,7 +31,7 @@ class FutureSpec extends JUnitSuite {
   }
 
   @Test def shouldActorReplyExceptionThroughExplicitFuture {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val future = actor !!! "Failure"
     future.await
@@ -42,9 +42,9 @@ class FutureSpec extends JUnitSuite {
 
   /*
   @Test def shouldFutureAwaitEitherLeft = {
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val future1 = actor1 !!! "Hello"
     val future2 = actor2 !!! "NoReply"
@@ -56,9 +56,9 @@ class FutureSpec extends JUnitSuite {
   }
 
   @Test def shouldFutureAwaitEitherRight = {
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val future1 = actor1 !!! "NoReply"
     val future2 = actor2 !!! "Hello"
@@ -70,9 +70,9 @@ class FutureSpec extends JUnitSuite {
   }
   */
   @Test def shouldFutureAwaitOneLeft = {
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val future1 = actor1 !!! "NoReply"
     val future2 = actor2 !!! "Hello"
@@ -84,9 +84,9 @@ class FutureSpec extends JUnitSuite {
   }
 
   @Test def shouldFutureAwaitOneRight = {
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val future1 = actor1 !!! "Hello"
     val future2 = actor2 !!! "NoReply"
@@ -98,9 +98,9 @@ class FutureSpec extends JUnitSuite {
   }
 
   @Test def shouldFutureAwaitAll = {
-    val actor1 = newActor[TestActor]
+    val actor1 = actorOf[TestActor]
     actor1.start
-    val actor2 = newActor[TestActor]
+    val actor2 = actorOf[TestActor]
     actor2.start
     val future1 = actor1 !!! "Hello"
     val future2 = actor2 !!! "Hello"
diff --git a/akka-core/src/test/scala/InMemoryActorSpec.scala b/akka-core/src/test/scala/InMemoryActorSpec.scala
index a88e8c50c6..cdf5e72675 100644
--- a/akka-core/src/test/scala/InMemoryActorSpec.scala
+++ b/akka-core/src/test/scala/InMemoryActorSpec.scala
@@ -121,7 +121,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor[InMemStatefulActor]
+    val stateful = actorOf[InMemStatefulActor]
     stateful.start
     stateful !! SetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
     stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -132,7 +132,7 @@ class InMemoryActorSpec extends JUnitSuite {
   def shouldOneWayMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
     val stateful = actorOf(new InMemStatefulActor(2))
     stateful.start
-    val failer = newActor[InMemFailerActor]
+    val failer = actorOf[InMemFailerActor]
     failer.start
     stateful ! SetMapStateOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
     stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
@@ -143,10 +143,10 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor[InMemStatefulActor]
+    val stateful = actorOf[InMemStatefulActor]
     stateful.start
     stateful !! SetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
-    val failer = newActor[InMemFailerActor]
+    val failer = actorOf[InMemFailerActor]
     failer.start
     try {
       stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
@@ -168,7 +168,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor[InMemStatefulActor]
+    val stateful = actorOf[InMemStatefulActor]
     stateful.start
     stateful !! SetVectorState("init") // set init state
     stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -181,7 +181,7 @@ class InMemoryActorSpec extends JUnitSuite {
     stateful.start
     stateful ! SetVectorStateOneWay("init") // set init state
     Thread.sleep(1000)
-    val failer = newActor[InMemFailerActor]
+    val failer = actorOf[InMemFailerActor]
     failer.start
     stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
     val notifier: Option[CountDownLatch] = stateful !! GetNotifier
@@ -191,10 +191,10 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor[InMemStatefulActor]
+    val stateful = actorOf[InMemStatefulActor]
     stateful.start
     stateful !! SetVectorState("init") // set init state
-    val failer = newActor[InMemFailerActor]
+    val failer = actorOf[InMemFailerActor]
     failer.start
     try {
       stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
@@ -216,7 +216,7 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor[InMemStatefulActor]
+    val stateful = actorOf[InMemStatefulActor]
     stateful.start
     stateful !! SetRefState("init") // set init state
     stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -229,7 +229,7 @@ class InMemoryActorSpec extends JUnitSuite {
     stateful.start
     stateful ! SetRefStateOneWay("init") // set init state
     Thread.sleep(1000)
-    val failer = newActor[InMemFailerActor]
+    val failer = actorOf[InMemFailerActor]
     failer.start
     stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
     val notifier: Option[CountDownLatch] = stateful !! GetNotifier
@@ -239,10 +239,10 @@ class InMemoryActorSpec extends JUnitSuite {
 
   @Test
   def shouldRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor[InMemStatefulActor]
+    val stateful = actorOf[InMemStatefulActor]
     stateful.start
     stateful !! SetRefState("init") // set init state
-    val failer = newActor[InMemFailerActor]
+    val failer = actorOf[InMemFailerActor]
     failer.start
     try {
       stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
diff --git a/akka-core/src/test/scala/ProtobufActorMessageSerializationSpec.scala b/akka-core/src/test/scala/ProtobufActorMessageSerializationSpec.scala
index 1af37c7a26..7875d72c7c 100644
--- a/akka-core/src/test/scala/ProtobufActorMessageSerializationSpec.scala
+++ b/akka-core/src/test/scala/ProtobufActorMessageSerializationSpec.scala
@@ -45,7 +45,7 @@ class ProtobufActorMessageSerializationSpec extends JUnitSuite {
   def init() {
     server = new RemoteServer
     server.start(HOSTNAME, PORT)
-    server.register("RemoteActorSpecActorBidirectional", newActor[RemoteActorSpecActorBidirectional])
+    server.register("RemoteActorSpecActorBidirectional", actorOf[RemoteActorSpecActorBidirectional])
     Thread.sleep(1000)
   }
 
diff --git a/akka-core/src/test/scala/ReactorBasedSingleThreadEventDrivenDispatcherActorSpec.scala b/akka-core/src/test/scala/ReactorBasedSingleThreadEventDrivenDispatcherActorSpec.scala
index 1c947182e2..d31aee3c14 100644
--- a/akka-core/src/test/scala/ReactorBasedSingleThreadEventDrivenDispatcherActorSpec.scala
+++ b/akka-core/src/test/scala/ReactorBasedSingleThreadEventDrivenDispatcherActorSpec.scala
@@ -36,7 +36,7 @@ class ReactorBasedSingleThreadEventDrivenDispatcherActorSpec extends JUnitSuite
   private val unit = TimeUnit.MILLISECONDS
 
   @Test def shouldSendOneWay = {
-    val actor = newActor[OneWayTestActor]
+    val actor = actorOf[OneWayTestActor]
     actor.start
     val result = actor ! "OneWay"
     assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS))
@@ -44,7 +44,7 @@ class ReactorBasedSingleThreadEventDrivenDispatcherActorSpec extends JUnitSuite
   }
 
   @Test def shouldSendReplySync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result: String = (actor !! ("Hello", 10000)).get
     assert("World" === result)
@@ -52,7 +52,7 @@ class ReactorBasedSingleThreadEventDrivenDispatcherActorSpec extends JUnitSuite
   }
 
   @Test def shouldSendReplyAsync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result = actor !! "Hello"
     assert("World" === result.get.asInstanceOf[String])
@@ -60,7 +60,7 @@ class ReactorBasedSingleThreadEventDrivenDispatcherActorSpec extends JUnitSuite
   }
 
   @Test def shouldSendReceiveException = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     try {
       actor !! "Failure"
diff --git a/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala b/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala
index 6e0e1ca31e..8a16c86939 100644
--- a/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala
+++ b/akka-core/src/test/scala/ReactorBasedThreadPoolEventDrivenDispatcherActorSpec.scala
@@ -39,7 +39,7 @@ class ReactorBasedThreadPoolEventDrivenDispatcherActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReplySync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result: String = (actor !! ("Hello", 10000)).get
     assert("World" === result)
@@ -47,7 +47,7 @@ class ReactorBasedThreadPoolEventDrivenDispatcherActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReplyAsync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result = actor !! "Hello"
     assert("World" === result.get.asInstanceOf[String])
@@ -55,7 +55,7 @@ class ReactorBasedThreadPoolEventDrivenDispatcherActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReceiveException = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     try {
       actor !! "Failure"
diff --git a/akka-core/src/test/scala/RemoteSupervisorSpec.scala b/akka-core/src/test/scala/RemoteSupervisorSpec.scala
index e3f06bd555..b223bbddae 100644
--- a/akka-core/src/test/scala/RemoteSupervisorSpec.scala
+++ b/akka-core/src/test/scala/RemoteSupervisorSpec.scala
@@ -335,7 +335,7 @@ class RemoteSupervisorSpec extends JUnitSuite {
     // Then create a concrete container in which we mix in support for the specific
     // implementation of the Actors we want to use.
 
-    pingpong1 = newActor[RemotePingPong1Actor]
+    pingpong1 = actorOf[RemotePingPong1Actor]
     pingpong1.makeRemote(RemoteServer.HOSTNAME, 9988)
 
     val factory = SupervisorFactory(
@@ -350,7 +350,7 @@ class RemoteSupervisorSpec extends JUnitSuite {
   }
 
   def getSingleActorOneForOneSupervisor: Supervisor = {
-    pingpong1 = newActor[RemotePingPong1Actor]
+    pingpong1 = actorOf[RemotePingPong1Actor]
     pingpong1.makeRemote(RemoteServer.HOSTNAME, 9988)
 
     val factory = SupervisorFactory(
@@ -364,11 +364,11 @@ class RemoteSupervisorSpec extends JUnitSuite {
   }
 
   def getMultipleActorsAllForOneConf: Supervisor = {
-    pingpong1 = newActor[RemotePingPong1Actor]
+    pingpong1 = actorOf[RemotePingPong1Actor]
     pingpong1.makeRemote(RemoteServer.HOSTNAME, 9988)
-    pingpong2 = newActor[RemotePingPong2Actor]
+    pingpong2 = actorOf[RemotePingPong2Actor]
     pingpong2.makeRemote(RemoteServer.HOSTNAME, 9988)
-    pingpong3 = newActor[RemotePingPong3Actor]
+    pingpong3 = actorOf[RemotePingPong3Actor]
     pingpong3.makeRemote(RemoteServer.HOSTNAME, 9988)
 
     val factory = SupervisorFactory(
@@ -390,11 +390,11 @@ class RemoteSupervisorSpec extends JUnitSuite {
   }
 
   def getMultipleActorsOneForOneConf: Supervisor = {
-    pingpong1 = newActor[RemotePingPong1Actor]
+    pingpong1 = actorOf[RemotePingPong1Actor]
     pingpong1.makeRemote(RemoteServer.HOSTNAME, 9988)
-    pingpong2 = newActor[RemotePingPong2Actor]
+    pingpong2 = actorOf[RemotePingPong2Actor]
     pingpong2.makeRemote(RemoteServer.HOSTNAME, 9988)
-    pingpong3 = newActor[RemotePingPong3Actor]
+    pingpong3 = actorOf[RemotePingPong3Actor]
     pingpong3.makeRemote(RemoteServer.HOSTNAME, 9988)
 
     val factory = SupervisorFactory(
@@ -416,11 +416,11 @@ class RemoteSupervisorSpec extends JUnitSuite {
   }
 
   def getNestedSupervisorsAllForOneConf: Supervisor = {
-    pingpong1 = newActor[RemotePingPong1Actor]
+    pingpong1 = actorOf[RemotePingPong1Actor]
     pingpong1.makeRemote(RemoteServer.HOSTNAME, 9988)
-    pingpong2 = newActor[RemotePingPong2Actor]
+    pingpong2 = actorOf[RemotePingPong2Actor]
     pingpong2.makeRemote(RemoteServer.HOSTNAME, 9988)
-    pingpong3 = newActor[RemotePingPong3Actor]
+    pingpong3 = actorOf[RemotePingPong3Actor]
     pingpong3.makeRemote(RemoteServer.HOSTNAME, 9988)
 
     val factory = SupervisorFactory(
diff --git a/akka-core/src/test/scala/ServerInitiatedRemoteActorSample.scala b/akka-core/src/test/scala/ServerInitiatedRemoteActorSample.scala
index 7a26bc65f9..e75a7d640a 100644
--- a/akka-core/src/test/scala/ServerInitiatedRemoteActorSample.scala
+++ b/akka-core/src/test/scala/ServerInitiatedRemoteActorSample.scala
@@ -17,7 +17,7 @@ object ServerInitiatedRemoteActorServer {
 
   def run = {
     RemoteNode.start("localhost", 9999)
-    RemoteNode.register("hello-service", newActor[HelloWorldActor])
+    RemoteNode.register("hello-service", actorOf[HelloWorldActor])
   }
 
   def main(args: Array[String]) = run
diff --git a/akka-core/src/test/scala/ServerInitiatedRemoteActorSpec.scala b/akka-core/src/test/scala/ServerInitiatedRemoteActorSpec.scala
index 51d1e0876f..e6803d1dcf 100644
--- a/akka-core/src/test/scala/ServerInitiatedRemoteActorSpec.scala
+++ b/akka-core/src/test/scala/ServerInitiatedRemoteActorSpec.scala
@@ -67,9 +67,9 @@ class ServerInitiatedRemoteActorSpec extends JUnitSuite {
 
     server.start(HOSTNAME, PORT)
 
-    server.register(newActor[RemoteActorSpecActorUnidirectional])
-    server.register(newActor[RemoteActorSpecActorBidirectional])
-    server.register(newActor[RemoteActorSpecActorAsyncSender])
+    server.register(actorOf[RemoteActorSpecActorUnidirectional])
+    server.register(actorOf[RemoteActorSpecActorBidirectional])
+    server.register(actorOf[RemoteActorSpecActorAsyncSender])
 
     Thread.sleep(1000)
   }
diff --git a/akka-core/src/test/scala/ShutdownSpec.scala b/akka-core/src/test/scala/ShutdownSpec.scala
index 040178af3f..afc7610cb8 100644
--- a/akka-core/src/test/scala/ShutdownSpec.scala
+++ b/akka-core/src/test/scala/ShutdownSpec.scala
@@ -13,7 +13,7 @@ object ActorShutdownRunner {
       }
     }
 
-    val myActor = newActor[MyActor]
+    val myActor = actorOf[MyActor]
     myActor.start
     myActor ! "test"
     myActor.stop
diff --git a/akka-core/src/test/scala/SupervisorSpec.scala b/akka-core/src/test/scala/SupervisorSpec.scala
index b2c634cb85..1530ba89f7 100644
--- a/akka-core/src/test/scala/SupervisorSpec.scala
+++ b/akka-core/src/test/scala/SupervisorSpec.scala
@@ -419,7 +419,7 @@ class SupervisorSpec extends JUnitSuite {
   // Creat some supervisors with different configurations
 
   def getSingleActorAllForOneSupervisor: Supervisor = {
-    pingpong1 = newActor[PingPong1Actor]
+    pingpong1 = actorOf[PingPong1Actor]
 
     val factory = SupervisorFactory(
         SupervisorConfig(
@@ -432,7 +432,7 @@ class SupervisorSpec extends JUnitSuite {
   }
 
   def getSingleActorOneForOneSupervisor: Supervisor = {
-    pingpong1 = newActor[PingPong1Actor]
+    pingpong1 = actorOf[PingPong1Actor]
 
     val factory = SupervisorFactory(
         SupervisorConfig(
@@ -445,9 +445,9 @@ class SupervisorSpec extends JUnitSuite {
   }
 
   def getMultipleActorsAllForOneConf: Supervisor = {
-    pingpong1 = newActor[PingPong1Actor]
-    pingpong2 = newActor[PingPong2Actor]
-    pingpong3 = newActor[PingPong3Actor]
+    pingpong1 = actorOf[PingPong1Actor]
+    pingpong2 = actorOf[PingPong2Actor]
+    pingpong3 = actorOf[PingPong3Actor]
 
     val factory = SupervisorFactory(
         SupervisorConfig(
@@ -468,9 +468,9 @@ class SupervisorSpec extends JUnitSuite {
   }
 
   def getMultipleActorsOneForOneConf: Supervisor = {
-    pingpong1 = newActor[PingPong1Actor]
-    pingpong2 = newActor[PingPong2Actor]
-    pingpong3 = newActor[PingPong3Actor]
+    pingpong1 = actorOf[PingPong1Actor]
+    pingpong2 = actorOf[PingPong2Actor]
+    pingpong3 = actorOf[PingPong3Actor]
 
     val factory = SupervisorFactory(
         SupervisorConfig(
@@ -491,9 +491,9 @@ class SupervisorSpec extends JUnitSuite {
   }
 
   def getNestedSupervisorsAllForOneConf: Supervisor = {
-    pingpong1 = newActor[PingPong1Actor]
-    pingpong2 = newActor[PingPong2Actor]
-    pingpong3 = newActor[PingPong3Actor]
+    pingpong1 = actorOf[PingPong1Actor]
+    pingpong2 = actorOf[PingPong2Actor]
+    pingpong3 = actorOf[PingPong3Actor]
 
     val factory = SupervisorFactory(
         SupervisorConfig(
diff --git a/akka-core/src/test/scala/ThreadBasedActorSpec.scala b/akka-core/src/test/scala/ThreadBasedActorSpec.scala
index 5d04393a22..92f5449f87 100644
--- a/akka-core/src/test/scala/ThreadBasedActorSpec.scala
+++ b/akka-core/src/test/scala/ThreadBasedActorSpec.scala
@@ -40,7 +40,7 @@ class ThreadBasedActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReplySync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result: String = (actor !! ("Hello", 10000)).get
     assert("World" === result)
@@ -48,7 +48,7 @@ class ThreadBasedActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReplyAsync = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     val result = actor !! "Hello"
     assert("World" === result.get.asInstanceOf[String])
@@ -56,7 +56,7 @@ class ThreadBasedActorSpec extends JUnitSuite {
   }
 
   @Test def shouldSendReceiveException = {
-    val actor = newActor[TestActor]
+    val actor = actorOf[TestActor]
     actor.start
     try {
       actor !! "Failure"
diff --git a/akka-http/src/test/scala/SecuritySpec.scala b/akka-http/src/test/scala/SecuritySpec.scala
index 5c625dd097..79a3d95805 100644
--- a/akka-http/src/test/scala/SecuritySpec.scala
+++ b/akka-http/src/test/scala/SecuritySpec.scala
@@ -33,7 +33,7 @@ class BasicAuthenticatorSpec extends junit.framework.TestCase
     with Suite with MockitoSugar with MustMatchers {
   import BasicAuthenticatorSpec._
   
-  val authenticator = newActor[BasicAuthenticator]
+  val authenticator = actorOf[BasicAuthenticator]
   authenticator.start
 
   @Test def testChallenge = {
diff --git a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala b/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala
index b47e11c982..c4bf14ddbb 100644
--- a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala
+++ b/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala
@@ -76,7 +76,7 @@ class CassandraPersistentActorSpec extends JUnitSuite {
  
   @Test
   def testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor[CassandraPersistentActor]
+    val stateful = actorOf[CassandraPersistentActor]
     stateful.start
     stateful !! SetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
     stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -86,10 +86,10 @@ class CassandraPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor[CassandraPersistentActor]
+    val stateful = actorOf[CassandraPersistentActor]
     stateful.start
     stateful !! SetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
@@ -101,7 +101,7 @@ class CassandraPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor[CassandraPersistentActor]
+    val stateful = actorOf[CassandraPersistentActor]
     stateful.start
     stateful !! SetVectorState("init") // set init state
     stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -110,10 +110,10 @@ class CassandraPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor[CassandraPersistentActor]
+    val stateful = actorOf[CassandraPersistentActor]
     stateful.start
     stateful !! SetVectorState("init") // set init state
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
@@ -124,7 +124,7 @@ class CassandraPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
-    val stateful = newActor[CassandraPersistentActor]
+    val stateful = actorOf[CassandraPersistentActor]
     stateful.start
     stateful !! SetRefState("init") // set init state
     stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
@@ -134,10 +134,10 @@ class CassandraPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
-    val stateful = newActor[CassandraPersistentActor]
+    val stateful = actorOf[CassandraPersistentActor]
     stateful.start
     stateful !! SetRefState("init") // set init state
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
diff --git a/akka-persistence/akka-persistence-mongo/src/test/scala/MongoPersistentActorSpec.scala b/akka-persistence/akka-persistence-mongo/src/test/scala/MongoPersistentActorSpec.scala
index d2fbc959be..0396beca84 100644
--- a/akka-persistence/akka-persistence-mongo/src/test/scala/MongoPersistentActorSpec.scala
+++ b/akka-persistence/akka-persistence-mongo/src/test/scala/MongoPersistentActorSpec.scala
@@ -105,9 +105,9 @@ class BankAccountActor extends Transactor {
 class MongoPersistentActorSpec extends JUnitSuite {
   @Test
   def testSuccessfulDebit = {
-    val bactor = newActor[BankAccountActor]
+    val bactor = actorOf[BankAccountActor]
     bactor.start
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     bactor !! Credit("a-123", 5000)
     bactor !! Debit("a-123", 3000, failer)
@@ -137,14 +137,14 @@ class MongoPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testUnsuccessfulDebit = {
-    val bactor = newActor[BankAccountActor]
+    val bactor = actorOf[BankAccountActor]
     bactor.start
     bactor !! Credit("a-123", 5000)
 
     val JsNumber(b) = (bactor !! Balance("a-123")).get.asInstanceOf[JsValue] 
     assertEquals(BigInt(5000), BigInt(b.intValue))
 
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       bactor !! Debit("a-123", 7000, failer)
@@ -160,14 +160,14 @@ class MongoPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testUnsuccessfulMultiDebit = {
-    val bactor = newActor[BankAccountActor]
+    val bactor = actorOf[BankAccountActor]
     bactor.start
     bactor !! Credit("a-123", 5000)
 
     val JsNumber(b) = (bactor !! Balance("a-123")).get.asInstanceOf[JsValue] 
     assertEquals(BigInt(5000), BigInt(b.intValue))
 
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       bactor !! MultiDebit("a-123", List(500, 2000, 1000, 3000), failer)
diff --git a/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentActorSpec.scala b/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentActorSpec.scala
index 889078a544..dcadab469a 100644
--- a/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentActorSpec.scala
+++ b/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentActorSpec.scala
@@ -101,9 +101,9 @@ import org.scalatest.junit.JUnitSuite
 class RedisPersistentActorSpec extends JUnitSuite {
   @Test
   def testSuccessfulDebit = {
-    val bactor = newActor[AccountActor]
+    val bactor = actorOf[AccountActor]
     bactor.start
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     bactor !! Credit("a-123", 5000)
     bactor !! Debit("a-123", 3000, failer)
@@ -127,12 +127,12 @@ class RedisPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testUnsuccessfulDebit = {
-    val bactor = newActor[AccountActor]
+    val bactor = actorOf[AccountActor]
     bactor.start
     bactor !! Credit("a-123", 5000)
     assertEquals(BigInt(5000), (bactor !! Balance("a-123")).get)
 
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       bactor !! Debit("a-123", 7000, failer)
@@ -148,13 +148,13 @@ class RedisPersistentActorSpec extends JUnitSuite {
 
   @Test
   def testUnsuccessfulMultiDebit = {
-    val bactor = newActor[AccountActor]
+    val bactor = actorOf[AccountActor]
     bactor.start
     bactor !! Credit("a-123", 5000)
 
     assertEquals(BigInt(5000), (bactor !! (Balance("a-123"), 5000)).get)
 
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
     try {
       bactor !! MultiDebit("a-123", List(500, 2000, 1000, 3000), failer)
diff --git a/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentQSpec.scala b/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentQSpec.scala
index 6a4b42e3b9..81d1d35dce 100644
--- a/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentQSpec.scala
+++ b/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentQSpec.scala
@@ -53,7 +53,7 @@ import org.scalatest.junit.JUnitSuite
 class RedisPersistentQSpec extends JUnitSuite {
   @Test
   def testSuccessfulNQ = {
-    val qa = newActor[QueueActor]
+    val qa = actorOf[QueueActor]
     qa.start
     qa !! NQ("a-123")
     qa !! NQ("a-124")
@@ -64,7 +64,7 @@ class RedisPersistentQSpec extends JUnitSuite {
 
   @Test
   def testSuccessfulDQ = {
-    val qa = newActor[QueueActor]
+    val qa = actorOf[QueueActor]
     qa.start
     qa !! NQ("a-123")
     qa !! NQ("a-124")
@@ -80,9 +80,9 @@ class RedisPersistentQSpec extends JUnitSuite {
 
   @Test
   def testSuccessfulMNDQ = {
-    val qa = newActor[QueueActor]
+    val qa = actorOf[QueueActor]
     qa.start
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
 
     qa !! NQ("a-123")
@@ -100,9 +100,9 @@ class RedisPersistentQSpec extends JUnitSuite {
 
   @Test
   def testMixedMNDQ = {
-    val qa = newActor[QueueActor]
+    val qa = actorOf[QueueActor]
     qa.start
-    val failer = newActor[PersistentFailerActor]
+    val failer = actorOf[PersistentFailerActor]
     failer.start
 
     // 3 enqueues
diff --git a/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentSortedSetSpec.scala b/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentSortedSetSpec.scala
index f970e3fd27..d0525a59b7 100644
--- a/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentSortedSetSpec.scala
+++ b/akka-persistence/akka-persistence-redis/src/test/scala/RedisPersistentSortedSetSpec.scala
@@ -111,7 +111,7 @@ class RedisPersistentSortedSetSpec extends
   val h6 = Hacker("Alan Turing", "1912")
 
   describe("Add and report cardinality of the set") {
-    val qa = newActor[SortedSetActor]
+    val qa = actorOf[SortedSetActor]
     qa.start
 
     it("should enter 6 hackers") {
@@ -167,10 +167,10 @@ class RedisPersistentSortedSetSpec extends
 
   describe("Transaction semantics") {
     it("should rollback on exception") {
-      val qa = newActor[SortedSetActor]
+      val qa = actorOf[SortedSetActor]
       qa.start
 
-      val failer = newActor[PersistentFailerActor]
+      val failer = actorOf[PersistentFailerActor]
       failer.start
 
       (qa !! SIZE).get.asInstanceOf[Int] should equal(0)
@@ -195,7 +195,7 @@ class RedisPersistentSortedSetSpec extends
 
   describe("zrange") {
     it ("should report proper range") {
-      val qa = newActor[SortedSetActor]
+      val qa = actorOf[SortedSetActor]
       qa.start
       qa !! ADD(h1)
       qa !! ADD(h2)
@@ -214,7 +214,7 @@ class RedisPersistentSortedSetSpec extends
     }
 
     it ("should report proper rge") {
-      val qa = newActor[SortedSetActor]
+      val qa = actorOf[SortedSetActor]
       qa.start
       qa !! ADD(h1)
       qa !! ADD(h2)
diff --git a/akka-samples/akka-sample-camel/src/main/scala/Application1.scala b/akka-samples/akka-sample-camel/src/main/scala/Application1.scala
index 11f1bb8657..dfff0e0539 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/Application1.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/Application1.scala
@@ -17,7 +17,7 @@ object Application1 {
   def main(args: Array[String]) {
     implicit val sender: Option[ActorRef] = None
 
-    val actor1 = newActor[RemoteActor1]
+    val actor1 = actorOf[RemoteActor1]
     val actor2 = RemoteClient.actorFor("remote2", "localhost", 7777)
 
     actor1.start
diff --git a/akka-samples/akka-sample-camel/src/main/scala/Application2.scala b/akka-samples/akka-sample-camel/src/main/scala/Application2.scala
index 8756464b37..e01b510a71 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/Application2.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/Application2.scala
@@ -17,6 +17,6 @@ object Application2 {
     val camelService = CamelService.newInstance
     camelService.load
     RemoteNode.start("localhost", 7777)
-    RemoteNode.register("remote2", newActor[RemoteActor2].start)
+    RemoteNode.register("remote2", actorOf[RemoteActor2].start)
   }
 }
\ No newline at end of file
diff --git a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
index a51563e4a0..9cb4fd6e35 100644
--- a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
+++ b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala
@@ -28,13 +28,13 @@ class Boot {
   val factory = SupervisorFactory(
     SupervisorConfig(
       RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
-      Supervise(newActor[Consumer1], LifeCycle(Permanent)) ::
-      Supervise(newActor[Consumer2], LifeCycle(Permanent)) :: Nil))
+      Supervise(actorOf[Consumer1], LifeCycle(Permanent)) ::
+      Supervise(actorOf[Consumer2], LifeCycle(Permanent)) :: Nil))
   factory.newInstance.start
 
   // Routing example
 
-  val producer = newActor[Producer1]
+  val producer = actorOf[Producer1]
   val mediator = actorOf(new Transformer(producer))
   val consumer = actorOf(new Consumer3(mediator))
 
diff --git a/akka-samples/akka-sample-chat/README b/akka-samples/akka-sample-chat/README
index cf787bd4d2..fec39724e1 100644
--- a/akka-samples/akka-sample-chat/README
+++ b/akka-samples/akka-sample-chat/README
@@ -19,7 +19,7 @@ Then to run the sample:
 4. In the first REPL you get execute: 
   - scala> import sample.chat._
   - scala> import se.scalablesolutions.akka.actor.Actor._
-  - scala> val chatService = newActor[ChatService].start
+  - scala> val chatService = actorOf[ChatService].start
 5. In the second REPL you get execute: 
     - scala> import sample.chat._
     - scala> Runner.run
diff --git a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
index 77383a031b..cfa8597fef 100644
--- a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
+++ b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
@@ -36,7 +36,7 @@ Then to run the sample:
 2. In the first REPL you get execute: 
   - scala> import sample.chat._
   - scala> import se.scalablesolutions.akka.actor.Actor._
-  - scala> val chatService = newActor[ChatService].start
+  - scala> val chatService = actorOf[ChatService].start
 3. In the second REPL you get execute: 
     - scala> import sample.chat._
     - scala> Runner.run
@@ -197,7 +197,7 @@ trait ChatServer extends Actor {
  * Class encapsulating the full Chat Service.
  * Start service by invoking:
  * 
- * val chatService = Actor.newActor[ChatService].start
+ * val chatService = Actor.actorOf[ChatService].start
  * 
*/ class ChatService extends diff --git a/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala b/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala index 453fd53e2a..f8e4f15bd9 100644 --- a/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala @@ -42,10 +42,10 @@ class Boot extends Logging { SupervisorConfig( RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), Supervise( - newActor[SimpleService], + actorOf[SimpleService], LifeCycle(Permanent)) :: Supervise( - newActor[PersistentSimpleService], + actorOf[PersistentSimpleService], LifeCycle(Permanent)) :: Nil)) factory.newInstance.start diff --git a/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala b/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala index 0f00b29a1c..9dcbaeb1d0 100644 --- a/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala +++ b/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala @@ -31,7 +31,7 @@ object ClientManagedRemoteActorServer extends Logging { object ClientManagedRemoteActorClient extends Logging { def run = { - val actor = newActor[RemoteHelloWorldActor] + val actor = actorOf[RemoteHelloWorldActor] log.info("Remote actor created, moved to the server") log.info("Sending 'Hello' to remote actor") val result = actor !! "Hello" diff --git a/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala b/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala index 62ddf23a53..8c88dfb8dd 100644 --- a/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala +++ b/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala @@ -23,7 +23,7 @@ object ServerManagedRemoteActorServer extends Logging { def run = { RemoteNode.start("localhost", 9999) log.info("Remote node started") - RemoteNode.register("hello-service", newActor[HelloWorldActor]) + RemoteNode.register("hello-service", actorOf[HelloWorldActor]) log.info("Remote actor registered and started") } diff --git a/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala b/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala index 53f4663e9d..755e6ca534 100644 --- a/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala +++ b/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala @@ -27,16 +27,16 @@ class Boot { SupervisorConfig( RestartStrategy(OneForOne, 3, 100,List(classOf[Exception])), Supervise( - newActor[SimpleService], + actorOf[SimpleService], LifeCycle(Permanent)) :: Supervise( - newActor[Chat], + actorOf[Chat], LifeCycle(Permanent)) :: Supervise( - newActor[PersistentSimpleService], + actorOf[PersistentSimpleService], LifeCycle(Permanent)) :: Supervise( - newActor[PubSub], + actorOf[PubSub], LifeCycle(Permanent)) :: Nil)) factory.newInstance.start diff --git a/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala b/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala index 6ec40ab7fb..18836b4e19 100644 --- a/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala +++ b/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala @@ -18,18 +18,18 @@ class Boot { // Dummy implementations of all authentication actors // see akka.conf to enable one of these for the AkkaSecurityFilterFactory Supervise( - newActor[BasicAuthenticationService], + actorOf[BasicAuthenticationService], LifeCycle(Permanent)) :: /** Supervise( - newActor[DigestAuthenticationService], + actorOf[DigestAuthenticationService], LifeCycle(Permanent)) :: Supervise( - newActor[SpnegoAuthenticationService], + actorOf[SpnegoAuthenticationService], LifeCycle(Permanent)) :: **/ Supervise( - newActor[SecureTickActor], + actorOf[SecureTickActor], LifeCycle(Permanent)):: Nil)) val supervisor = factory.newInstance From c3d8e85f37af4f5c274f7667280f47230f1cf34a Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Sun, 9 May 2010 15:35:43 +0200 Subject: [PATCH 06/14] Deactivate endpoints of stopped consumer actors (AKKA-183) --- .../src/main/scala/service/CamelService.scala | 2 +- .../scala/service/ConsumerPublisher.scala | 163 +++++++++++++----- .../service/CamelServiceFeatureTest.scala | 28 ++- ...est.scala => ConsumerRegisteredTest.scala} | 23 +-- .../scala/service/PublishRequestorTest.scala | 50 ++++-- .../src/main/scala/Actors.scala | 25 +++ .../src/main/scala/Boot.scala | 4 +- 7 files changed, 219 insertions(+), 76 deletions(-) rename akka-camel/src/test/scala/service/{PublishTest.scala => ConsumerRegisteredTest.scala} (52%) diff --git a/akka-camel/src/main/scala/service/CamelService.scala b/akka-camel/src/main/scala/service/CamelService.scala index 6dd2714e70..566700a737 100644 --- a/akka-camel/src/main/scala/service/CamelService.scala +++ b/akka-camel/src/main/scala/service/CamelService.scala @@ -45,7 +45,7 @@ trait CamelService extends Bootable with Logging { ActorRegistry.addRegistrationListener(publishRequestor.start) // publish already registered consumer actors - for (publish <- Publish.forConsumers(ActorRegistry.actors)) consumerPublisher ! publish + for (actor <- ActorRegistry.actors; event <- ConsumerRegistered.forConsumer(actor)) consumerPublisher ! event } /** diff --git a/akka-camel/src/main/scala/service/ConsumerPublisher.scala b/akka-camel/src/main/scala/service/ConsumerPublisher.scala index 722f4e428e..167f3acaa1 100644 --- a/akka-camel/src/main/scala/service/ConsumerPublisher.scala +++ b/akka-camel/src/main/scala/service/ConsumerPublisher.scala @@ -16,36 +16,66 @@ import se.scalablesolutions.akka.util.Logging /** * Actor that publishes consumer actors as Camel endpoints at the CamelContext managed * by se.scalablesolutions.akka.camel.CamelContextManager. It accepts messages of type - * se.scalablesolutions.akka.camel.service.Publish. + * se.scalablesolutions.akka.camel.service.ConsumerRegistered and + * se.scalablesolutions.akka.camel.service.ConsumerUnregistered. * * @author Martin Krasser */ class ConsumerPublisher extends Actor with Logging { - @volatile private var latch = new CountDownLatch(0) + @volatile private var publishLatch = new CountDownLatch(0) + @volatile private var unpublishLatch = new CountDownLatch(0) /** * Adds a route to the actor identified by a Publish message to the global CamelContext. */ protected def receive = { - case p: Publish => publish(new ConsumerRoute(p.endpointUri, p.id, p.uuid)) - case _ => { /* ignore */} + case r: ConsumerRegistered => { + handleConsumerRegistered(r) + publishLatch.countDown // needed for testing only. + } + case u: ConsumerUnregistered => { + handleConsumerUnregistered(u) + unpublishLatch.countDown // needed for testing only. + } + case _ => { /* ignore */} } /** - * Sets the number of expected Publish messages received by this actor. Used for testing - * only. + * Sets the expected number of actors to be published. Used for testing only. */ - private[camel] def expectPublishCount(count: Int): Unit = latch = new CountDownLatch(count) + private[camel] def expectPublishCount(count: Int): Unit = + publishLatch = new CountDownLatch(count) /** - * Waits for the number of expected Publish messages to arrive. Used for testing only. + * Sets the expected number of actors to be unpublished. Used for testing only. */ - private[camel] def awaitPublish = latch.await + private[camel] def expectUnpublishCount(count: Int): Unit = + unpublishLatch = new CountDownLatch(count) - private def publish(route: ConsumerRoute) { - CamelContextManager.context.addRoutes(route) - log.info("published actor via endpoint %s" format route.endpointUri) - latch.countDown // needed for testing only. + /** + * Waits for the expected number of actors to be published. Used for testing only. + */ + private[camel] def awaitPublish = publishLatch.await + + /** + * Waits for the expected number of actors to be unpublished. Used for testing only. + */ + private[camel] def awaitUnpublish = unpublishLatch.await + + /** + * Creates a route to the registered consumer actor. + */ + private def handleConsumerRegistered(event: ConsumerRegistered) { + CamelContextManager.context.addRoutes(new ConsumerRoute(event.uri, event.id, event.uuid)) + log.info("published actor %s (%s) at endpoint %s" format (event.clazz, event.id, event.uri)) + } + + /** + * Stops route to the already un-registered consumer actor. + */ + private def handleConsumerUnregistered(event: ConsumerUnregistered) { + CamelContextManager.context.stopRoute(event.id) + log.info("unpublished actor %s (%s) from endpoint %s" format (event.clazz, event.id, event.uri)) } } @@ -68,8 +98,8 @@ class ConsumerRoute(val endpointUri: String, id: String, uuid: Boolean) extends def configure = { val schema = endpointUri take endpointUri.indexOf(":") // e.g. "http" from "http://whatever/..." bodyConversions.get(schema) match { - case Some(clazz) => from(endpointUri).convertBodyTo(clazz).to(actorUri) - case None => from(endpointUri).to(actorUri) + case Some(clazz) => from(endpointUri).routeId(id).convertBodyTo(clazz).to(actorUri) + case None => from(endpointUri).routeId(id).to(actorUri) } } @@ -77,59 +107,104 @@ class ConsumerRoute(val endpointUri: String, id: String, uuid: Boolean) extends } /** - * A registration listener that publishes consumer actors (and ignores other actors). + * A registration listener that triggers publication and un-publication of consumer actors. * * @author Martin Krasser */ class PublishRequestor(consumerPublisher: ActorRef) extends Actor { protected def receive = { - case ActorUnregistered(actor) => { /* ignore */ } - case ActorRegistered(actor) => Publish.forConsumer(actor) match { - case Some(publish) => consumerPublisher ! publish - case None => { /* ignore */ } - } + case ActorRegistered(actor) => for (event <- ConsumerRegistered.forConsumer(actor)) consumerPublisher ! event + case ActorUnregistered(actor) => for (event <- ConsumerUnregistered.forConsumer(actor)) consumerPublisher ! event } } /** - * Request message for publishing a consumer actor. - * - * @param endpointUri endpoint URI of the consumer actor - * @param id actor identifier - * @param uuid true if id refers to Actor.uuid, false if - * id refers to Acotr.getId. + * Consumer actor lifecycle event. * * @author Martin Krasser */ -case class Publish(endpointUri: String, id: String, uuid: Boolean) +sealed trait ConsumerEvent + +/** + * Event indicating that a consumer actor has been registered at the actor registry. + * + * @param clazz clazz name of the referenced actor + * @param uri endpoint URI of the consumer actor + * @param id actor identifier + * @param uuid true if id is the actor's uuid, false if + * id is the actor's id. + * + * @author Martin Krasser + */ +case class ConsumerRegistered(clazz: String, uri: String, id: String, uuid: Boolean) extends ConsumerEvent + +/** + * Event indicating that a consumer actor has been unregistered from the actor registry. + * + * @param clazz clazz name of the referenced actor + * @param uri endpoint URI of the consumer actor + * @param id actor identifier + * @param uuid true if id is the actor's uuid, false if + * id is the actor's id. + * + * @author Martin Krasser + */ +case class ConsumerUnregistered(clazz: String, uri: String, id: String, uuid: Boolean) extends ConsumerEvent /** * @author Martin Krasser */ -object Publish { +private[camel] object ConsumerRegistered { + /** + * Optionally creates an ConsumerRegistered event message for a consumer actor or None if + * actorRef is not a consumer actor. + */ + def forConsumer(actorRef: ActorRef): Option[ConsumerRegistered] = actorRef match { + case ConsumerDescriptor(clazz, uri, id, uuid) => Some(ConsumerRegistered(clazz, uri, id, uuid)) + case _ => None + } +} + +/** + * @author Martin Krasser + */ +private[camel] object ConsumerUnregistered { + /** + * Optionally creates an ConsumerUnregistered event message for a consumer actor or None if + * actorRef is not a consumer actor. + */ + def forConsumer(actorRef: ActorRef): Option[ConsumerUnregistered] = actorRef match { + case ConsumerDescriptor(clazz, uri, id, uuid) => Some(ConsumerUnregistered(clazz, uri, id, uuid)) + case _ => None + } +} + +/** + * Describes a consumer actor with elements that are relevant for publishing an actor at a + * Camel endpoint (or unpublishing an actor from an endpoint). + * + * @author Martin Krasser + */ +private[camel] object ConsumerDescriptor { /** - * Creates a list of Publish request messages for all consumer actors in the actors - * list. + * An extractor that optionally creates a 4-tuple from a consumer actor reference containing + * the target actor's class name, endpoint URI, identifier and a hint whether the identifier + * is the actor uuid or actor id. If actorRef doesn't reference a consumer actor, + * None is returned. */ - def forConsumers(actors: List[ActorRef]): List[Publish] = - for (actor <- actors; pub = forConsumer(actor); if pub.isDefined) yield pub.get + def unapply(actorRef: ActorRef): Option[(String, String, String, Boolean)] = + unapplyConsumerInstance(actorRef) orElse unapplyConsumeAnnotated(actorRef) - /** - * Creates a Publish request message if actor is a consumer actor. - */ - def forConsumer(actor: ActorRef): Option[Publish] = - forConsumeAnnotated(actor) orElse forConsumerType(actor) - - private def forConsumeAnnotated(actorRef: ActorRef): Option[Publish] = { + private def unapplyConsumeAnnotated(actorRef: ActorRef): Option[(String, String, String, Boolean)] = { val annotation = actorRef.actorClass.getAnnotation(classOf[consume]) if (annotation eq null) None - else if (actorRef.remoteAddress.isDefined) None // do not publish proxies - else Some(Publish(annotation.value, actorRef.id, false)) + else if (actorRef.remoteAddress.isDefined) None + else Some((actorRef.actor.getClass.getName, annotation.value, actorRef.id, false)) } - private def forConsumerType(actorRef: ActorRef): Option[Publish] = + private def unapplyConsumerInstance(actorRef: ActorRef): Option[(String, String, String, Boolean)] = if (!actorRef.actor.isInstanceOf[Consumer]) None else if (actorRef.remoteAddress.isDefined) None - else Some(Publish(actorRef.actor.asInstanceOf[Consumer].endpointUri, actorRef.uuid, true)) + else Some((actorRef.actor.getClass.getName, actorRef.actor.asInstanceOf[Consumer].endpointUri, actorRef.uuid, true)) } diff --git a/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala b/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala index 34090aa9d5..513007aff8 100644 --- a/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala +++ b/akka-camel/src/test/scala/service/CamelServiceFeatureTest.scala @@ -62,9 +62,9 @@ class CamelServiceFeatureTest extends FeatureSpec with BeforeAndAfterAll with Gi given("two consumer actors registered before and after CamelService startup") service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].expectPublishCount(1) actorOf(new TestConsumer("direct:publish-test-2")).start + service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].awaitPublish when("requests are sent to these actors") - service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].awaitPublish val response1 = CamelContextManager.template.requestBody("direct:publish-test-1", "msg1") val response2 = CamelContextManager.template.requestBody("direct:publish-test-2", "msg2") @@ -74,6 +74,32 @@ class CamelServiceFeatureTest extends FeatureSpec with BeforeAndAfterAll with Gi } } + feature("Unpublish registered consumer actor from the global CamelContext") { + + scenario("attempt access to unregistered consumer actor via Camel direct-endpoint") { + val endpointUri = "direct:unpublish-test-1" + + given("a consumer actor that has been stopped") + assert(CamelContextManager.context.hasEndpoint(endpointUri) eq null) + service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].expectPublishCount(1) + val consumer = actorOf(new TestConsumer(endpointUri)).start + service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].awaitPublish + assert(CamelContextManager.context.hasEndpoint(endpointUri) ne null) + + service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].expectUnpublishCount(1) + consumer.stop + service.consumerPublisher.actor.asInstanceOf[ConsumerPublisher].awaitUnpublish + // endpoint is still there but the route has been stopped + assert(CamelContextManager.context.hasEndpoint(endpointUri) ne null) + + when("a request is sent to this actor") + val response1 = CamelContextManager.template.requestBody(endpointUri, "msg1") + + then("the direct endpoint falls back to its default behaviour and returns the original message") + assert(response1 === "msg1") + } + } + feature("Configure a custom Camel route for the global CamelContext") { scenario("access an actor from the custom Camel route") { diff --git a/akka-camel/src/test/scala/service/PublishTest.scala b/akka-camel/src/test/scala/service/ConsumerRegisteredTest.scala similarity index 52% rename from akka-camel/src/test/scala/service/PublishTest.scala rename to akka-camel/src/test/scala/service/ConsumerRegisteredTest.scala index 22b8e1575b..d9cce517a9 100644 --- a/akka-camel/src/test/scala/service/PublishTest.scala +++ b/akka-camel/src/test/scala/service/ConsumerRegisteredTest.scala @@ -8,7 +8,7 @@ import se.scalablesolutions.akka.actor.Actor._ import se.scalablesolutions.akka.actor.annotation.consume import se.scalablesolutions.akka.camel.Consumer -object PublishTest { +object ConsumerRegisteredTest { @consume("mock:test1") class ConsumeAnnotatedActor extends Actor { id = "test" @@ -25,27 +25,28 @@ object PublishTest { } } -class PublishTest extends JUnitSuite { - import PublishTest._ +class ConsumerRegisteredTest extends JUnitSuite { + import ConsumerRegisteredTest._ @Test def shouldCreatePublishRequestList = { - val publish = Publish.forConsumers(List(actorOf[ConsumeAnnotatedActor])) - assert(publish === List(Publish("mock:test1", "test", false))) + val as = List(actorOf[ConsumeAnnotatedActor]) + val events = for (a <- as; e <- ConsumerRegistered.forConsumer(a)) yield e + assert(events === List(ConsumerRegistered(classOf[ConsumeAnnotatedActor].getName, "mock:test1", "test", false))) } @Test def shouldCreateSomePublishRequestWithActorId = { - val publish = Publish.forConsumer(actorOf[ConsumeAnnotatedActor]) - assert(publish === Some(Publish("mock:test1", "test", false))) + val event = ConsumerRegistered.forConsumer(actorOf[ConsumeAnnotatedActor]) + assert(event === Some(ConsumerRegistered(classOf[ConsumeAnnotatedActor].getName, "mock:test1", "test", false))) } @Test def shouldCreateSomePublishRequestWithActorUuid = { val ca = actorOf[ConsumerActor] - val publish = Publish.forConsumer(ca) - assert(publish === Some(Publish("mock:test2", ca.uuid, true))) + val event = ConsumerRegistered.forConsumer(ca) + assert(event === Some(ConsumerRegistered(ca.actor.getClass.getName, "mock:test2", ca.uuid, true))) } @Test def shouldCreateNone = { - val publish = Publish.forConsumer(actorOf[PlainActor]) - assert(publish === None) + val event = ConsumerRegistered.forConsumer(actorOf[PlainActor]) + assert(event === None) } } diff --git a/akka-camel/src/test/scala/service/PublishRequestorTest.scala b/akka-camel/src/test/scala/service/PublishRequestorTest.scala index 985f18f142..a7f1685de1 100644 --- a/akka-camel/src/test/scala/service/PublishRequestorTest.scala +++ b/akka-camel/src/test/scala/service/PublishRequestorTest.scala @@ -1,41 +1,55 @@ package se.scalablesolutions.akka.camel.service -import org.junit.{After, Test} +import _root_.org.junit.{Before, After, Test} import org.scalatest.junit.JUnitSuite import se.scalablesolutions.akka.camel.Consumer import se.scalablesolutions.akka.camel.support.{Receive, Countdown} -import se.scalablesolutions.akka.actor.{ActorRegistry, ActorRegistered, Actor} +import se.scalablesolutions.akka.actor.{Actor, ActorRef, ActorRegistry, ActorRegistered, ActorUnregistered} import Actor._ object PublishRequestorTest { - class PublisherMock extends Actor with Receive[Publish] { - var received: Publish = _ + class PublisherMock extends Actor with Receive[ConsumerEvent] { + var received: ConsumerEvent = _ protected def receive = { - case msg: Publish => onMessage(msg) + case msg: ConsumerRegistered => onMessage(msg) + case msg: ConsumerUnregistered => onMessage(msg) } - def onMessage(msg: Publish) = received = msg + def onMessage(msg: ConsumerEvent) = received = msg } } class PublishRequestorTest extends JUnitSuite { import PublishRequestorTest._ - - @After def tearDown = ActorRegistry.shutdownAll - @Test def shouldReceivePublishRequestOnActorRegisteredEvent = { - val consumer = actorOf(new Actor with Consumer { + var publisher: ActorRef = _ + var requestor: ActorRef = _ + var consumer: ActorRef = _ + + @Before def setUp = { + publisher = actorOf(new PublisherMock with Countdown[ConsumerEvent]).start + requestor = actorOf(new PublishRequestor(publisher)).start + consumer = actorOf(new Actor with Consumer { def endpointUri = "mock:test" protected def receive = null }).start - val publisher = actorOf(new PublisherMock with Countdown[Publish]) - val requestor = actorOf(new PublishRequestor(publisher)) - publisher.start - requestor.start + } + + @After def tearDown = { + ActorRegistry.shutdownAll + } + + @Test def shouldReceiveConsumerRegisteredEvent = { requestor.!(ActorRegistered(consumer))(None) - publisher.actor.asInstanceOf[Countdown[Publish]].waitFor - assert(publisher.actor.asInstanceOf[PublisherMock].received === Publish("mock:test", consumer.uuid, true)) - publisher.stop - requestor.stop + publisher.actor.asInstanceOf[Countdown[ConsumerEvent]].waitFor + assert(publisher.actor.asInstanceOf[PublisherMock].received === + ConsumerRegistered(consumer.actor.getClass.getName, "mock:test", consumer.uuid, true)) + } + + @Test def shouldReceiveConsumerUnregisteredEvent = { + requestor.!(ActorUnregistered(consumer))(None) + publisher.actor.asInstanceOf[Countdown[ConsumerRegistered]].waitFor + assert(publisher.actor.asInstanceOf[PublisherMock].received === + ConsumerUnregistered(consumer.actor.getClass.getName, "mock:test", consumer.uuid, true)) } } diff --git a/akka-samples/akka-sample-camel/src/main/scala/Actors.scala b/akka-samples/akka-sample-camel/src/main/scala/Actors.scala index d92f742e6f..11fd9020f9 100644 --- a/akka-samples/akka-sample-camel/src/main/scala/Actors.scala +++ b/akka-samples/akka-sample-camel/src/main/scala/Actors.scala @@ -59,6 +59,31 @@ class Consumer3(transformer: ActorRef) extends Actor with Consumer { } } +class Consumer4 extends Actor with Consumer with Logging { + def endpointUri = "jetty:http://0.0.0.0:8877/camel/stop" + + def receive = { + case msg: Message => msg.bodyAs(classOf[String]) match { + case "stop" => { + reply("Consumer4 stopped") + stop + } + case body => reply(body) + } + } +} + +class Consumer5 extends Actor with Consumer with Logging { + def endpointUri = "jetty:http://0.0.0.0:8877/camel/start" + + def receive = { + case _ => { + new Consumer4().start; + reply("Consumer4 started") + } + } +} + class Transformer(producer: ActorRef) extends Actor { protected def receive = { case msg: Message => producer.forward(msg.transformBody[String]("- %s -" format _)) diff --git a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala index 9cb4fd6e35..3fff61174a 100644 --- a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala +++ b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala @@ -61,7 +61,9 @@ class Boot { //val cometdPublisherBridge = new PublisherBridge("jetty:http://0.0.0.0:8877/camel/pub/cometd", cometdPublisher).start val jmsPublisherBridge = new PublisherBridge("jetty:http://0.0.0.0:8877/camel/pub/jms", jmsPublisher).start - + + new Consumer4().start // POSTing "stop" to http://0.0.0.0:8877/camel/stop stops and unpublishes this actor + new Consumer5().start // POSTing any msg to http://0.0.0.0:8877/camel/start starts and published Consumer4 again. } class CustomRouteBuilder extends RouteBuilder { From 81f0419863eb14e2cbfc8069933737fe9a242862 Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Mon, 10 May 2010 20:37:51 +1200 Subject: [PATCH 07/14] Changed the order for detecting akka.conf --- akka-core/src/main/scala/config/Config.scala | 41 +++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/akka-core/src/main/scala/config/Config.scala b/akka-core/src/main/scala/config/Config.scala index f9a1035a7c..c230d45b5d 100644 --- a/akka-core/src/main/scala/config/Config.scala +++ b/akka-core/src/main/scala/config/Config.scala @@ -28,17 +28,7 @@ object Config extends Logging { } val config = { - if (HOME.isDefined) { - try { - val configFile = HOME.get + "/config/akka.conf" - Configgy.configure(configFile) - log.info("AKKA_HOME is defined to [%s], config loaded from [%s].", HOME.get, configFile) - } catch { - case e: ParseException => throw new IllegalStateException( - "'akka.conf' config file can not be found in [" + HOME + "/config/akka.conf] aborting." + - "\n\tEither add it in the 'config' directory or add it to the classpath.") - } - } else if (System.getProperty("akka.config", "") != "") { + if (System.getProperty("akka.config", "") != "") { val configFile = System.getProperty("akka.config", "") try { Configgy.configure(configFile) @@ -47,20 +37,33 @@ object Config extends Logging { case e: ParseException => throw new IllegalStateException( "Config could not be loaded from -Dakka.config=" + configFile) } - } else { + } else if (getClass.getClassLoader.getResource("akka.conf") != null) { try { Configgy.configureFromResource("akka.conf", getClass.getClassLoader) log.info("Config loaded from the application classpath.") } catch { case e: ParseException => throw new IllegalStateException( - "\nCan't find 'akka.conf' configuration file." + - "\nOne of the three ways of locating the 'akka.conf' file needs to be defined:" + - "\n\t1. Define 'AKKA_HOME' environment variable to the root of the Akka distribution." + - "\n\t2. Define the '-Dakka.config=...' system property option." + - "\n\t3. Put the 'akka.conf' file on the classpath." + - "\nI have no way of finding the 'akka.conf' configuration file." + - "\nAborting.") + "Can't load 'akka.conf' config file from application classpath.") } + } else if (HOME.isDefined) { + try { + val configFile = HOME.get + "/config/akka.conf" + Configgy.configure(configFile) + log.info("AKKA_HOME is defined as [%s], config loaded from [%s].", HOME.get, configFile) + } catch { + case e: ParseException => throw new IllegalStateException( + "AKKA_HOME is defined as [" + HOME.get + "] " + + "but the 'akka.conf' config file can not be found at [" + HOME.get + "/config/akka.conf].") + } + } else { + throw new IllegalStateException( + "\nCan't load 'akka.conf'." + + "\nOne of the three ways of locating the 'akka.conf' file needs to be defined:" + + "\n\t1. Define the '-Dakka.config=...' system property option." + + "\n\t2. Put the 'akka.conf' file on the classpath." + + "\n\t3. Define 'AKKA_HOME' environment variable pointing to the root of the Akka distribution." + + "\nI have no way of finding the 'akka.conf' configuration file." + + "\nAborting.") } Configgy.config } From 16c03cca2a66eb4a116c43cbc9a0abdad54367a6 Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Mon, 10 May 2010 14:38:03 +0200 Subject: [PATCH 08/14] Message API improvements --- akka-camel/src/main/scala/Message.scala | 20 +++++++++++++++++++ akka-camel/src/test/scala/MessageTest.scala | 6 +++--- .../src/main/scala/Actors.scala | 10 +++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/akka-camel/src/main/scala/Message.scala b/akka-camel/src/main/scala/Message.scala index 6118a17522..a4231978ec 100644 --- a/akka-camel/src/main/scala/Message.scala +++ b/akka-camel/src/main/scala/Message.scala @@ -23,9 +23,21 @@ case class Message(val body: Any, val headers: Map[String, Any] = Map.empty) { * * @see CamelContextManager. */ + @deprecated("use bodyAs[T](implicit m: Manifest[T]): T instead") def bodyAs[T](clazz: Class[T]): T = CamelContextManager.context.getTypeConverter.mandatoryConvertTo[T](clazz, body) + /** + * Returns the body of the message converted to the type T. Conversion is done + * using Camel's type converter. The type converter is obtained from the CamelContext managed + * by CamelContextManager. Applications have to ensure proper initialization of + * CamelContextManager. + * + * @see CamelContextManager. + */ + def bodyAs[T](implicit m: Manifest[T]): T = + CamelContextManager.context.getTypeConverter.mandatoryConvertTo[T](m.erasure.asInstanceOf[Class[T]], body) + /** * Returns those headers from this message whose name is contained in names. */ @@ -41,8 +53,16 @@ case class Message(val body: Any, val headers: Map[String, Any] = Map.empty) { * * @see Message#bodyAs(Class) */ + @deprecated("use setBodyAs[T](implicit m: Manifest[T]): Message instead") def setBodyAs[T](clazz: Class[T]): Message = setBody(bodyAs(clazz)) + /** + * Creates a Message with a new body converted to type T. + * + * @see Message#bodyAs(Class) + */ + def setBodyAs[T](implicit m: Manifest[T]): Message = setBody(bodyAs[T]) + /** * Creates a Message with a new body. */ diff --git a/akka-camel/src/test/scala/MessageTest.scala b/akka-camel/src/test/scala/MessageTest.scala index 797d48ee57..da317be902 100644 --- a/akka-camel/src/test/scala/MessageTest.scala +++ b/akka-camel/src/test/scala/MessageTest.scala @@ -14,12 +14,12 @@ class MessageTest extends JUnitSuite with BeforeAndAfterAll { override protected def beforeAll = CamelContextManager.init @Test def shouldConvertDoubleBodyToString = { - assertEquals("1.4", Message(1.4, null).bodyAs(classOf[String])) + assertEquals("1.4", Message(1.4, null).bodyAs[String]) } @Test def shouldThrowExceptionWhenConvertingDoubleBodyToInputStream { intercept[NoTypeConversionAvailableException] { - Message(1.4, null).bodyAs(classOf[InputStream]) + Message(1.4, null).bodyAs[InputStream] } } @@ -37,7 +37,7 @@ class MessageTest extends JUnitSuite with BeforeAndAfterAll { @Test def shouldConvertBodyAndPreserveHeaders = { assertEquals( Message("1.4", Map("A" -> "1")), - Message(1.4 , Map("A" -> "1")).setBodyAs(classOf[String])) + Message(1.4 , Map("A" -> "1")).setBodyAs[String]) } @Test def shouldSetBodyAndPreserveHeaders = { diff --git a/akka-samples/akka-sample-camel/src/main/scala/Actors.scala b/akka-samples/akka-sample-camel/src/main/scala/Actors.scala index 11fd9020f9..655adf76a6 100644 --- a/akka-samples/akka-sample-camel/src/main/scala/Actors.scala +++ b/akka-samples/akka-sample-camel/src/main/scala/Actors.scala @@ -40,14 +40,14 @@ class Consumer1 extends Actor with Consumer with Logging { def endpointUri = "file:data/input" def receive = { - case msg: Message => log.info("received %s" format msg.bodyAs(classOf[String])) + case msg: Message => log.info("received %s" format msg.bodyAs[String]) } } @consume("jetty:http://0.0.0.0:8877/camel/test1") class Consumer2 extends Actor { def receive = { - case msg: Message => reply("Hello %s" format msg.bodyAs(classOf[String])) + case msg: Message => reply("Hello %s" format msg.bodyAs[String]) } } @@ -55,7 +55,7 @@ class Consumer3(transformer: ActorRef) extends Actor with Consumer { def endpointUri = "jetty:http://0.0.0.0:8877/camel/welcome" def receive = { - case msg: Message => transformer.forward(msg.setBodyAs(classOf[String])) + case msg: Message => transformer.forward(msg.setBodyAs[String]) } } @@ -63,7 +63,7 @@ class Consumer4 extends Actor with Consumer with Logging { def endpointUri = "jetty:http://0.0.0.0:8877/camel/stop" def receive = { - case msg: Message => msg.bodyAs(classOf[String]) match { + case msg: Message => msg.bodyAs[String] match { case "stop" => { reply("Consumer4 stopped") stop @@ -110,7 +110,7 @@ class PublisherBridge(uri: String, publisher: ActorRef) extends Actor with Consu protected def receive = { case msg: Message => { - publisher ! msg.bodyAs(classOf[String]) + publisher ! msg.bodyAs[String] reply("message published") } } From 2e239f010a1271fab1d906c32bb89cdf77f93f23 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 10 May 2010 21:27:46 +0200 Subject: [PATCH 09/14] Fixing bug with !! and WorkStealing? --- ...sedEventDrivenWorkStealingDispatcher.scala | 58 ++++++++----------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala b/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala index 4edf6651c0..289645ee7d 100644 --- a/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala +++ b/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala @@ -51,12 +51,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(_name: String) extends Mess if (!tryProcessMailbox(invocation.receiver)) { // we are not able to process our mailbox (another thread is busy with it), so lets donate some of our mailbox // to another actor and then process his mailbox in stead. - findThief(invocation.receiver) match { - case Some(thief) => { - tryDonateAndProcessMessages(invocation.receiver, thief) - } - case None => { /* no other actor in the pool */ } - } + findThief(invocation.receiver).foreach( tryDonateAndProcessMessages(invocation.receiver,_) ) } } }) @@ -101,18 +96,13 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(_name: String) extends Mess private def findThief(receiver: ActorRef): Option[ActorRef] = { // copy to prevent concurrent modifications having any impact val actors = pooledActors.toArray(new Array[ActorRef](pooledActors.size)) - var i = lastThiefIndex - if (i > actors.size) - i = 0 - + val i = if ( lastThiefIndex > actors.size ) 0 else lastThiefIndex + // we risk to pick a thief which is unregistered from the dispatcher in the meantime, but that typically means // the dispatcher is being shut down... - doFindThief(receiver, actors, i) match { - case (thief: Option[ActorRef], index: Int) => { - lastThiefIndex = (index + 1) % actors.size - return thief - } - } + val (thief: Option[ActorRef], index: Int) = doFindThief(receiver, actors, i) + lastThiefIndex = (index + 1) % actors.size + thief } /** @@ -127,13 +117,11 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(_name: String) extends Mess for (i <- 0 to actors.length) { val index = (i + startIndex) % actors.length val actor = actors(index) - if (actor != receiver) { // skip ourselves - if (actor._mailbox.isEmpty) { // only pick actors that will most likely be able to process the messages - return (Some(actor), index) - } - } + if (actor != receiver && actor._mailbox.isEmpty) + return (Some(actor), index) } - return (None, startIndex) // nothing found, reuse same start index next time + + (None, startIndex) // nothing found, reuse same start index next time } /** @@ -154,27 +142,27 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(_name: String) extends Mess * Donate messages to the thief and process them on the thief as long as the receiver has more messages. */ private def donateAndProcessMessages(receiver: ActorRef, thief: ActorRef): Unit = { - donateMessage(receiver, thief) match { - case None => { - // no more messages to donate - return - } - case Some(donatedInvocation) => { + if(donateMessage(receiver, thief)) { processMailbox(thief) - return donateAndProcessMessages(receiver, thief) - } + donateAndProcessMessages(receiver, thief) } } /** * Steal a message from the receiver and give it to the thief. */ - private def donateMessage(receiver: ActorRef, thief: ActorRef): Option[MessageInvocation] = { + private def donateMessage(receiver: ActorRef, thief: ActorRef): Boolean = { val donated = receiver._mailbox.pollLast - if (donated != null) { - thief.self ! donated.message - return Some(donated) - } else return None + if (donated ne null) { + donated.replyTo match { + case None => thief.self.!(donated.message)(None) + case Some(Left(actor)) => thief.self.postMessageToMailbox(donated.message,Some(actor)) + case Some(Right(future)) => thief.self.postMessageToMailboxAndCreateFutureResultWithTimeout[Any](donated.message,receiver.timeout,Some(future)) + } + true + } + else + false } def start = if (!active) { From cf4891fc9af5eba475d9bf5fce7e18d99439edee Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 10 May 2010 21:51:00 +0200 Subject: [PATCH 10/14] Fixed potential stack overflow --- ...orBasedEventDrivenWorkStealingDispatcher.scala | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala b/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala index 289645ee7d..28a58a5784 100644 --- a/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala +++ b/akka-core/src/main/scala/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala @@ -131,23 +131,14 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(_name: String) extends Mess private def tryDonateAndProcessMessages(receiver: ActorRef, thief: ActorRef) = { if (thief._dispatcherLock.tryLock) { try { - donateAndProcessMessages(receiver, thief) + while(donateMessage(receiver, thief)) + processMailbox(thief) } finally { thief._dispatcherLock.unlock } } } - /** - * Donate messages to the thief and process them on the thief as long as the receiver has more messages. - */ - private def donateAndProcessMessages(receiver: ActorRef, thief: ActorRef): Unit = { - if(donateMessage(receiver, thief)) { - processMailbox(thief) - donateAndProcessMessages(receiver, thief) - } - } - /** * Steal a message from the receiver and give it to the thief. */ @@ -155,7 +146,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(_name: String) extends Mess val donated = receiver._mailbox.pollLast if (donated ne null) { donated.replyTo match { - case None => thief.self.!(donated.message)(None) + case None => thief.self.postMessageToMailbox(donated.message,None) case Some(Left(actor)) => thief.self.postMessageToMailbox(donated.message,Some(actor)) case Some(Right(future)) => thief.self.postMessageToMailboxAndCreateFutureResultWithTimeout[Any](donated.message,receiver.timeout,Some(future)) } From cbe7262990f8ec3eeb202230ae1795f3338bb8ba Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 10 May 2010 22:18:12 +0200 Subject: [PATCH 11/14] Upgraded to Netty 3.2.0-RC1 --- project/build/AkkaProject.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 9f3f120b13..8019b218ef 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -42,7 +42,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { // val configgy = "Configgy" at "http://www.lag.net/repo" val codehaus = "Codehaus" at "http://repository.codehaus.org" val codehaus_snapshots = "Codehaus Snapshots" at "http://snapshots.repository.codehaus.org" - val jboss = "jBoss" at "http://repository.jboss.org/maven2" + val jboss = "jBoss" at "https://repository.jboss.org/nexus/content/groups/public/" val guiceyfruit = "GuiceyFruit" at "http://guiceyfruit.googlecode.com/svn/repo/releases/" val google = "Google" at "http://google-maven-repository.googlecode.com/svn/repository" val java_net = "java.net" at "http://download.java.net/maven/2" @@ -136,7 +136,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { // ------------------------------------------------------------ // subprojects class AkkaCoreProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { - val netty = "org.jboss.netty" % "netty" % "3.2.0.BETA1" % "compile" + val netty = "org.jboss.netty" % "netty" % "3.2.0.CR1" % "compile" val commons_io = "commons-io" % "commons-io" % "1.4" % "compile" val dispatch_json = "net.databinder" % "dispatch-json_2.8.0.Beta1" % "0.6.6" % "compile" val dispatch_http = "net.databinder" % "dispatch-http_2.8.0.Beta1" % "0.6.6" % "compile" From 80ef9af01e7bb0232ce6f5b0cb70ca6bfcd9a193 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 11 May 2010 19:00:26 +0200 Subject: [PATCH 12/14] AKKA-192 - Upgrade slf4j to 1.6.0 --- project/build/AkkaProject.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 8019b218ef..6f37caff23 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -209,8 +209,8 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { class AkkaCassandraProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { val cassandra = "org.apache.cassandra" % "cassandra" % CASSANDRA_VERSION % "compile" - val slf4j = "org.slf4j" % "slf4j-api" % "1.5.8" % "compile" - val slf4j_log4j = "org.slf4j" % "slf4j-log4j12" % "1.5.8" % "compile" + val slf4j = "org.slf4j" % "slf4j-api" % "1.6.0" % "compile" + val slf4j_log4j = "org.slf4j" % "slf4j-log4j12" % "1.6.0" % "compile" val log4j = "log4j" % "log4j" % "1.2.15" % "compile" // testing val high_scale = "org.apache.cassandra" % "high-scale-lib" % CASSANDRA_VERSION % "test" From 0b02d2bc0adb100d1af33dc8709426f8a1c3abb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Wed, 12 May 2010 12:27:16 +0200 Subject: [PATCH 13/14] Updated to Guice 2.0 --- project/build/AkkaProject.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 6f37caff23..1048f80884 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -150,7 +150,8 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % "2.1" % "compile" val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % "2.1" % "compile" val configgy = "net.lag" % "configgy" % "2.8.0.Beta1-1.5-SNAPSHOT" % "compile" - val guicey = "org.guiceyfruit" % "guice-core" % "2.0-beta-4" % "compile" + val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" + val aopalliance = "aopalliance" % "aopalliance" % "1.0" % "compile" val protobuf = "com.google.protobuf" % "protobuf-java" % "2.2.0" % "compile" val multiverse = "org.multiverse" % "multiverse-alpha" % "0.5" % "compile" From eb50a1cd5f714720651d1c70ee941a77bbfdda26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Wed, 12 May 2010 12:29:43 +0200 Subject: [PATCH 14/14] Fixed wrong instructions in sample-remote README --- akka-samples/akka-sample-remote/README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/akka-samples/akka-sample-remote/README b/akka-samples/akka-sample-remote/README index 052e79a37c..b20d1c7f4e 100644 --- a/akka-samples/akka-sample-remote/README +++ b/akka-samples/akka-sample-remote/README @@ -14,6 +14,7 @@ To run the sample: - Step down into to the root of the Akka distribution. - Set 'export AKKA_HOME=. - Run 'sbt' + - Run 'update' followed by 'compile' if you have not done that before. - Run 'project akka-sample-remote' - Run 'console' to start up a REPL (interpreter). 2. In the first REPL you get execute: @@ -39,6 +40,7 @@ To run the sample: - Step down into to the root of the Akka distribution. - Set 'export AKKA_HOME=. - Run 'sbt' + - Run 'update' followed by 'compile' if you have not done that before. - Run 'project akka-sample-remote' - Run 'console' to start up a REPL (interpreter). 2. In the first REPL you get execute: