import swarm.Selector;
4 {/ e* m; M* W9 E
E+ ?+ f, b" S$ Y+ D' tpublic class SwarmUtils {
2 I0 _6 `" h- S2 h7 `9 k$ c public static Selector getSelector(String name, String method) {% u$ b( s# {8 v
Selector sel;7 b, }) @7 C3 Q0 x" f* ?8 n, n
try {
5 Q1 ^9 j0 S! N8 J sel = new Selector(Class.forName(name), method, false);9 T# X( @" g1 Q3 s4 ]; ]6 a
} catch (Exception e) {
0 \# m& A8 M8 c System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");: l: A3 S- G& Z8 T5 F3 n& E4 m* c" A
System.err.println(name + "." + method + " returns " + e.getMessage());3 R5 x- N% q) w$ M
System.err.println("The process will be terminated.");% T& Q$ ^' E/ z, ]/ H
System.exit(1);; [# a5 K; R5 @( X% ~* |
return null;
+ i/ {- z6 h' P9 y3 [" `! l }1 S6 e5 T2 l+ T G1 M: ^( d k
return sel;
2 K* f4 F& R8 j* ?& R* _! B: M }$ c; y$ m; T4 |' b, I" g! w
& F' ~: V: [ b' m0 @% f# X public static Selector getSelector(Object obj, String method) {
, B8 \9 N1 x8 \& Z) K Selector sel;& e, b+ {* J7 w* ?1 n) z& j! b, q O: u6 H
try {! Z: k$ d! |7 V+ g$ F
sel = new Selector(obj.getClass(), method, false);
W0 \6 i) R% | } catch (Exception e) { D* | H6 n1 w" B; [
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 Z% j. c9 o9 G& A + (obj.getClass()).getName() + ".");
, R9 d# P! d, z: _: E5 v System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());+ J, ]1 x1 j' z! d: U4 I
System.err.println("The process will be terminated.");
. M/ y4 L# k6 u# i System.exit(1);! d: h% f* g4 v) l, g5 I
return null;; H7 s) l. N9 e2 S7 {6 E( q
}2 ] v# \ V$ a( a b1 M
return sel;
6 [( ?/ N1 A/ g$ ~7 X2 v5 Z" v }
I+ ~/ k8 Z7 Y9 r$ q/ ]* a, l} |