2010-10-26 12:49:25 +02:00
|
|
|
package akka.config;
|
2010-10-18 19:30:43 +02:00
|
|
|
|
2010-10-26 12:49:25 +02:00
|
|
|
import akka.actor.*;
|
2010-10-18 19:30:43 +02:00
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2010-10-19 14:17:22 +02:00
|
|
|
import java.util.Arrays;
|
2010-10-18 19:30:43 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2010-10-26 12:49:25 +02:00
|
|
|
import static akka.config.Supervision.*;
|
2010-10-18 19:30:43 +02:00
|
|
|
|
|
|
|
|
public class SupervisionConfig {
|
|
|
|
|
/*Just some sample code to demonstrate the declarative supervision configuration for Java */
|
|
|
|
|
public SupervisorConfig createSupervisorConfig(List<ActorRef> toSupervise) {
|
|
|
|
|
ArrayList<Server> targets = new ArrayList<Server>(toSupervise.size());
|
|
|
|
|
for(ActorRef ref : toSupervise) {
|
|
|
|
|
targets.add(new Supervise(ref, permanent(), new RemoteAddress("localhost",9999)));
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-21 19:19:40 +02:00
|
|
|
return new SupervisorConfig(new AllForOneStrategy(new Class[] { Exception.class },50,1000), targets.toArray(new Server[0]));
|
2010-10-18 19:30:43 +02:00
|
|
|
}
|
|
|
|
|
}
|