package akka.actor; import akka.japi.Creator; import akka.remoteinterface.RemoteSupport; /** * JAVA API for * - creating actors, * - creating remote actors, * - locating actors */ public class Actors { /** * * @return The actor registry */ public static ActorRegistry registry() { return Actor$.MODULE$.registry(); } /** * * @return * @throws UnsupportedOperationException If remoting isn't configured * @throws ModuleNotAvailableException If the class for the remote support cannot be loaded */ public static RemoteSupport remote() { return Actor$.MODULE$.remote(); } /** * NOTE: Use this convenience method with care, do NOT make it possible to get a reference to the * UntypedActor instance directly, but only through its 'ActorRef' wrapper reference. *
* Creates an ActorRef out of the Actor. Allows you to pass in the instance for the UntypedActor. * Only use this method when you need to pass in constructor arguments into the 'UntypedActor'. * * You use it by implementing the UntypedActorFactory interface. * Example in Java: ** ActorRef actor = Actors.actorOf(new UntypedActorFactory() { * public UntypedActor create() { * return new MyUntypedActor("service:name", 5); * } * }); * actor.start(); * actor.sendOneWay(message, context); * actor.stop(); **/ public static ActorRef actorOf(final Creator
* ActorRef actor = Actors.actorOf(MyUntypedActor.class); * actor.start(); * actor.sendOneWay(message, context); * actor.stop(); ** You can create and start the actor in one statement like this: *
* val actor = Actors.actorOf(MyActor.class).start(); **/ public static ActorRef actorOf(final Class extends Actor> type) { return Actor$.MODULE$.actorOf(type); } /** * The message that is sent when an Actor gets a receive timeout. *
* if( message == receiveTimeout() ) { * //Timed out * } ** @return the single instance of ReceiveTimeout */ public final static ReceiveTimeout$ receiveTimeout() { return ReceiveTimeout$.MODULE$; } /** * The message that when sent to an Actor kills it by throwing an exception. *
* actor.sendOneWay(kill()); ** @return the single instance of Kill */ public final static Kill$ kill() { return Kill$.MODULE$; } /** * The message that when sent to an Actor shuts it down by calling 'stop'. *
* actor.sendOneWay(poisonPill()); ** @return the single instance of PoisonPill */ public final static PoisonPill$ poisonPill() { return PoisonPill$.MODULE$; } }