Skip to content

Commit

Permalink
new GetActorFactory request
Browse files Browse the repository at this point in the history
  • Loading branch information
laforge49 committed Mar 26, 2012
1 parent e271834 commit a360cc8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/org/agilewiki/jactor/components/factory/Factory.java
Expand Up @@ -75,6 +75,24 @@ public void initializationProcessRequest(Internals internals, DefineActorType de
}
});

thisActor.bind(
GetActorFactory.class.getName(),
new ConcurrentMethodBinding<GetActorFactory, ActorFactory>() {
@Override
public ActorFactory concurrentProcessRequest(RequestReceiver requestReceiver,
GetActorFactory request)
throws Exception {
String actorType = request.getActorType();
ActorFactory af = types.get(actorType);
if (af == null) {
if (parentHasSameComponent())
return request.call(requestReceiver.getParent());
throw new IllegalArgumentException("Unknown actor type: " + actorType);
}
return af;
}
});

thisActor.bind(
NewActor.class.getName(),
new ConcurrentMethodBinding<NewActor, Actor>() {
Expand Down
@@ -0,0 +1,31 @@
package org.agilewiki.jactor.components.factory;

import org.agilewiki.jactor.bind.JBConcurrentRequest;

/**
* Returns the actor factory assigned to a given actor type.
*/
public class GetActorFactory extends JBConcurrentRequest<ActorFactory> {
/**
* An actor type name.
*/
private String actorType;

/**
* Create a request.
*
* @param actorType An actor type name.
*/
public GetActorFactory(String actorType) {
this.actorType = actorType;
}

/**
* Returns an actor type name.
*
* @return An actor type name.
*/
public String getActorType() {
return actorType;
}
}

0 comments on commit a360cc8

Please sign in to comment.