|
Akka/Scala example source code file (SampleActor.java)
The SampleActor.java Akka example source code/** * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package docs.actor; //#sample-actor import akka.actor.AbstractActor; import akka.japi.pf.ReceiveBuilder; import scala.PartialFunction; import scala.runtime.BoxedUnit; public class SampleActor extends AbstractActor { private PartialFunction<Object, BoxedUnit> guarded = ReceiveBuilder. match(String.class, s -> s.contains("guard"), s -> { sender().tell("contains(guard): " + s, self()); context().unbecome(); }).build(); public SampleActor() { receive(ReceiveBuilder. match(Double.class, d -> { sender().tell(d.isNaN() ? 0 : d, self()); }). match(Integer.class, i -> { sender().tell(i * 10, self()); }). match(String.class, s -> s.startsWith("guard"), s -> { sender().tell("startsWith(guard): " + s.toUpperCase(), self()); context().become(guarded, false); }).build() ); } } //#sample-actor Other Akka source code examplesHere is a short list of links related to this Akka SampleActor.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.