")
+// - scala> myClient.login
+// - scala> myClient.post("Can I join?")
+// - scala> println("CHAT LOG:\n\t" + myClient.chatLog.log.mkString("\n\t"))
+//
+//
+// That’s it. Have fun.
+//
+// ******************************************************************************/
+//
+// /**
+// * ChatServer's internal events.
+// */
+// sealed trait Event
+// case class Login(user: String) extends Event
+// case class Logout(user: String) extends Event
+// case class GetChatLog(from: String) extends Event
+// case class ChatLog(log: List[String]) extends Event
+// case class ChatMessage(from: String, message: String) extends Event
+//
+// /**
+// * Chat client.
+// */
+// class ChatClient(val name: String) {
+// val chat = Actor.remote.actorFor("chat:service", "localhost", 2552)
+//
+// def login = chat ! Login(name)
+// def logout = chat ! Logout(name)
+// def post(message: String) = chat ! ChatMessage(name, name + ": " + message)
+// def chatLog = (chat !! GetChatLog(name)).as[ChatLog].getOrElse(throw new Exception("Couldn't get the chat log from ChatServer"))
+// }
+//
+// /**
+// * Internal chat client session.
+// */
+// class Session(user: String, storage: ActorRef) extends Actor {
+// private val loginTime = System.currentTimeMillis
+// private var userLog: List[String] = Nil
+//
+// EventHandler.info(this, "New session for user [%s] has been created at [%s]".format(user, loginTime))
+//
+// def receive = {
+// case msg @ ChatMessage(from, message) =>
+// userLog ::= message
+// storage ! msg
+//
+// case msg @ GetChatLog(_) =>
+// storage forward msg
+// }
+// }
+//
+// /**
+// * Abstraction of chat storage holding the chat log.
+// */
+// trait ChatStorage extends Actor
+//
+// /**
+// * Memory-backed chat storage implementation.
+// */
+// class MemoryChatStorage extends ChatStorage {
+// private var chatLog = TransactionalVector[Array[Byte]]()
+//
+// EventHandler.info(this, "Memory-based chat storage is starting up...")
+//
+// def receive = {
+// case msg @ ChatMessage(from, message) =>
+// EventHandler.debug(this, "New chat message [%s]".format(message))
+// atomic { chatLog + message.getBytes("UTF-8") }
+//
+// case GetChatLog(_) =>
+// val messageList = atomic { chatLog.map(bytes => new String(bytes, "UTF-8")).toList }
+// reply(ChatLog(messageList))
+// }
+//
+// override def postRestart(reason: Throwable) {
+// chatLog = TransactionalVector()
+// }
+// }
+//
+// /**
+// * Implements user session management.
+// *
+// * Uses self-type annotation (this: Actor =>) to declare that it needs to be mixed in with an Actor.
+// */
+// trait SessionManagement { this: Actor =>
+//
+// val storage: ActorRef // needs someone to provide the ChatStorage
+// val sessions = new HashMap[String, ActorRef]
+//
+// protected def sessionManagement: Receive = {
+// case Login(username) =>
+// EventHandler.info(this, "User [%s] has logged in".format(username))
+// val session = actorOf(new Session(username, storage))
+// session
+// sessions += (username -> session)
+//
+// case Logout(username) =>
+// EventHandler.info(this, "User [%s] has logged out".format(username))
+// val session = sessions(username)
+// session.stop()
+// sessions -= username
+// }
+//
+// protected def shutdownSessions() {
+// sessions.foreach { case (_, session) => session.stop() }
+// }
+// }
+//
+// /**
+// * Implements chat management, e.g. chat message dispatch.
+// *
+// * Uses self-type annotation (this: Actor =>) to declare that it needs to be mixed in with an Actor.
+// */
+// trait ChatManagement { this: Actor =>
+// val sessions: HashMap[String, ActorRef] // needs someone to provide the Session map
+//
+// protected def chatManagement: Receive = {
+// case msg @ ChatMessage(from, _) => getSession(from).foreach(_ ! msg)
+// case msg @ GetChatLog(from) => getSession(from).foreach(_ forward msg)
+// }
+//
+// private def getSession(from: String) : Option[ActorRef] = {
+// if (sessions.contains(from))
+// Some(sessions(from))
+// else {
+// EventHandler.info(this, "Session expired for %s".format(from))
+// None
+// }
+// }
+// }
+//
+// /**
+// * Creates and links a MemoryChatStorage.
+// */
+// trait MemoryChatStorageFactory { this: Actor =>
+// val storage = actorOf(Props[MemoryChatStorage].withSupervisor(this.self)) // starts and links ChatStorage
+// }
+//
+// /**
+// * Chat server. Manages sessions and redirects all other messages to the Session for the client.
+// */
+// trait ChatServer extends Actor {
+// //faultHandler = OneForOneStrategy(List(classOf[Exception]),5, 5000)
+// val storage: ActorRef
+//
+// EventHandler.info(this, "Chat server is starting up...")
+//
+// // actor message handler
+// def receive: Receive = sessionManagement orElse chatManagement
+//
+// // abstract methods to be defined somewhere else
+// protected def chatManagement: Receive
+// protected def sessionManagement: Receive
+// protected def shutdownSessions()
+//
+// override def postStop() {
+// EventHandler.info(this, "Chat server is shutting down...")
+// shutdownSessions()
+// storage.stop()
+// }
+// }
+//
+// /**
+// * Class encapsulating the full Chat Service.
+// * Start service by invoking:
+// *
+// * val chatService = Actor.actorOf[ChatService]
+// *
+// */
+// class ChatService extends
+// ChatServer with
+// SessionManagement with
+// ChatManagement with
+// MemoryChatStorageFactory {
+// override def preStart() {
+// remote.start("localhost", 2552);
+// remote.register("chat:service", self) //Register the actor with the specified service id
+// }
+// }
+//
+// /**
+// * Test runner starting ChatService.
+// */
+// object ServerRunner {
+//
+// def main(args: Array[String]) { ServerRunner.run() }
+//
+// def run() {
+// actorOf[ChatService]
+// }
+// }
+//
+// /**
+// * Test runner emulating a chat session.
+// */
+// object ClientRunner {
+//
+// def main(args: Array[String]) { ClientRunner.run() }
+//
+// def run() {
+//
+// val client1 = new ChatClient("jonas")
+// client1.login
+// val client2 = new ChatClient("patrik")
+// client2.login
+//
+// client1.post("Hi there")
+// println("CHAT LOG:\n\t" + client1.chatLog.log.mkString("\n\t"))
+//
+// client2.post("Hello")
+// println("CHAT LOG:\n\t" + client2.chatLog.log.mkString("\n\t"))
+//
+// client1.post("Hi again")
+// println("CHAT LOG:\n\t" + client1.chatLog.log.mkString("\n\t"))
+//
+// client1.logout
+// client2.logout
+// }
+// }
+//
diff --git a/akka-samples/akka-sample-fsm/src/README b/akka-samples/akka-sample-fsm/src/README
new file mode 100644
index 0000000000..17971c005b
--- /dev/null
+++ b/akka-samples/akka-sample-fsm/src/README
@@ -0,0 +1,30 @@
+FSM
+===
+
+Requirements
+------------
+
+To build and run FSM you need [Simple Build Tool][sbt] (sbt).
+
+Running
+-------
+
+First time, 'sbt update' to get dependencies, then to run Ants use 'sbt run'.
+Here is an example. First type 'sbt' to start SBT interactively, the run 'update' and 'run':
+> cd $AKKA_HOME
+
+> % sbt
+
+> > update
+
+> > project akka-sample-fsm
+
+> > run
+
+> > Choose 1 or 2 depending on what sample you wish to run
+
+Notice
+------
+
+[akka]: http://akka.io
+[sbt]: http://code.google.com/p/simple-build-tool/
diff --git a/akka-samples/akka-sample-fsm/src/main/scala/Buncher.scala b/akka-samples/akka-sample-fsm/src/main/scala/Buncher.scala
index 0dcf33e401..d039609a98 100644
--- a/akka-samples/akka-sample-fsm/src/main/scala/Buncher.scala
+++ b/akka-samples/akka-sample-fsm/src/main/scala/Buncher.scala
@@ -1,3 +1,6 @@
+/**
+ * Copyright (C) 2009-2010 Typesafe Inc. .
+ */
package sample.fsm.buncher
import akka.actor.ActorRefFactory
@@ -6,15 +9,15 @@ import akka.util.Duration
import akka.actor.{ FSM, Actor, ActorRef }
/*
- * generic typed object buncher.
- *
- * To instantiate it, use the factory method like so:
- * Buncher(100, 500)(x : List[AnyRef] => x foreach println)
- * which will yield a fully functional ActorRef.
- * The type of messages allowed is strongly typed to match the
- * supplied processing method; other messages are discarded (and
- * possibly logged).
- */
+* generic typed object buncher.
+*
+* To instantiate it, use the factory method like so:
+* Buncher(100, 500)(x : List[AnyRef] => x foreach println)
+* which will yield a fully functional ActorRef.
+* The type of messages allowed is strongly typed to match the
+* supplied processing method; other messages are discarded (and
+* possibly logged).
+*/
object GenericBuncher {
trait State
case object Idle extends State
diff --git a/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala
index 2c23940c9f..3acbf473e6 100644
--- a/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala
+++ b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala
@@ -1,3 +1,6 @@
+/**
+ * Copyright (C) 2009-2010 Typesafe Inc. .
+ */
package sample.fsm.dining.become
//Akka adaptation of
@@ -7,8 +10,8 @@ import akka.actor.{ ActorRef, Actor, ActorSystem }
import akka.util.duration._
/*
- * First we define our messages, they basically speak for themselves
- */
+* First we define our messages, they basically speak for themselves
+*/
sealed trait DiningHakkerMessage
case class Busy(chopstick: ActorRef) extends DiningHakkerMessage
case class Put(hakker: ActorRef) extends DiningHakkerMessage
@@ -18,9 +21,9 @@ object Eat extends DiningHakkerMessage
object Think extends DiningHakkerMessage
/*
- * A Chopstick is an actor, it can be taken, and put back
- */
-class Chopstick(name: String) extends Actor {
+* A Chopstick is an actor, it can be taken, and put back
+*/
+class Chopstick extends Actor {
//When a Chopstick is taken by a hakker
//It will refuse to be taken by other hakkers
@@ -44,8 +47,8 @@ class Chopstick(name: String) extends Actor {
}
/*
- * A hakker is an awesome dude or dudett who either thinks about hacking or has to eat ;-)
- */
+* A hakker is an awesome dude or dudett who either thinks about hacking or has to eat ;-)
+*/
class Hakker(name: String, left: ActorRef, right: ActorRef) extends Actor {
//When a hakker is thinking it can become hungry
@@ -75,7 +78,7 @@ class Hakker(name: String, left: ActorRef, right: ActorRef) extends Actor {
//back to think about how he should obtain his chopsticks :-)
def waiting_for(chopstickToWaitFor: ActorRef, otherChopstick: ActorRef): Receive = {
case Taken(`chopstickToWaitFor`) ⇒
- println("%s has picked up %s and %s, and starts to eat", name, left.address, right.address)
+ println("%s has picked up %s and %s and starts to eat".format(name, left.name, right.name))
become(eating)
system.scheduler.scheduleOnce(self, Think, 5 seconds)
@@ -105,27 +108,33 @@ class Hakker(name: String, left: ActorRef, right: ActorRef) extends Actor {
become(thinking)
left ! Put(self)
right ! Put(self)
- println("%s puts down his chopsticks and starts to think", name)
+ println("%s puts down his chopsticks and starts to think".format(name))
system.scheduler.scheduleOnce(self, Eat, 5 seconds)
}
//All hakkers start in a non-eating state
def receive = {
case Think ⇒
- println("%s starts to think", name)
+ println("%s starts to think".format(name))
become(thinking)
system.scheduler.scheduleOnce(self, Eat, 5 seconds)
}
}
/*
- * Alright, here's our test-harness
- */
+* Alright, here's our test-harness
+*/
object DiningHakkers {
val system = ActorSystem()
+
+ def main(args: Array[String]) {
+ run
+ }
+
def run {
//Create 5 chopsticks
- val chopsticks = for (i ← 1 to 5) yield system.actorOf(new Chopstick("Chopstick " + i))
+ val chopsticks = for (i ← 1 to 5) yield system.actorOf[Chopstick]("Chopstick " + i)
+
//Create 5 awesome hakkers and assign them their left and right chopstick
val hakkers = for {
(name, i) ← List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex
diff --git a/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala
index 987f630784..d0c8bca54a 100644
--- a/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala
+++ b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala
@@ -1,3 +1,6 @@
+/**
+ * Copyright (C) 2009-2010 Typesafe Inc. .
+ */
package sample.fsm.dining.fsm
import akka.actor.{ ActorRef, Actor, FSM, ActorSystem }
@@ -6,8 +9,8 @@ import akka.util.Duration
import akka.util.duration._
/*
- * Some messages for the chopstick
- */
+* Some messages for the chopstick
+*/
sealed trait ChopstickMessage
object Take extends ChopstickMessage
object Put extends ChopstickMessage
@@ -27,9 +30,9 @@ case object Taken extends ChopstickState
case class TakenBy(hakker: ActorRef)
/*
- * A chopstick is an actor, it can be taken, and put back
- */
-class Chopstick(name: String) extends Actor with FSM[ChopstickState, TakenBy] {
+* A chopstick is an actor, it can be taken, and put back
+*/
+class Chopstick extends Actor with FSM[ChopstickState, TakenBy] {
// A chopstick begins its existence as available and taken by no one
startWith(Available, TakenBy(system.deadLetters))
@@ -77,8 +80,8 @@ case object Eating extends FSMHakkerState
case class TakenChopsticks(left: Option[ActorRef], right: Option[ActorRef])
/*
- * A fsm hakker is an awesome dude or dudette who either thinks about hacking or has to eat ;-)
- */
+* A fsm hakker is an awesome dude or dudette who either thinks about hacking or has to eat ;-)
+*/
class FSMHakker(name: String, left: ActorRef, right: ActorRef) extends Actor with FSM[FSMHakkerState, TakenChopsticks] {
//All hakkers start waiting
@@ -86,7 +89,7 @@ class FSMHakker(name: String, left: ActorRef, right: ActorRef) extends Actor wit
when(Waiting) {
case Event(Think, _) ⇒
- println("%s starts to think", name)
+ println("%s starts to think".format(name))
startThinking(5 seconds)
}
@@ -125,7 +128,7 @@ class FSMHakker(name: String, left: ActorRef, right: ActorRef) extends Actor wit
}
private def startEating(left: ActorRef, right: ActorRef): State = {
- println("%s has picked up %s and %s, and starts to eat", name, left.address, right.address)
+ println("%s has picked up %s and %s and starts to eat".format(name, left.name, right.name))
goto(Eating) using TakenChopsticks(Some(left), Some(right)) forMax (5 seconds)
}
@@ -144,7 +147,7 @@ class FSMHakker(name: String, left: ActorRef, right: ActorRef) extends Actor wit
// then he puts down his chopsticks and starts to think
when(Eating) {
case Event(StateTimeout, _) ⇒
- println("%s puts down his chopsticks and starts to think", name)
+ println("%s puts down his chopsticks and starts to think".format(name))
left ! Put
right ! Put
startThinking(5 seconds)
@@ -159,15 +162,19 @@ class FSMHakker(name: String, left: ActorRef, right: ActorRef) extends Actor wit
}
/*
- * Alright, here's our test-harness
- */
+* Alright, here's our test-harness
+*/
object DiningHakkersOnFsm {
val system = ActorSystem()
+ def main(args: Array[String]) {
+ run
+ }
+
def run = {
// Create 5 chopsticks
- val chopsticks = for (i ← 1 to 5) yield system.actorOf(new Chopstick("Chopstick " + i))
+ val chopsticks = for (i ← 1 to 5) yield system.actorOf[Chopstick]("Chopstick " + i)
// Create 5 awesome fsm hakkers and assign them their left and right chopstick
val hakkers = for {
(name, i) ← List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex
diff --git a/akka-samples/akka-sample-hello/config/akka.conf b/akka-samples/akka-sample-hello/config/akka.conf
deleted file mode 100644
index 5b8920874f..0000000000
--- a/akka-samples/akka-sample-hello/config/akka.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-####################
-# Akka Config File #
-####################
-
-akka {
- version = "2.0-SNAPSHOT"
-
- enabled-modules = ["http"]
-
- time-unit = "seconds"
-
- event-handlers = ["akka.event.EventHandler$DefaultListener"]
-
- boot = ["sample.hello.Boot"]
-
- http {
- hostname = "localhost"
- port = 9998
-
- connection-close = true
- root-actor-id = "_httproot"
- root-actor-builtin = true
- timeout = 1000
- expired-header-name = "Async-Timeout"
- expired-header-value = "expired"
- }
-}
diff --git a/akka-samples/akka-sample-hello/config/microkernel-server.xml b/akka-samples/akka-sample-hello/config/microkernel-server.xml
deleted file mode 100644
index 4f86dab23c..0000000000
--- a/akka-samples/akka-sample-hello/config/microkernel-server.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 300000
- 2
- false
- 8443
- 20000
- 5000
-
-
-
-
-
-
-
-
-
-
-
- -
-
- /
-
- akka.http.AkkaMistServlet
- /*
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- true
- true
- true
- 1000
-
-
diff --git a/akka-samples/akka-sample-hello/src/README b/akka-samples/akka-sample-hello/src/README
new file mode 100644
index 0000000000..cd271f1dde
--- /dev/null
+++ b/akka-samples/akka-sample-hello/src/README
@@ -0,0 +1,28 @@
+HELLO
+=====
+
+Requirements
+------------
+
+To build and run FSM you need [Simple Build Tool][sbt] (sbt).
+
+Running
+-------
+
+First time, 'sbt update' to get dependencies, then to run Ants use 'sbt run'.
+Here is an example. First type 'sbt' to start SBT interactively, the run 'update' and 'run':
+> cd $AKKA_HOME
+
+> % sbt
+
+> > update
+
+> > project akka-sample-hello
+
+> > run
+
+Notice
+------
+
+[akka]: http://akka.io
+[sbt]: http://code.google.com/p/simple-build-tool/
diff --git a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala
deleted file mode 100644
index 149c6a3ee4..0000000000
--- a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Copyright (C) 2009-2011 Typesafe Inc.
- */
-
-package sample.hello
-
-import akka.actor._
-import akka.http._
-
-class Boot {
- val supervisor = Supervisor(OneForOneStrategy(List(classOf[Exception]), 3, 100))
- Actor.actorOf(Props[RootEndpoint].withSupervisor(supervisor))
- Actor.actorOf(Props[HelloEndpoint].withSupervisor(supervisor))
-}
diff --git a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/HelloEndpoint.scala b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/HelloEndpoint.scala
deleted file mode 100644
index 2ea8c1fe83..0000000000
--- a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/HelloEndpoint.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (C) 2009-2011 Typesafe Inc.
- */
-
-package sample.hello
-
-import akka.actor._
-import akka.http._
-
-import java.text.DateFormat
-import java.util.Date
-
-class HelloEndpoint extends Actor with Endpoint {
- self.dispatcher = Endpoint.Dispatcher
-
- lazy val hello = Actor.actorOf(
- new Actor {
- def time = DateFormat.getTimeInstance.format(new Date)
- def receive = {
- case get: Get => get OK "Hello at " + time
- }
- })
-
- def hook: Endpoint.Hook = { case _ => hello }
-
- override def preStart = Actor.registry.actorFor(MistSettings.RootActorID).get ! Endpoint.Attach(hook)
-
- def receive = handleHttpRequest
-}
diff --git a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Main.scala b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Main.scala
new file mode 100644
index 0000000000..e3399e86fc
--- /dev/null
+++ b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Main.scala
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2009-2011 Typesafe Inc.
+ */
+package sample.hello
+
+import akka.actor.{ ActorSystem, Actor }
+
+case object Start
+
+object Main {
+ def main(args: Array[String]) {
+ val system = ActorSystem()
+ system.actorOf[HelloActor] ! Start
+ }
+}
+
+class HelloActor extends Actor {
+ val worldActor = system.actorOf[WorldActor]
+ def receive = {
+ case Start ⇒ worldActor ! "Hello"
+ case s: String ⇒
+ println("Received message: %s".format(s))
+ system.stop()
+ }
+}
+
+class WorldActor extends Actor {
+ def receive = {
+ case s: String ⇒ sender ! s.toUpperCase + " world!"
+ }
+}
+
diff --git a/akka-samples/akka-sample-osgi/src/main/scala/OsgiExample.scala b/akka-samples/akka-sample-osgi/src/main/scala/OsgiExample.scala
index 3e2d7af049..bf257ffd49 100644
--- a/akka-samples/akka-sample-osgi/src/main/scala/OsgiExample.scala
+++ b/akka-samples/akka-sample-osgi/src/main/scala/OsgiExample.scala
@@ -3,29 +3,27 @@
*/
package sample.osgi
-import akka.actor.Actor
-import akka.actor.Actor._
-
import org.osgi.framework.{ BundleActivator, BundleContext }
+import akka.actor.{ Timeout, ActorSystem, Actor }
class Activator extends BundleActivator {
+ val system = ActorSystem()
def start(context: BundleContext) {
println("Starting the OSGi example ...")
- val echo = actorOf[EchoActor]
- val answer = (echo ? "OSGi example").as[String]
+ val echo = system.actorOf[EchoActor]
+ val answer = (echo ? ("OSGi example", Timeout(100))).as[String]
println(answer getOrElse "No answer!")
}
def stop(context: BundleContext) {
- Actor.registry.local.shutdownAll()
+ system.stop()
println("Stopped the OSGi example.")
}
}
class EchoActor extends Actor {
-
override def receive = {
- case x => reply(x)
+ case x ⇒ sender ! x
}
}
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 84a201f530..9b3a27a7ae 100644
--- a/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala
+++ b/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala
@@ -2,35 +2,37 @@
* Copyright (C) 2009-2011 Typesafe Inc.
*/
-package sample.remote
-
-import akka.actor.Actor._
-import akka.actor. {ActorRegistry, Actor}
-
-class HelloWorldActor extends Actor {
- def receive = {
- case "Hello" =>
- reply("World")
- }
-}
-
-object ServerManagedRemoteActorServer {
-
- def run = {
- Actor.remote.start("localhost", 2552)
- Actor.remote.register("hello-service", actorOf[HelloWorldActor])
- }
-
- def main(args: Array[String]) = run
-}
-
-object ServerManagedRemoteActorClient {
-
- def run = {
- val actor = Actor.remote.actorFor("hello-service", "localhost", 2552)
- val result = actor !! "Hello"
- }
-
- def main(args: Array[String]) = run
-}
+// REMOTING IS NOT PART OF MILESTONE 1 OF AKKA 2.0
+//package sample.remote
+//
+//import akka.actor.Actor._
+//import akka.actor. {ActorRegistry, Actor}
+//
+//class HelloWorldActor extends Actor {
+// def receive = {
+// case "Hello" =>
+// reply("World")
+// }
+//}
+//
+//object ServerManagedRemoteActorServer {
+//
+// def run = {
+// Actor.remote.start("localhost", 2552)
+// Actor.remote.register("hello-service", actorOf[HelloWorldActor])
+// }
+//
+// def main(args: Array[String]) = run
+//}
+//
+//object ServerManagedRemoteActorClient {
+//
+// def run = {
+// val actor = Actor.remote.actorFor("hello-service", "localhost", 2552)
+// val result = actor !! "Hello"
+// }
+//
+// def main(args: Array[String]) = run
+//}
+//
diff --git a/akka-tutorials/akka-tutorial-first/pom.xml b/akka-tutorials/akka-tutorial-first/pom.xml
index 8e25d972f3..1cec835a9c 100644
--- a/akka-tutorials/akka-tutorial-first/pom.xml
+++ b/akka-tutorials/akka-tutorial-first/pom.xml
@@ -13,7 +13,7 @@
- se.scalablesolutions.akka
+ com.typesafe.akka
akka-actor
2.0-SNAPSHOT
diff --git a/akka-tutorials/akka-tutorial-first/project/TutorialBuild.scala b/akka-tutorials/akka-tutorial-first/project/TutorialBuild.scala
new file mode 100644
index 0000000000..5e5ef32493
--- /dev/null
+++ b/akka-tutorials/akka-tutorial-first/project/TutorialBuild.scala
@@ -0,0 +1,22 @@
+import sbt._
+import Keys._
+
+object TutorialBuild extends Build {
+ lazy val buildSettings = Seq(
+ organization := "com.typesafe.akka",
+ version := "2.0-SNAPSHOT",
+ scalaVersion := "2.9.1"
+ )
+
+ lazy val akka = Project(
+ id = "akka-tutorial-first",
+ base = file("."),
+ settings = Defaults.defaultSettings ++ Seq(
+ libraryDependencies ++= Seq(
+ "com.typesafe.akka" % "akka-actor" % "2.0-SNAPSHOT",
+ "junit" % "junit" % "4.5" % "test",
+ "org.scalatest" % "scalatest_2.9.0" % "1.6.1" % "test",
+ "com.typesafe.akka" % "akka-testkit" % "2.0-SNAPSHOT" % "test")
+ )
+ )
+}
\ No newline at end of file
diff --git a/akka-tutorials/akka-tutorial-first/project/build.properties b/akka-tutorials/akka-tutorial-first/project/build.properties
index 4981c1c2c3..c6158f7be4 100644
--- a/akka-tutorials/akka-tutorial-first/project/build.properties
+++ b/akka-tutorials/akka-tutorial-first/project/build.properties
@@ -1,5 +1 @@
-project.organization=se.scalablesolutions.akka
-project.name=akka-tutorial-first
-project.version=2.0-SNAPSHOT
-build.scala.versions=2.9.0
-sbt.version=0.7.7
+sbt.version=0.11.0
\ No newline at end of file
diff --git a/akka-tutorials/akka-tutorial-first/project/build/Project.scala b/akka-tutorials/akka-tutorial-first/project/build/Project.scala
deleted file mode 100644
index 975f2ce970..0000000000
--- a/akka-tutorials/akka-tutorial-first/project/build/Project.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-import sbt._
-
-class TutorialOneProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject
diff --git a/akka-tutorials/akka-tutorial-first/project/plugins/Plugins.scala b/akka-tutorials/akka-tutorial-first/project/plugins/Plugins.scala
deleted file mode 100644
index fb121fcd3e..0000000000
--- a/akka-tutorials/akka-tutorial-first/project/plugins/Plugins.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-import sbt._
-
-class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
- val akkaRepo = "Akka Repo" at "http://akka.io/repository"
- val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "2.0-SNAPSHOT"
-}
diff --git a/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java b/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java
index ca8fe597f7..d6b9e8c1f1 100644
--- a/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java
+++ b/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java
@@ -1,182 +1,184 @@
-// *
-// * Copyright (C) 2009-2011 Typesafe Inc.
+/**
+ * Copyright (C) 2009-2011 Typesafe Inc.
+ */
+package akka.tutorial.first.java;
-// package akka.tutorial.first.java;
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.actor.UntypedActor;
+import akka.actor.UntypedActorFactory;
+import akka.japi.Creator;
+import akka.routing.*;
-// import static akka.actor.Actors.poisonPill;
-// import static java.util.Arrays.asList;
+import java.util.LinkedList;
+import java.util.concurrent.CountDownLatch;
-// import akka.actor.ActorRef;
-// import akka.actor.Actors;
-// import akka.actor.ActorSystem;
-// import akka.actor.UntypedActor;
-// import akka.actor.UntypedActorFactory;
-// import akka.routing.RoutedProps;
-// import akka.routing.RouterType;
-// import akka.routing.LocalConnectionManager;
-// import akka.routing.Routing;
-// import akka.routing.Routing.Broadcast;
-// import scala.collection.JavaConversions;
+public class Pi {
-// import java.util.LinkedList;
-// import java.util.concurrent.CountDownLatch;
+ private static final ActorSystem system = ActorSystem.apply();
-// public class Pi {
+ public static void main(String[] args) throws Exception {
+ Pi pi = new Pi();
+ pi.calculate(4, 10000, 10000);
+ }
-// private static final ActorSystem system = new ActorSystem();
+ // ====================
+ // ===== Messages =====
+ // ====================
+ static class Calculate {
+ }
-// public static void main(String[] args) throws Exception {
-// Pi pi = new Pi();
-// pi.calculate(4, 10000, 10000);
-// }
+ static class Work {
+ private final int start;
+ private final int nrOfElements;
-// // ====================
-// // ===== Messages =====
-// // ====================
-// static class Calculate {}
+ public Work(int start, int nrOfElements) {
+ this.start = start;
+ this.nrOfElements = nrOfElements;
+ }
-// static class Work {
-// private final int start;
-// private final int nrOfElements;
+ public int getStart() {
+ return start;
+ }
-// public Work(int start, int nrOfElements) {
-// this.start = start;
-// this.nrOfElements = nrOfElements;
-// }
+ public int getNrOfElements() {
+ return nrOfElements;
+ }
+ }
-// public int getStart() { return start; }
-// public int getNrOfElements() { return nrOfElements; }
-// }
+ static class Result {
+ private final double value;
-// static class Result {
-// private final double value;
+ public Result(double value) {
+ this.value = value;
+ }
-// public Result(double value) {
-// this.value = value;
-// }
+ public double getValue() {
+ return value;
+ }
+ }
-// public double getValue() { return value; }
-// }
+ // ==================
+ // ===== Worker =====
+ // ==================
+ public static class Worker extends UntypedActor {
-// // ==================
-// // ===== Worker =====
-// // ==================
-// static class Worker extends UntypedActor {
+ // define the work
+ private double calculatePiFor(int start, int nrOfElements) {
+ double acc = 0.0;
+ for (int i = start * nrOfElements; i <= ((start + 1) * nrOfElements - 1); i++) {
+ acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1);
+ }
+ return acc;
+ }
-// // define the work
-// private double calculatePiFor(int start, int nrOfElements) {
-// double acc = 0.0;
-// for (int i = start * nrOfElements; i <= ((start + 1) * nrOfElements - 1); i++) {
-// acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1);
-// }
-// return acc;
-// }
+ // message handler
+ public void onReceive(Object message) {
+ if (message instanceof Work) {
+ Work work = (Work) message;
-// // message handler
-// public void onReceive(Object message) {
-// if (message instanceof Work) {
-// Work work = (Work) message;
+ // perform the work
+ double result = calculatePiFor(work.getStart(), work.getNrOfElements());
-// // perform the work
-// double result = calculatePiFor(work.getStart(), work.getNrOfElements());
+ // reply with the result
+ getSender().tell(new Result(result));
-// // reply with the result
-// getSender().tell(new Result(result));
+ } else throw new IllegalArgumentException("Unknown message [" + message + "]");
+ }
+ }
-// } else throw new IllegalArgumentException("Unknown message [" + message + "]");
-// }
-// }
+ // ==================
+ // ===== Master =====
+ // ==================
+ public static class Master extends UntypedActor {
+ private final int nrOfMessages;
+ private final int nrOfElements;
+ private final CountDownLatch latch;
-// // ==================
-// // ===== Master =====
-// // ==================
-// static class Master extends UntypedActor {
-// private final int nrOfMessages;
-// private final int nrOfElements;
-// private final CountDownLatch latch;
+ private double pi;
+ private int nrOfResults;
+ private long start;
-// private double pi;
-// private int nrOfResults;
-// private long start;
+ private ActorRef router;
-// private ActorRef router;
+ public Master(final int nrOfWorkers, int nrOfMessages, int nrOfElements, CountDownLatch latch) {
+ this.nrOfMessages = nrOfMessages;
+ this.nrOfElements = nrOfElements;
+ this.latch = latch;
+ Creator routerCreator = new Creator() {
+ public Router create() {
+ return new RoundRobinRouter();
+ }
+ };
+ LinkedList actors = new LinkedList() {
+ {
+ for (int i = 0; i < nrOfWorkers; i++) add(system.actorOf(Worker.class));
+ }
+ };
+ RoutedProps props = new RoutedProps(routerCreator, new LocalConnectionManager(actors), new akka.actor.Timeout(-1), true);
+ router = new RoutedActorRef(system, props, getSelf(), "pi");
+ }
-// public Master(int nrOfWorkers, int nrOfMessages, int nrOfElements, CountDownLatch latch) {
-// this.nrOfMessages = nrOfMessages;
-// this.nrOfElements = nrOfElements;
-// this.latch = latch;
+ // message handler
+ public void onReceive(Object message) {
-// LinkedList workers = new LinkedList();
-// for (int i = 0; i < nrOfWorkers; i++) {
-// ActorRef worker = system.actorOf(Worker.class);
-// workers.add(worker);
-// }
+ if (message instanceof Calculate) {
-// router = system.actorOf(new RoutedProps().withRoundRobinRouter().withLocalConnections(workers), "pi");
-// }
+ // schedule work
+ for (int start = 0; start < nrOfMessages; start++) {
+ router.tell(new Work(start, nrOfElements), getSelf());
+ }
-// // message handler
-// public void onReceive(Object message) {
+ } else if (message instanceof Result) {
-// if (message instanceof Calculate) {
-// // schedule work
-// for (int start = 0; start < nrOfMessages; start++) {
-// router.tell(new Work(start, nrOfElements), getSelf());
-// }
+ // handle result from the worker
+ Result result = (Result) message;
+ pi += result.getValue();
+ nrOfResults += 1;
+ if (nrOfResults == nrOfMessages) getSelf().stop();
-// // send a PoisonPill to all workers telling them to shut down themselves
-// router.tell(new Broadcast(poisonPill()));
+ } else throw new IllegalArgumentException("Unknown message [" + message + "]");
+ }
-// // send a PoisonPill to the router, telling him to shut himself down
-// router.tell(poisonPill());
+ @Override
+ public void preStart() {
+ start = System.currentTimeMillis();
+ }
-// } else if (message instanceof Result) {
+ @Override
+ public void postStop() {
+ // tell the world that the calculation is complete
+ System.out.println(String.format(
+ "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis",
+ pi, (System.currentTimeMillis() - start)));
+ latch.countDown();
+ }
+ }
-// // handle result from the worker
-// Result result = (Result) message;
-// pi += result.getValue();
-// nrOfResults += 1;
-// if (nrOfResults == nrOfMessages) getSelf().stop();
+ // ==================
+ // ===== Run it =====
+ // ==================
+ public void calculate(final int nrOfWorkers, final int nrOfElements, final int nrOfMessages)
+ throws Exception {
-// } else throw new IllegalArgumentException("Unknown message [" + message + "]");
-// }
+ // this latch is only plumbing to know when the calculation is completed
+ final CountDownLatch latch = new CountDownLatch(1);
-// @Override
-// public void preStart() {
-// start = System.currentTimeMillis();
-// }
+ // create the master
+ ActorRef master = system.actorOf(new UntypedActorFactory() {
+ public UntypedActor create() {
+ return new Master(nrOfWorkers, nrOfMessages, nrOfElements, latch);
+ }
+ });
-// @Override
-// public void postStop() {
-// // tell the world that the calculation is complete
-// System.out.println(String.format(
-// "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis",
-// pi, (System.currentTimeMillis() - start)));
-// latch.countDown();
-// }
-// }
+ // start the calculation
+ master.tell(new Calculate());
-// // ==================
-// // ===== Run it =====
-// // ==================
-// public void calculate(final int nrOfWorkers, final int nrOfElements, final int nrOfMessages)
-// throws Exception {
+ // wait for master to shut down
+ latch.await();
-// // this latch is only plumbing to know when the calculation is completed
-// final CountDownLatch latch = new CountDownLatch(1);
-
-// // create the master
-// ActorRef master = system.actorOf(new UntypedActorFactory() {
-// public UntypedActor create() {
-// return new Master(nrOfWorkers, nrOfMessages, nrOfElements, latch);
-// }
-// });
-
-// // start the calculation
-// master.tell(new Calculate());
-
-// // wait for master to shut down
-// latch.await();
-// }
-// }
+ // Shut down the system
+ system.stop();
+ }
+}
diff --git a/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala b/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala
index 836f766e12..d7f932a053 100644
--- a/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala
+++ b/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala
@@ -1,113 +1,114 @@
-// /**
-// * Copyright (C) 2009-2011 Typesafe Inc.
-// */
+/**
+ * Copyright (C) 2009-2011 Typesafe Inc.
+ */
+package akka.tutorial.first.scala
-// package akka.tutorial.first.scala
+import java.util.concurrent.CountDownLatch
+import akka.routing.{ RoutedActorRef, LocalConnectionManager, RoundRobinRouter, RoutedProps }
+import akka.actor.{ ActorSystemImpl, Actor, ActorSystem }
-// import akka.actor.{ Actor, PoisonPill, ActorSystem }
-// import Actor._
-// import java.util.concurrent.CountDownLatch
-// import akka.routing.Routing.Broadcast
-// import akka.routing.{ RoutedProps, Routing }
+object Pi extends App {
-// object Pi extends App {
+ val system = ActorSystem()
-// val system = ActorSystem()
+ // Initiate the calculation
+ calculate(nrOfWorkers = 4, nrOfElements = 10000, nrOfMessages = 10000)
-// calculate(nrOfWorkers = 4, nrOfElements = 10000, nrOfMessages = 10000)
+ // ====================
+ // ===== Messages =====
+ // ====================
+ sealed trait PiMessage
-// // ====================
-// // ===== Messages =====
-// // ====================
-// sealed trait PiMessage
+ case object Calculate extends PiMessage
-// case object Calculate extends PiMessage
+ case class Work(start: Int, nrOfElements: Int) extends PiMessage
-// case class Work(start: Int, nrOfElements: Int) extends PiMessage
+ case class Result(value: Double) extends PiMessage
-// case class Result(value: Double) extends PiMessage
+ // ==================
+ // ===== Worker =====
+ // ==================
+ class Worker extends Actor {
-// // ==================
-// // ===== Worker =====
-// // ==================
-// class Worker extends Actor {
+ // define the work
+ def calculatePiFor(start: Int, nrOfElements: Int): Double = {
+ var acc = 0.0
+ for (i ← start until (start + nrOfElements))
+ acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1)
+ acc
+ }
-// // define the work
-// def calculatePiFor(start: Int, nrOfElements: Int): Double = {
-// var acc = 0.0
-// for (i ← start until (start + nrOfElements))
-// acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1)
-// acc
-// }
+ def receive = {
+ case Work(start, nrOfElements) ⇒ sender ! Result(calculatePiFor(start, nrOfElements)) // perform the work
+ }
+ }
-// def receive = {
-// case Work(start, nrOfElements) ⇒ sender ! Result(calculatePiFor(start, nrOfElements)) // perform the work
-// }
-// }
+ // ==================
+ // ===== Master =====
+ // ==================
+ class Master(nrOfWorkers: Int, nrOfMessages: Int, nrOfElements: Int, latch: CountDownLatch)
+ extends Actor {
-// // ==================
-// // ===== Master =====
-// // ==================
-// class Master(nrOfWorkers: Int, nrOfMessages: Int, nrOfElements: Int, latch: CountDownLatch)
-// extends Actor {
+ var pi: Double = _
+ var nrOfResults: Int = _
+ var start: Long = _
-// var pi: Double = _
-// var nrOfResults: Int = _
-// var start: Long = _
+ // create the workers
+ val workers = Vector.fill(nrOfWorkers)(system.actorOf[Worker])
-// // create the workers
-// val workers = Vector.fill(nrOfWorkers)(system.actorOf[Worker])
+ // wrap them with a load-balancing router
+ val props = RoutedProps(routerFactory = () ⇒ new RoundRobinRouter, connectionManager = new LocalConnectionManager(workers))
+ val router = new RoutedActorRef(system, props, self, "pi")
-// // wrap them with a load-balancing router
-// val router = system.actorOf(RoutedProps().withRoundRobinRouter.withLocalConnections(workers), "pi")
+ // message handler
+ def receive = {
+ case Calculate ⇒
+ // schedule work
+ for (i ← 0 until nrOfMessages) router ! Work(i * nrOfElements, nrOfElements)
+ case Result(value) ⇒
+ // handle result from the worker
+ pi += value
+ nrOfResults += 1
-// // message handler
-// def receive = {
-// case Calculate ⇒
-// // schedule work
-// for (i ← 0 until nrOfMessages) router ! Work(i * nrOfElements, nrOfElements)
+ // Stop this actor and all its supervised children
+ if (nrOfResults == nrOfMessages) self.stop()
+ }
-// // send a PoisonPill to all workers telling them to shut down themselves
-// router ! Broadcast(PoisonPill)
+ override def preStart() {
+ start = System.currentTimeMillis
+ }
-// // send a PoisonPill to the router, telling him to shut himself down
-// router ! PoisonPill
+ override def postStop() {
+ // tell the world that the calculation is complete
+ println(
+ "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis"
+ .format(pi, (System.currentTimeMillis - start)))
+ latch.countDown()
+ }
+ }
-// case Result(value) ⇒
-// // handle result from the worker
-// pi += value
-// nrOfResults += 1
-// if (nrOfResults == nrOfMessages) self.stop()
-// }
+ object Master {
+ val impl = system.asInstanceOf[ActorSystemImpl]
+ }
-// override def preStart() {
-// start = System.currentTimeMillis
-// }
+ // ==================
+ // ===== Run it =====
+ // ==================
+ def calculate(nrOfWorkers: Int, nrOfElements: Int, nrOfMessages: Int) {
-// override def postStop() {
-// // tell the world that the calculation is complete
-// println(
-// "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis"
-// .format(pi, (System.currentTimeMillis - start)))
-// latch.countDown()
-// }
-// }
+ // this latch is only plumbing to know when the calculation is completed
+ val latch = new CountDownLatch(1)
-// // ==================
-// // ===== Run it =====
-// // ==================
-// def calculate(nrOfWorkers: Int, nrOfElements: Int, nrOfMessages: Int) {
+ // create the master
+ val master = system.actorOf(new Master(nrOfWorkers, nrOfMessages, nrOfElements, latch))
-// // this latch is only plumbing to know when the calculation is completed
-// val latch = new CountDownLatch(1)
+ // start the calculation
+ master ! Calculate
-// // create the master
-// val master = system.actorOf(new Master(nrOfWorkers, nrOfMessages, nrOfElements, latch))
+ // wait for master to shut down
+ latch.await()
-// // start the calculation
-// master ! Calculate
-
-// // wait for master to shut down
-// latch.await()
-// }
-// }
+ // Shut down the system
+ system.stop()
+ }
+}
diff --git a/akka-tutorials/akka-tutorial-first/src/test/scala/WorkerSpec.scala b/akka-tutorials/akka-tutorial-first/src/test/scala/WorkerSpec.scala
new file mode 100644
index 0000000000..608ba55481
--- /dev/null
+++ b/akka-tutorials/akka-tutorial-first/src/test/scala/WorkerSpec.scala
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2009-2011 Typesafe Inc.
+ */
+package akka.tutorial.first.scala
+
+import org.junit.runner.RunWith
+import org.scalatest.matchers.MustMatchers
+import org.scalatest.WordSpec
+import akka.testkit.TestActorRef
+import akka.tutorial.first.scala.Pi.Worker
+import akka.actor.ActorSystem
+
+@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
+class WorkerSpec extends WordSpec with MustMatchers {
+
+ implicit def system = ActorSystem()
+
+ "Worker" must {
+ "calculate pi correctly" in {
+ val testActor = TestActorRef[Worker]
+ val actor = testActor.underlyingActor
+ actor.calculatePiFor(0, 0) must equal(0.0)
+ actor.calculatePiFor(1, 1) must equal(-1.3333333333333333)
+ }
+ }
+}
\ No newline at end of file
diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala
index dd09fe3c80..e4fb06a8cc 100644
--- a/project/AkkaBuild.scala
+++ b/project/AkkaBuild.scala
@@ -243,23 +243,31 @@ object AkkaBuild extends Build {
id = "akka-samples",
base = file("akka-samples"),
settings = parentSettings,
- aggregate = Seq(fsmSample)
- // aggregate = Seq(fsmSample, camelSample)
+ aggregate = Seq(antsSample, helloSample, osgiSample, fsmSample)
)
- // lazy val antsSample = Project(
- // id = "akka-sample-ants",
- // base = file("akka-samples/akka-sample-ants"),
- // dependencies = Seq(stm),
- // settings = defaultSettings
- // )
+ lazy val antsSample = Project(
+ id = "akka-sample-ants",
+ base = file("akka-samples/akka-sample-ants"),
+ dependencies = Seq(actor, stm),
+ settings = defaultSettings
+ )
- // lazy val chatSample = Project(
- // id = "akka-sample-chat",
- // base = file("akka-samples/akka-sample-chat"),
- // dependencies = Seq(cluster),
- // settings = defaultSettings
- // )
+ lazy val helloSample = Project(
+ id = "akka-sample-hello",
+ base = file("akka-samples/akka-sample-hello"),
+ dependencies = Seq(actor),
+ settings = defaultSettings
+ )
+
+ lazy val osgiSample = Project(
+ id = "akka-sample-osgi",
+ base = file("akka-samples/akka-sample-osgi"),
+ dependencies = Seq(actor),
+ settings = defaultSettings ++ Seq(
+ libraryDependencies ++= Dependencies.sampleOsgi
+ )
+ )
lazy val fsmSample = Project(
id = "akka-sample-fsm",
@@ -268,6 +276,21 @@ object AkkaBuild extends Build {
settings = defaultSettings
)
+ // lazy val chatSample = Project(
+ // id = "akka-sample-chat",
+ // base = file("akka-samples/akka-sample-chat"),
+ // dependencies = Seq(cluster),
+ // settings = defaultSettings
+ // )
+
+ // lazy val samples = Project(
+ // id = "akka-samples",
+ // base = file("akka-samples"),
+ // settings = parentSettings,
+ // aggregate = Seq(fsmSample)
+ // // aggregate = Seq(fsmSample, camelSample)
+ // )
+
// lazy val camelSample = Project(
// id = "akka-sample-camel",
// base = file("akka-samples/akka-sample-camel"),
@@ -277,13 +300,6 @@ object AkkaBuild extends Build {
// )
// )
- // lazy val helloSample = Project(
- // id = "akka-sample-hello",
- // base = file("akka-samples/akka-sample-hello"),
- // dependencies = Seq(kernel),
- // settings = defaultSettings
- // )
-
// lazy val remoteSample = Project(
// id = "akka-sample-remote",
// base = file("akka-samples/akka-sample-remote"),
@@ -295,22 +311,24 @@ object AkkaBuild extends Build {
id = "akka-tutorials",
base = file("akka-tutorials"),
settings = parentSettings,
- aggregate = Seq(firstTutorial, secondTutorial)
+ aggregate = Seq(firstTutorial)
)
lazy val firstTutorial = Project(
id = "akka-tutorial-first",
base = file("akka-tutorials/akka-tutorial-first"),
- dependencies = Seq(actor),
- settings = defaultSettings
+ dependencies = Seq(actor, testkit),
+ settings = defaultSettings ++ Seq(
+ libraryDependencies ++= Dependencies.tutorials
+ )
)
- lazy val secondTutorial = Project(
- id = "akka-tutorial-second",
- base = file("akka-tutorials/akka-tutorial-second"),
- dependencies = Seq(actor),
- settings = defaultSettings
- )
+ // lazy val secondTutorial = Project(
+ // id = "akka-tutorial-second",
+ // base = file("akka-tutorials/akka-tutorial-second"),
+ // dependencies = Seq(actor),
+ // settings = defaultSettings
+ // )
lazy val docs = Project(
id = "akka-docs",
@@ -448,6 +466,10 @@ object Dependencies {
// val sampleCamel = Seq(camelCore, camelSpring, commonsCodec, Runtime.camelJms, Runtime.activemq, Runtime.springJms,
// Test.junit, Test.scalatest, Test.logback)
+ val sampleOsgi = Seq(osgi)
+
+ val tutorials = Seq(Test.scalatest, Test.junit)
+
val docs = Seq(Test.scalatest, Test.junit)
}