!pro #17380 Build with Java 8

* genjavadoc adjustments for java8
This commit is contained in:
Patrik Nordwall 2015-05-05 16:44:49 +02:00
parent 67a9e62254
commit 0953e7aee3
41 changed files with 156 additions and 368 deletions

View file

@ -10,18 +10,19 @@ import static akka.actor.SupervisorStrategy.Directive;
* Used for building a partial function for {@link akka.actor.Actor#supervisorStrategy() Actor.supervisorStrategy()}.
* *
* Inside an actor you can use it like this with Java 8 to define your supervisorStrategy.
* <p/>
* <p>
* Example:
* </p>
* <pre>
* @Override
* &#64;Override
* private static SupervisorStrategy strategy =
* new OneForOneStrategy(10, Duration.create("1 minute"), DeciderBuilder.
* match(ArithmeticException.class, e -> resume()).
* match(NullPointerException.class, e -> restart()).
* match(IllegalArgumentException.class, e -> stop()).
* matchAny(o -> escalate()).build());
* match(ArithmeticException.class, e -&gt; resume()).
* match(NullPointerException.class, e -&gt; restart()).
* match(IllegalArgumentException.class, e -&gt; stop()).
* matchAny(o -&gt; escalate()).build());
*
* @Override
* &#64;Override
* public SupervisorStrategy supervisorStrategy() {
* return strategy;
* }

View file

