@Override public Address address() { return this.actor.address(); }
if (actor.wantsFilteredDelivery()) { Object answer = this.dispatch(actor, message, asking); actor.execute((Command) message); } else if (message instanceof Event) { actor.handle((Event) message); } else { if (asking) { stores = false; // by convention, asking does not modify the actor Object answer = actor.answer(message); local.senderAgent().tell(new FutureValueMessage(answer)); } else { actor.reactTo(message);
/** * @see co.vaughnvernon.actormodel.actor.ActorFinder#findActorAgentBy(java.lang.Class, co.vaughnvernon.actormodel.actor.Query) */ @Override public ActorAgent findFirstMatching( Class<? extends Actor> anActorType, Query aQuery) { ActorKeyValueTypeElement typeElement = this.typeElementFor(anActorType); for (Actor actor : typeElement.store().values()) { if (actor.matches(aQuery)) { ActorAgent actorAgent = this.actorAgentFactory() .newActorAgentFor(this, anActorType, actor, typeElement.mailbox()); return actorAgent; } } return null; }
/** * Stores anActor in my cache according to its type, anActorType. * @param anActorType the Class<? extends Actor> of the concrete Actor type * @param anActor the Actor instance to store */ protected void storeActor(Class<? extends Actor> anActorType, Actor anActor) { ActorKeyValueTypeElement typeElement = this.typeElementFor(anActorType); typeElement.store().put(anActor.address().address(), anActor); }