diff --git a/akka-docs/intro/getting-started-first-scala-eclipse.rst b/akka-docs/intro/getting-started-first-scala-eclipse.rst index 4e8fdfdae9..9e02f99a71 100644 --- a/akka-docs/intro/getting-started-first-scala-eclipse.rst +++ b/akka-docs/intro/getting-started-first-scala-eclipse.rst @@ -284,7 +284,7 @@ In Scala we have 'case classes' which make excellent messages. So let's start by We also create a common base trait for our messages (that we define as being ``sealed`` in order to prevent creating messages outside our control): -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#messages +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#messages Creating the worker @@ -295,7 +295,7 @@ trait and defining the ``receive`` method. The ``receive`` method defines our message handler. We expect it to be able to handle the ``Work`` message so we need to add a handler for this message: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#worker +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#worker :exclude: calculatePiFor The ``Actor`` trait is defined in ``akka.actor`` and you can either import it explicitly, @@ -318,7 +318,7 @@ The only thing missing in our ``Worker`` actor is the implementation on the algorithm in Scala, in this introductory tutorial we have chosen an imperative style using a for comprehension and an accumulator: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#calculatePiFor +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#calculatePiFor Creating the master @@ -328,11 +328,11 @@ Now create a new class for the master actor. The master actor is a little bit more involved. In its constructor we create a round-robin router to make it easier to spread out the work evenly between the workers. First we need to add some imports: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#imports +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#imports and then we can create the router: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#create-router +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#create-router Now we have a router that is representing all our workers in a single abstraction. So now let's create the master actor. We pass it three integer variables: @@ -343,7 +343,7 @@ abstraction. So now let's create the master actor. We pass it three integer vari Here is the master actor: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#master +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#master :exclude: handle-messages A couple of things are worth explaining further. @@ -370,7 +370,7 @@ will propagate down to all its supervised 'children'. Let's capture this in code: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#master-receive +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#master-receive Creating the result listener ---------------------------- @@ -378,7 +378,7 @@ Creating the result listener The listener is straightforward. When it receives the ``PiApproximation`` from the ``Master`` it prints the result and shuts down the ``ActorSystem``. -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#result-listener +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#result-listener Bootstrap the calculation ------------------------- @@ -390,7 +390,7 @@ which means that we will be able to run this as an application directly from the The ``Pi`` object is a perfect container module for our actors and messages, so let's put them all there. We also create a method ``calculate`` in which we start up the ``Master`` actor and wait for it to finish: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#app +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#app :exclude: actors-and-messages As you can see the *calculate* method above it creates an ``ActorSystem`` and this is the Akka container which diff --git a/akka-docs/intro/getting-started-first-scala.rst b/akka-docs/intro/getting-started-first-scala.rst index 88a2b2c130..0d66c11eea 100644 --- a/akka-docs/intro/getting-started-first-scala.rst +++ b/akka-docs/intro/getting-started-first-scala.rst @@ -49,7 +49,7 @@ check out the full tutorial from the Akka GitHub repository. It is in the `here`__, with the actual source code `here`__. __ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first -__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala +__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala To check out the code using Git invoke the following:: @@ -244,7 +244,7 @@ Now it's about time to start hacking. We start by creating a ``Pi.scala`` file and adding these import statements at the top of the file: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#imports +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#imports If you are using SBT in this tutorial then create the file in the ``src/main/scala`` directory. @@ -282,7 +282,7 @@ start by creating three messages as case classes. We also create a common base trait for our messages (that we define as being ``sealed`` in order to prevent creating messages outside our control): -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#messages +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#messages Creating the worker @@ -293,7 +293,7 @@ trait and defining the ``receive`` method. The ``receive`` method defines our message handler. We expect it to be able to handle the ``Work`` message so we need to add a handler for this message: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#worker +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#worker :exclude: calculatePiFor As you can see we have now created an ``Actor`` with a ``receive`` method as a @@ -308,7 +308,7 @@ The only thing missing in our ``Worker`` actor is the implementation on the algorithm in Scala, in this introductory tutorial we have chosen an imperative style using a for comprehension and an accumulator: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#calculatePiFor +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#calculatePiFor Creating the master @@ -317,7 +317,7 @@ Creating the master The master actor is a little bit more involved. In its constructor we create a round-robin router to make it easier to spread out the work evenly between the workers. Let's do that first: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#create-router +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#create-router Now we have a router that is representing all our workers in a single abstraction. So now let's create the master actor. We pass it three integer variables: @@ -328,7 +328,7 @@ abstraction. So now let's create the master actor. We pass it three integer vari Here is the master actor: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#master +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#master :exclude: handle-messages A couple of things are worth explaining further. @@ -355,7 +355,7 @@ will propagate down to all its supervised 'children'. Let's capture this in code: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#master-receive +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#master-receive Creating the result listener @@ -364,7 +364,7 @@ Creating the result listener The listener is straightforward. When it receives the ``PiApproximation`` from the ``Master`` it prints the result and shuts down the ``ActorSystem``. -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#result-listener +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#result-listener Bootstrap the calculation ========================= @@ -378,7 +378,7 @@ The ``Pi`` object is a perfect container module for our actors and messages, so let's put them all there. We also create a method ``calculate`` in which we start up the ``Master`` actor and wait for it to finish: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala#app +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala#app :exclude: actors-and-messages As you can see the *calculate* method above it creates an ``ActorSystem`` and this is the Akka container which @@ -392,14 +392,14 @@ That's it. Now we are done. But before we package it up and run it, let's take a look at the full code now, with package declaration, imports and all: -.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala +.. includecode:: ../../akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala Run it as a command line application ==================================== If you have not typed in (or copied) the code for the tutorial as in -``$AKKA_HOME/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala`` then now is the time. +``$AKKA_HOME/akka-tutorials/akka-tutorial-first/src/main/scala/akka/tutorial/first/scala/Pi.scala`` then now is the time. When that's done open up a shell and step in to the Akka distribution (``cd $AKKA_HOME``). First we need to compile the source file. That is done with Scala's compiler