@ -90,10 +90,11 @@ public class Match<I, R> extends AbstractMatch<I, R> {
/**
* Convenience function to make the Java code more readable.
* <p>
* <p></p>
*
* <pre><code>
* Matcher&lt;X, Y&gt; matcher = Matcher.create(...);
* <p>
*
* Y someY = matcher.match(obj);
* </code></pre>
*

View file

@ -10,19 +10,20 @@ package akka.japi.pf;
* There is both a match on type only, and a match on type and predicate.
*
* Inside an actor you can use it like this with Java 8 to define your receive method.
* <p/>
* <p>
* Example:
* </p>
* <pre>
* @Override
* &#64;Override
* public Actor() {
* receive(ReceiveBuilder.
* match(Double.class, d -> {
* match(Double.class, d -&gt; {
* sender().tell(d.isNaN() ? 0 : d, self());
* }).
* match(Integer.class, i -> {
* match(Integer.class, i -&gt; {
* sender().tell(i * 10, self());
* }).
* match(String.class, s -> s.startsWith("foo"), s -> {
* match(String.class, s -&gt; s.startsWith("foo"), s -&gt; {
* sender().tell(s.toUpperCase(), self());
* }).build()
* );

View file

@ -110,7 +110,7 @@ public class UnitMatch<I> extends AbstractMatch<I, BoxedUnit> {
* <p>
* <pre><code>
* UnitMatcher&lt;X&gt; matcher = UnitMatcher.create(...);
* <p>
*
* matcher.match(obj);
* </code></pre>
*

View file

@ -204,7 +204,7 @@ before or after using them to construct an actor system:
.. parsed-literal::
Welcome to Scala version @scalaVersion@ (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
Welcome to Scala version @scalaVersion@ (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0).
Type in expressions to have them evaluated.
Type :help for more information.

View file

@ -4,9 +4,11 @@ Getting Started
Prerequisites
-------------
Akka requires that you have `Java 1.6 <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_ or
Akka requires that you have `Java 8 <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_ or
later installed on you machine.
`Typesafe <http://www.typesafe.com>`_ provides versions of Akka that are compatible with Java 6, 7 and 8.
Getting Started Guides and Template Projects
--------------------------------------------
@ -33,8 +35,7 @@ Akka is very modular and consists of several JARs containing different features.
- ``akka-cluster`` Cluster membership management, elastic routers.
- ``akka-osgi`` base bundle for using Akka in OSGi containers, containing the
``akka-actor`` classes
- ``akka-osgi`` utilities for using Akka in OSGi containers
- ``akka-osgi-aries`` Aries blueprint for provisioning actor systems

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor;
package docs.actorlambda;
import akka.actor.*;
import akka.japi.pf.ReceiveBuilder;
@ -13,8 +13,8 @@ import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import scala.PartialFunction;
import scala.runtime.BoxedUnit;
import static docs.actor.Messages.Swap.Swap;
import static docs.actor.Messages.*;
import static docs.actorlambda.Messages.Swap.Swap;
import static docs.actorlambda.Messages.*;
import static akka.japi.Util.immutableSeq;
import java.util.concurrent.TimeUnit;

View file

@ -1,7 +1,7 @@
/**
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor;
package docs.actorlambda;
//#testkit
import akka.actor.*;

View file

@ -1,8 +1,7 @@
package docs.actor;
/**
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actorlambda;
import akka.actor.AbstractActor;
import akka.actor.ActorRef;

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor;
package docs.actorlambda;
import java.util.ArrayList;
import java.util.Collections;

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor;
package docs.actorlambda;
//#imports
import akka.actor.AbstractActor;

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor;
package docs.actorlambda;
//#sample-actor
import akka.actor.AbstractActor;

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor;
package docs.actorlambda;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor.fsm;
package docs.actorlambda.fsm;
//#simple-imports
import akka.actor.AbstractFSM;
@ -14,11 +14,11 @@ import java.util.List;
import scala.concurrent.duration.Duration;
//#simple-imports
import static docs.actor.fsm.Buncher.Data;
import static docs.actor.fsm.Buncher.State.*;
import static docs.actor.fsm.Buncher.State;
import static docs.actor.fsm.Buncher.Uninitialized.*;
import static docs.actor.fsm.Events.*;
import static docs.actorlambda.fsm.Buncher.Data;
import static docs.actorlambda.fsm.Buncher.State.*;
import static docs.actorlambda.fsm.Buncher.State;
import static docs.actorlambda.fsm.Buncher.Uninitialized.*;
import static docs.actorlambda.fsm.Events.*;
//#simple-fsm
public class Buncher extends AbstractFSM<State, Data> {

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor.fsm;
package docs.actorlambda.fsm;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
@ -13,11 +13,11 @@ import org.junit.BeforeClass;
import org.junit.Test;
import java.util.LinkedList;
import docs.actor.fsm.*;
import static docs.actor.fsm.Events.Batch;
import static docs.actor.fsm.Events.Queue;
import static docs.actor.fsm.Events.SetTarget;
import static docs.actor.fsm.Events.Flush.Flush;
import docs.actorlambda.fsm.*;
import static docs.actorlambda.fsm.Events.Batch;
import static docs.actorlambda.fsm.Events.Queue;
import static docs.actorlambda.fsm.Events.SetTarget;
import static docs.actorlambda.fsm.Events.Flush.Flush;
//#test-code
public class BuncherTest {

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor.fsm;
package docs.actorlambda.fsm;
import akka.actor.ActorRef;
import java.util.List;

View file

@ -2,7 +2,7 @@
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor.fsm;
package docs.actorlambda.fsm;
import akka.actor.*;
import akka.testkit.JavaTestKit;
@ -14,8 +14,8 @@ import scala.concurrent.duration.Duration;
import static org.junit.Assert.*;
import static docs.actor.fsm.FSMDocTest.StateType.*;
import static docs.actor.fsm.FSMDocTest.Messages.*;
import static docs.actorlambda.fsm.FSMDocTest.StateType.*;
import static docs.actorlambda.fsm.FSMDocTest.Messages.*;
import static java.util.concurrent.TimeUnit.*;
public class FSMDocTest {
@ -173,7 +173,7 @@ public class FSMDocTest {
expectMsgEquals(Active);
expectMsgEquals(Data.Foo);
String msg = expectMsgClass(String.class);
assertThat(msg, CoreMatchers.startsWith("LogEntry(SomeState,Foo,Actor[akka://FSMDocTest/system/"));
assertTrue(msg.startsWith("LogEntry(SomeState,Foo,Actor[akka://FSMDocTest/system/"));
}};
}
}

View file

@ -1,7 +1,7 @@
/**
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package docs.actor.japi;
package docs.actorlambda.japi;
//#all
//#imports
@ -28,10 +28,10 @@ import static akka.actor.SupervisorStrategy.escalate;
import static akka.pattern.Patterns.ask;
import static akka.pattern.Patterns.pipe;
import static docs.actor.japi.FaultHandlingDocSample.WorkerApi.*;
import static docs.actor.japi.FaultHandlingDocSample.CounterServiceApi.*;
import static docs.actor.japi.FaultHandlingDocSample.CounterApi.*;
import static docs.actor.japi.FaultHandlingDocSample.StorageApi.*;
import static docs.actorlambda.japi.FaultHandlingDocSample.WorkerApi.*;
import static docs.actorlambda.japi.FaultHandlingDocSample.CounterServiceApi.*;
import static docs.actorlambda.japi.FaultHandlingDocSample.CounterApi.*;
import static docs.actorlambda.japi.FaultHandlingDocSample.StorageApi.*;
//#imports

View file

@ -95,12 +95,12 @@ To select a Protocol Family you must extend ``akka.io.Inet.DatagramChannelCreato
class which implements ``akka.io.Inet.SocketOption``. Provide custom logic
for opening a datagram channel by overriding :meth:`create` method.
.. includecode:: ../../../akka-samples/akka-docs-udp-multicast/src/main/java/docs/io/JavaUdpMulticast.java#inet6-protocol-family
.. includecode:: code/docs/io/JavaUdpMulticast.java#inet6-protocol-family
Another socket option will be needed to join a multicast group.
.. includecode:: ../../../akka-samples/akka-docs-udp-multicast/src/main/java/docs/io/JavaUdpMulticast.java#multicast-group
.. includecode:: code/docs/io/JavaUdpMulticast.java#multicast-group
Socket options must be provided to :meth:`UdpMessage.bind` command.
.. includecode:: ../../../akka-samples/akka-docs-udp-multicast/src/main/java/docs/io/JavaUdpMulticast.java#bind
.. includecode:: code/docs/io/JavaUdpMulticast.java#bind

View file

@ -51,7 +51,7 @@ function there is a builder named ``ReceiveBuilder`` that you can use.
Here is an example:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/MyActor.java
.. includecode:: code/docs/actorlambda/MyActor.java
:include: imports,my-actor
Please note that the Akka Actor ``receive`` message loop is exhaustive, which
@ -80,8 +80,8 @@ creating an actor including associated deployment information (e.g. which
dispatcher to use, see more below). Here are some examples of how to create a
:class:`Props` instance.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#import-props
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#creating-props
.. includecode:: code/docs/actorlambda/ActorDocTest.java#import-props
.. includecode:: code/docs/actorlambda/ActorDocTest.java#creating-props
The second variant shows how to pass constructor arguments to the
:class:`Actor` being created, but it should only be used outside of actors as
@ -96,7 +96,7 @@ found.
Dangerous Variants
^^^^^^^^^^^^^^^^^^
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#creating-props-deprecated
.. includecode:: code/docs/actorlambda/ActorDocTest.java#creating-props-deprecated
This method is not recommended to be used within another actor because it
encourages to close over the enclosing scope, resulting in non-serializable
@ -128,14 +128,14 @@ associated with using the ``Props.create(...)`` method which takes a by-name
argument, since within a companion object the given code block will not retain
a reference to its enclosing scope:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#props-factory
.. includecode:: code/docs/actorlambda/ActorDocTest.java#props-factory
Another good practice is to declare what messages an Actor can receive
as close to the actor definition as possible (e.g. as static classes
inside the Actor or using other suitable class), which makes it easier to know
what it can receive.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#messages-in-companion
.. includecode:: code/docs/actorlambda/ActorDocTest.java#messages-in-companion
Creating Actors with Props
--------------------------
@ -144,14 +144,14 @@ Actors are created by passing a :class:`Props` instance into the
:meth:`actorOf` factory method which is available on :class:`ActorSystem` and
:class:`ActorContext`.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#import-actorRef
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#system-actorOf
.. includecode:: code/docs/actorlambda/ActorDocTest.java#import-actorRef
.. includecode:: code/docs/actorlambda/ActorDocTest.java#system-actorOf
Using the :class:`ActorSystem` will create top-level actors, supervised by the
actor systems provided guardian actor, while using an actors context will
create a child actor.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#context-actorOf
.. includecode:: code/docs/actorlambda/ActorDocTest.java#context-actorOf
:exclude: plus-some-behavior
It is recommended to create a hierarchy of children, grand-children and so on
@ -321,7 +321,7 @@ termination (see `Stopping Actors`_). This service is provided by the
Registering a monitor is easy:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#watch
.. includecode:: code/docs/actorlambda/ActorDocTest.java#watch
It should be noted that the :class:`Terminated` message is generated
independent of the order in which registration and termination occur.
@ -348,7 +348,7 @@ Start Hook
Right after starting the actor, its :meth:`preStart` method is invoked.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#preStart
.. includecode:: code/docs/actorlambda/ActorDocTest.java#preStart
This method is called when the actor is first created. During restarts it is
called by the default implementation of :meth:`postRestart`, which means that
@ -427,7 +427,7 @@ actors may look up other actors by specifying absolute or relative
paths—logical or physical—and receive back an :class:`ActorSelection` with the
result:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#selection-local
.. includecode:: code/docs/actorlambda/ActorDocTest.java#selection-local
.. note::
@ -453,7 +453,7 @@ structure, i.e. the supervisor.
The path elements of an actor selection may contain wildcard patterns allowing for
broadcasting of messages to that section:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#selection-wildcard
.. includecode:: code/docs/actorlambda/ActorDocTest.java#selection-wildcard
Messages can be sent via the :class:`ActorSelection` and the path of the
:class:`ActorSelection` is looked up when delivering each message. If the selection
@ -469,8 +469,8 @@ actors which are traversed in the sense that if a concrete name lookup fails
negative result is generated. Please note that this does not mean that delivery
of that reply is guaranteed, it still is a normal message.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#import-identify
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#identify
.. includecode:: code/docs/actorlambda/ActorDocTest.java#import-identify
.. includecode:: code/docs/actorlambda/ActorDocTest.java#identify
You can also acquire an :class:`ActorRef` for an :class:`ActorSelection` with
the ``resolveOne`` method of the :class:`ActorSelection`. It returns a ``Future``
@ -480,7 +480,7 @@ didn't complete within the supplied `timeout`.
Remote actor addresses may also be looked up, if :ref:`remoting <remoting-java>` is enabled:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#selection-remote
.. includecode:: code/docs/actorlambda/ActorDocTest.java#selection-remote
An example demonstrating actor look-up is given in :ref:`remote-sample-java`.
@ -537,7 +537,7 @@ Tell: Fire-forget
This is the preferred way of sending messages. No blocking waiting for a
message. This gives the best concurrency and scalability characteristics.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#tell
.. includecode:: code/docs/actorlambda/ActorDocTest.java#tell
The sender reference is passed along with the message and available within the
receiving actor via its :meth:`sender()` method while processing this
@ -577,7 +577,7 @@ more below.
To complete the future with an exception you need send a Failure message to the sender.
This is *not done automatically* when an actor throws an exception while processing a message.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#reply-exception
.. includecode:: code/docs/actorlambda/ActorDocTest.java#reply-exception
If the actor does not complete the future, it will expire after the timeout period,
specified as parameter to the ``ask`` method; this will complete the
@ -608,7 +608,7 @@ original sender address/reference is maintained even though the message is going
through a 'mediator'. This can be useful when writing actors that work as
routers, load-balancers, replicators etc.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#forward
.. includecode:: code/docs/actorlambda/ActorDocTest.java#forward
Receive messages
================
@ -616,13 +616,13 @@ Receive messages
An Actor either has to set its initial receive behavior in the constructor by
calling the :meth:`receive` method in the :class:`AbstractActor`:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java
.. includecode:: code/docs/actorlambda/ActorDocTest.java
:include: receive-constructor
:exclude: and-some-behavior
or by implementing the :meth:`receive` method in the :class:`Actor` interface:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#receive
.. includecode:: code/docs/actorlambda/ActorDocTest.java#receive
Both the argument to the :class:`AbstractActor` :meth:`receive` method and the return
type of the :class:`Actor` :meth:`receive` method is a ``PartialFunction<Object, BoxedUnit>``
@ -634,7 +634,7 @@ function there is a builder named ``ReceiveBuilder`` that you can use.
Here is an example:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/MyActor.java
.. includecode:: code/docs/actorlambda/MyActor.java
:include: imports,my-actor
.. _LambdaActor.Reply:
@ -649,7 +649,7 @@ for replying later, or passing on to other actors. If there is no sender (a
message was sent without an actor or future context) then the sender
defaults to a 'dead-letter' actor ref.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/MyActor.java#reply
.. includecode:: code/docs/actorlambda/MyActor.java#reply
Receive timeout
@ -667,7 +667,7 @@ timeout there must have been an idle period beforehand as configured via this me
Once set, the receive timeout stays in effect (i.e. continues firing repeatedly after inactivity
periods). Pass in `Duration.Undefined` to switch off this feature.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#receive-timeout
.. includecode:: code/docs/actorlambda/ActorDocTest.java#receive-timeout
.. _stopping-actors-lambda:
@ -704,7 +704,7 @@ whole system.
The :meth:`postStop()` hook is invoked after an actor is fully stopped. This
enables cleaning up of resources:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#postStop
.. includecode:: code/docs/actorlambda/ActorDocTest.java#postStop
:exclude: clean-up-some-resources
.. note::
@ -735,7 +735,7 @@ termination of several actors:
.. includecode:: code/docs/actor/UntypedActorDocTest.java#gracefulStop
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#gracefulStop-actor
.. includecode:: code/docs/actorlambda/ActorDocTest.java#gracefulStop-actor
When ``gracefulStop()`` returns successfully, the actors ``postStop()`` hook
will have been executed: there exists a happens-before edge between the end of
@ -775,7 +775,7 @@ popped.
To hotswap the Actor behavior using ``become``:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#hot-swap-actor
.. includecode:: code/docs/actorlambda/ActorDocTest.java#hot-swap-actor
This variant of the :meth:`become` method is useful for many different things,
such as to implement a Finite State Machine (FSM, for an example see `Dining
@ -791,7 +791,7 @@ of “pop” operations (i.e. :meth:`unbecome`) matches the number of “push”
in the long run, otherwise this amounts to a memory leak (which is why this
behavior is not the default).
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#swapper
.. includecode:: code/docs/actorlambda/ActorDocTest.java#swapper
Stash
@ -816,7 +816,7 @@ order as they have been received originally. An actor that extends
Here is an example of the ``AbstractActorWithStash`` class in action:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/ActorDocTest.java#stash
.. includecode:: code/docs/actorlambda/ActorDocTest.java#stash
Invoking ``stash()`` adds the current message (the message that the
actor received last) to the actor's stash. It is typically invoked
@ -949,7 +949,7 @@ for example in the presence of circular dependencies. In this case the actor sho
and use ``become()`` or a finite state-machine state transition to encode the initialized and uninitialized states
of the actor.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/InitializationDocTest.java#messageInit
.. includecode:: code/docs/actorlambda/InitializationDocTest.java#messageInit
If the actor may receive messages before it has been initialized, a useful tool can be the ``Stash`` to save messages
until the initialization finishes, and replaying them after the actor became initialized.

View file

@ -49,5 +49,5 @@ Step Description
Full Source Code of the Fault Tolerance Sample
------------------------------------------------------
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/japi/FaultHandlingDocSample.java#all
.. includecode:: code/docs/actorlambda/japi/FaultHandlingDocSample.java#all

View file

@ -32,7 +32,7 @@ in more depth.
For the sake of demonstration let us consider the following strategy:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: strategy
I have chosen a few well-known exception types in order to demonstrate the
@ -109,49 +109,49 @@ Test Application
The following section shows the effects of the different directives in practice,
wherefor a test setup is needed. First off, we need a suitable supervisor:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: supervisor
This supervisor will be used to create a child, with which we can experiment:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: child
The test is easier by using the utilities described in :ref:`akka-testkit`,
where ``TestProbe`` provides an actor ref useful for receiving and inspecting replies.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: testkit
Let us create actors:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: create
The first test shall demonstrate the ``Resume`` directive, so we try it out by
setting some non-initial state in the actor and have it fail:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: resume
As you can see the value 42 survives the fault handling directive. Now, if we
change the failure to a more serious ``NullPointerException``, that will no
longer be the case:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: restart
And finally in case of the fatal ``IllegalArgumentException`` the child will be
terminated by the supervisor:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: stop
Up to now the supervisor was completely unaffected by the childs failure,
because the directives set did handle it. In case of an ``Exception``, this is not
true anymore and the supervisor escalates the failure.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: escalate-kill
The supervisor itself is supervised by the top-level actor provided by the
@ -164,12 +164,12 @@ child not to survive this failure.
In case this is not desired (which depends on the use case), we need to use a
different supervisor which overrides this behavior.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: supervisor2
With this parent, the child survives the escalated restart, as demonstrated in
the last test:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/FaultHandlingTest.java
.. includecode:: code/docs/actorlambda/FaultHandlingTest.java
:include: escalate-restart

View file

@ -38,11 +38,11 @@ send them on after the burst ended or a flush request is received.
First, consider all of the below to use these import statements:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java#simple-imports
.. includecode:: code/docs/actorlambda/fsm/Buncher.java#simple-imports
The contract of our “Buncher” actor is that it accepts or produces the following messages:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Events.java
.. includecode:: code/docs/actorlambda/fsm/Events.java
:include: simple-events
:exclude: boilerplate
@ -53,7 +53,7 @@ The contract of our “Buncher” actor is that it accepts or produces the follo
The actor can be in two states: no message queued (aka ``Idle``) or some
message queued (aka ``Active``). The states and the state data is defined like this:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java
.. includecode:: code/docs/actorlambda/fsm/Buncher.java
:include: simple-state
:exclude: boilerplate
@ -64,7 +64,7 @@ reference to send the batches to and the actual queue of messages.
Now lets take a look at the skeleton for our FSM actor:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java
.. includecode:: code/docs/actorlambda/fsm/Buncher.java
:include: simple-fsm
:exclude: transition-elided,unhandled-elided
@ -93,7 +93,7 @@ shall work identically in both states, we make use of the fact that any event
which is not handled by the ``when()`` block is passed to the
``whenUnhandled()`` block:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java#unhandled-elided
.. includecode:: code/docs/actorlambda/fsm/Buncher.java#unhandled-elided
The first case handled here is adding ``Queue()`` requests to the internal
queue and going to the ``Active`` state (this does the obvious thing of staying
@ -107,7 +107,7 @@ target, for which we use the ``onTransition`` mechanism: you can declare
multiple such blocks and all of them will be tried for matching behavior in
case a state transition occurs (i.e. only when the state actually changes).
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java#transition-elided
.. includecode:: code/docs/actorlambda/fsm/Buncher.java#transition-elided
The transition callback is a partial function which takes as input a pair of
states—the current and the next state. During the state change, the old state
@ -117,7 +117,7 @@ available as ``nextStateData``.
To verify that this buncher actually works, it is quite easy to write a test
using the :ref:`akka-testkit`, here using JUnit as an example:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/BuncherTest.java
.. includecode:: code/docs/actorlambda/fsm/BuncherTest.java
:include: test-code
Reference
@ -129,7 +129,7 @@ The AbstractFSM Class
The :class:`AbstractFSM` abstract class is the base class used to implement an FSM. It implements
Actor since an Actor is created to drive the FSM.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java
.. includecode:: code/docs/actorlambda/fsm/Buncher.java
:include: simple-fsm
:exclude: fsm-body
@ -181,7 +181,7 @@ The :meth:`stateFunction` argument is a :class:`PartialFunction[Event, State]`,
which is conveniently given using the state function builder syntax as
demonstrated below:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/Buncher.java
.. includecode:: code/docs/actorlambda/fsm/Buncher.java
:include: when-syntax
.. warning::
@ -193,7 +193,7 @@ It is recommended practice to declare the states as an enum and then verify that
``when`` clause for each of the states. If you want to leave the handling of a state
“unhandled” (more below), it still needs to be declared like this:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java#NullFunction
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java#NullFunction
Defining the Initial State
--------------------------
@ -213,7 +213,7 @@ If a state doesn't handle a received event a warning is logged. If you want to
do something else in this case you can specify that with
:func:`whenUnhandled(stateFunction)`:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: unhandled-syntax
Within this handler the state of the FSM may be queried using the
@ -257,7 +257,7 @@ of the modifiers described in the following:
All modifiers can be chained to achieve a nice and concise description:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: modifier-syntax
The parentheses are not actually needed in all cases, but they visually
@ -294,14 +294,14 @@ The handler is a partial function which takes a pair of states as input; no
resulting state is needed as it is not possible to modify the transition in
progress.
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: transition-syntax
It is also possible to pass a function object accepting two states to
:func:`onTransition`, in case your transition handling logic is implemented as
a method:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: alt-transition-syntax
The handlers registered with this method are stacked, so you can intersperse
@ -377,14 +377,14 @@ state data which is available during termination handling.
the same way as a state transition (but note that the ``return`` statement
may not be used within a :meth:`when` block).
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: stop-syntax
You can use :func:`onTermination(handler)` to specify custom code that is
executed when the FSM is stopped. The handler is a partial function which takes
a :class:`StopEvent(reason, stateName, stateData)` as argument:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: termination-syntax
As for the :func:`whenUnhandled` case, this handler is not stacked, so each
@ -418,7 +418,7 @@ Event Tracing
The setting ``akka.actor.debug.fsm`` in :ref:`configuration` enables logging of an
event trace by :class:`LoggingFSM` instances:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: logging-fsm
:exclude: body-elided
@ -439,7 +439,7 @@ The :class:`AbstractLoggingFSM` class adds one more feature to the FSM: a rollin
log which may be used during debugging (for tracing how the FSM entered a
certain failure state) or for other creative uses:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/actor/fsm/FSMDocTest.java
.. includecode:: code/docs/actorlambda/fsm/FSMDocTest.java
:include: logging-fsm
The :meth:`logDepth` defaults to zero, which turns off the event log.

View file

@ -4,13 +4,13 @@
package docs.io
import java.net.{InetAddress, InetSocketAddress, NetworkInterface, StandardProtocolFamily}
import java.net.{ InetAddress, InetSocketAddress, NetworkInterface, StandardProtocolFamily }
import java.net.DatagramSocket
import java.nio.channels.DatagramChannel
import akka.actor.{Actor, ActorLogging, ActorRef}
import akka.io.Inet.{DatagramChannelCreator, SocketOption, SocketOptionV2}
import akka.io.{IO, Udp}
import akka.actor.{ Actor, ActorLogging, ActorRef }
import akka.io.Inet.{ DatagramChannelCreator, SocketOption, SocketOptionV2 }
import akka.io.{ IO, Udp }
import akka.util.ByteString
//#inet6-protocol-family

View file

@ -4,14 +4,14 @@
package docs.io
import java.net.{Inet6Address, InetSocketAddress, NetworkInterface, StandardProtocolFamily}
import java.net.{ Inet6Address, InetSocketAddress, NetworkInterface, StandardProtocolFamily }
import java.nio.channels.DatagramChannel
import scala.util.Random
import akka.actor.{ActorSystem, Props}
import akka.actor.{ ActorSystem, Props }
import akka.io.Udp
import akka.testkit.TestKit
import org.scalatest.{BeforeAndAfter, WordSpecLike}
import org.scalatest.{ BeforeAndAfter, WordSpecLike }
import scala.collection.JavaConversions.enumerationAsScalaIterator
@ -42,7 +42,7 @@ class ScalaUdpMulticastSpec extends TestKit(ActorSystem("ScalaUdpMulticastSpec")
}
}
def afterAll = {
def afterAll(): Unit = {
TestKit.shutdownActorSystem(system)
}

View file

@ -95,12 +95,12 @@ To select a Protocol Family you must extend ``akka.io.Inet.DatagramChannelCreato
class which extends ``akka.io.Inet.SocketOption``. Provide custom logic
for opening a datagram channel by overriding :meth:`create` method.
.. includecode:: ../../../akka-samples/akka-docs-udp-multicast/src/main/scala/ScalaUdpMulticast.scala#inet6-protocol-family
.. includecode:: code/docs/io/ScalaUdpMulticast.scala#inet6-protocol-family
Another socket option will be needed to join a multicast group.
.. includecode:: ../../../akka-samples/akka-docs-udp-multicast/src/main/scala/ScalaUdpMulticast.scala#multicast-group
.. includecode:: code/docs/io/ScalaUdpMulticast.scala#multicast-group
Socket options must be provided to :class:`UdpMessage.Bind` message.
.. includecode:: ../../../akka-samples/akka-docs-udp-multicast/src/main/scala/ScalaUdpMulticast.scala#bind
.. includecode:: code/docs/io/ScalaUdpMulticast.scala#bind

View file

@ -1,17 +0,0 @@
name := "akka-docs-java-lambda"
version := "2.4-SNAPSHOT"
scalaVersion := "2.11.5"
compileOrder := CompileOrder.ScalaThenJava
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT",
"com.typesafe.akka" %% "akka-testkit" % "2.4-SNAPSHOT" % "test",
"junit" % "junit" % "4.11" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test")

View file

@ -1,53 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>sample</groupId>
<artifactId>akka-docs-java-lambda</artifactId>
<packaging>jar</packaging>
<version>2.4-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.11</artifactId>
<version>2.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -1 +0,0 @@
sbt.version=0.13.7

View file

@ -1,19 +0,0 @@
name := "akka-docs-udp-multicast"
version := "2.4-SNAPSHOT"
scalaVersion := "2.11.5"
compileOrder := CompileOrder.ScalaThenJava
javacOptions ++= Seq("-source", "1.7", "-target", "1.7", "-Xlint")
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT",
"com.typesafe.akka" %% "akka-testkit" % "2.4-SNAPSHOT",
"org.scalatest" %% "scalatest" % "2.2.1" % "test",
"junit" % "junit" % "4.11" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)

View file

@ -1 +0,0 @@
sbt.version=0.13.7

View file

@ -10,9 +10,9 @@ val project = Project(
name := "akka-sample-cluster-java",
version := "2.4-SNAPSHOT",
scalaVersion := "2.11.5",
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
javacOptions in Compile ++= Seq("-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-Xlint:deprecation"),
javacOptions in doc in Compile := Seq("-source", "1.6"), // javadoc does not support -target and -Xlint flags
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.8", "-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
javacOptions in Compile ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-Xlint:deprecation"),
javacOptions in doc in Compile := Seq("-source", "1.8", "-Xdoclint:none"),
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-remote" % akkaVersion,

View file

@ -10,8 +10,8 @@ val project = Project(
name := "akka-sample-cluster-scala",
version := "2.4-SNAPSHOT",
scalaVersion := "2.11.5",
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
javacOptions in Compile ++= Seq("-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-Xlint:deprecation"),
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.8", "-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
javacOptions in Compile ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-Xlint:deprecation"),
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-remote" % akkaVersion,

View file

@ -2,9 +2,11 @@ name := "akka-docs-java-lambda"
version := "2.4-SNAPSHOT"
scalaVersion := "2.11.5"
scalaVersion := "2.11.6"
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint")
javacOptions in doc ++= Seq("-encoding", "UTF-8", "-source", "1.8")
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a")

View file

@ -4,7 +4,9 @@ version := "1.0"
scalaVersion := "2.11.5"
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint")
javacOptions in doc ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-Xdoclint:none")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-persistence-experimental" % "2.4-SNAPSHOT"

View file

@ -4,7 +4,9 @@ version := "1.0"
scalaVersion := "2.11.5"
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint")
javacOptions in doc ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-Xdoclint:none")
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a")

View file

@ -332,7 +332,7 @@ public class JavaTestKit {
*
* <pre>
* <code>
* final String out = new ExpectMsg<String>("match hint") {
* final String out = new ExpectMsg&lt;String&gt;("match hint") {
* protected String match(Object in) {
* if (in instanceof Integer)
* return "match";

View file

@ -203,9 +203,10 @@ object AkkaBuild extends Build {
settings = parentSettings ++ ActivatorDist.settings,
// FIXME osgiDiningHakkersSampleMavenTest temporarily removed from aggregate due to #16703
aggregate = if (!CommandLineOptions.aggregateSamples) Nil else
Seq(sampleCamelJava, sampleCamelScala, sampleClusterJava, sampleClusterScala, sampleFsmScala,
sampleMainJava, sampleMainScala, sampleMultiNodeScala,
samplePersistenceJava, samplePersistenceScala, sampleRemoteJava, sampleRemoteScala)
Seq(sampleCamelJava, sampleCamelScala, sampleClusterJava, sampleClusterScala, sampleFsmScala, sampleFsmJavaLambda,
sampleMainJava, sampleMainScala, sampleMainJavaLambda, sampleMultiNodeScala,
samplePersistenceJava, samplePersistenceScala, samplePersistenceJavaLambda,
sampleRemoteJava, sampleRemoteScala, sampleSupervisionJavaLambda)
)
lazy val sampleCamelJava = Sample.project("akka-sample-camel-java")
@ -215,17 +216,22 @@ object AkkaBuild extends Build {
lazy val sampleClusterScala = Sample.project("akka-sample-cluster-scala")
lazy val sampleFsmScala = Sample.project("akka-sample-fsm-scala")
lazy val sampleFsmJavaLambda = Sample.project("akka-sample-fsm-java-lambda")
lazy val sampleMainJava = Sample.project("akka-sample-main-java")
lazy val sampleMainScala = Sample.project("akka-sample-main-scala")
lazy val sampleMainJavaLambda = Sample.project("akka-sample-main-java-lambda")
lazy val sampleMultiNodeScala = Sample.project("akka-sample-multi-node-scala")
lazy val samplePersistenceJava = Sample.project("akka-sample-persistence-java")
lazy val samplePersistenceScala = Sample.project("akka-sample-persistence-scala")
lazy val samplePersistenceJavaLambda = Sample.project("akka-sample-persistence-java-lambda")
lazy val sampleRemoteJava = Sample.project("akka-sample-remote-java")
lazy val sampleRemoteScala = Sample.project("akka-sample-remote-scala")
lazy val sampleSupervisionJavaLambda = Sample.project("akka-sample-supervision-java-lambda")
lazy val osgiDiningHakkersSampleMavenTest = Project(id = "akka-sample-osgi-dining-hakkers-maven-test",
base = file("akka-samples/akka-sample-osgi-dining-hakkers-maven-test"),
@ -305,13 +311,13 @@ object AkkaBuild extends Build {
lazy val defaultSettings = baseSettings ++ resolverSettings ++ TestExtras.Filter.settings ++
Protobuf.settings ++ Seq(
// compile options
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.8", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
scalacOptions in Compile ++= (if (allWarnings) Seq("-deprecation") else Nil),
scalacOptions in Test := (scalacOptions in Test).value.filterNot(_ == "-Xlog-reflective-calls"),
// -XDignore.symbol.file suppresses sun.misc.Unsafe warnings
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-XDignore.symbol.file"),
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8", "-Xlint:unchecked", "-XDignore.symbol.file"),
javacOptions in compile ++= (if (allWarnings) Seq("-Xlint:deprecation") else Nil),
javacOptions in doc ++= Seq("-encoding", "UTF-8", "-source", "1.6"),
javacOptions in doc ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-Xdoclint:none"),
incOptions := incOptions.value.withNameHashing(true),
crossVersion := CrossVersion.binary,

View file

@ -1,136 +0,0 @@
#!/usr/bin/env bash
# defaults
declare -r default_java_home="/usr/local/share/java/jdk6"
declare -r default_java8_home="/usr/local/share/java/jdk8"
declare -r default_sbt_jar="/usr/share/sbt-launcher-packaging/bin/sbt-launch.jar"
declare -r default_ivy_home="~/.ivy2"
# get the source location for this script; handles symlinks
function get_script_path {
local source="${BASH_SOURCE[0]}"
while [ -h "${source}" ] ; do
source="$(readlink "${source}")";
done
echo ${source}
}
# path, name, and dir for this script
declare -r script_path=$(get_script_path)
declare -r script_name=$(basename "${script_path}")
declare -r script_dir="$(cd -P "$(dirname "${script_path}")" && pwd)"
# print usage info
function usage {
cat <<EOM
Usage: ${script_name} [options] VERSION
-h | --help Print this usage message
--java_home PATH Set the path to the "standard" java version
--java8_home PATH Set the path to the java 8 version
This script assumes that the mvn command is in your path.
EOM
}
# echo a log message
function echolog {
echo "[${script_name}] $@"
}
# echo an error message
function echoerr {
echo "[${script_name}] $@" 1>&2
}
# fail the script with an error message
function fail {
echoerr "$@"
exit 1
}
# try to run a command or otherwise fail with a message
function try {
"${@:1:$#-1}" || fail "${@:$#}"
}
# try to run a command or otherwise fail
function check {
type -P "$@" &> /dev/null || fail "command not found: $@"
}
# run mvn clean test using the specified java home in the specified directory
function mvncleantest {
tmp="$script_dir/../../$2"
try cd "$tmp" "can't step into project directory: $tmp"
export JAVA_HOME="$1"
try mvn clean test "mvn execution in $2 failed"
}
# run sbt clean test using the specified java home in the specified directory
function sbtcleantest {
tmp="$script_dir/../../$2"
try cd "$tmp" "can't step into project directory: $tmp"
orig_path="$PATH"
export PATH="$1/bin:$PATH"
try java -jar $sbt_jar -Dsbt.ivy.home=$ivy_home clean test "sbt execution in $2 failed"
export PATH="$orig_path"
}
# initialize variables with defaults and override from environment
declare java_home="$default_java_home"
if [ $AKKA_BUILD_JAVA_HOME ]; then
java_home="$AKKA_BUILD_JAVA_HOME"
fi
declare java8_home="$default_java8_home"
if [ $AKKA_BUILD_JAVA8_HOME ]; then
java8_home="$AKKA_BUILD_JAVA8_HOME"
fi
declare sbt_jar="$default_sbt_jar"
if [ $AKKA_BUILD_SBT_JAR ]; then
sbt_jar="$AKKA_BUILD_SBT_JAR"
fi
declare ivy_home="$default_ivy_home"
if [ $AKKA_BUILD_IVY_HOME ]; then
ivy_home="$AKKA_BUILD_IVY_HOME"
fi
# process options and set flags
while true; do
case "$1" in
-h | --help ) usage; exit 1 ;;
--java_home ) java_home=$2; shift 2 ;;
--java8_home ) java8_home=$2; shift 2 ;;
* ) break ;;
esac
done
declare -r java_path="$java_home/bin/java"
declare -r java8_path="$java8_home/bin/java"
# check that java paths work
check "$java_path"
check "$java8_path"
# check for a mvn command
check mvn
# now do some work
mvncleantest "$java8_home" "akka-samples/akka-docs-java-lambda"
mvncleantest "$java8_home" "akka-samples/akka-sample-fsm-java-lambda"
mvncleantest "$java8_home" "akka-samples/akka-sample-persistence-java-lambda"
mvncleantest "$java8_home" "akka-samples/akka-sample-supervision-java-lambda"
sample_dir=akka-samples/akka-sample-main-java-lambda
tmp="$script_dir/../../$sample_dir"
try cd "$tmp" "can't step into project directory: $tmp"
export JAVA_HOME="$java8_home"
try mvn clean compile exec:java -Dexec.mainClass="akka.Main" -Dexec.args="sample.hello.HelloWorld" "mvn execution in $sample_dir failed"
try mvn exec:java -Dexec.mainClass="sample.hello.Main2" "mvn execution in $sample_dir failed"
sbtcleantest "$java8_home" "akka-samples/akka-docs-udp-multicast"