import swarm.Selector;& _/ p3 k- G& ?' U# V: ?- ?* ~
$ X9 X7 s! u2 l5 i: Z2 cpublic class SwarmUtils {: N7 q: K* S" Q ? P
public static Selector getSelector(String name, String method) {8 M% z( d1 @( A" W( v8 w
Selector sel;1 L; @9 ?& o/ l2 K/ T3 ~
try {3 {0 K" T U+ e6 b! H" ?; P
sel = new Selector(Class.forName(name), method, false);. q6 i0 n5 E/ R
} catch (Exception e) {
- M& v3 Z0 z4 J3 I9 N System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
+ z+ j Z8 g$ `6 M System.err.println(name + "." + method + " returns " + e.getMessage());
. V6 \. ?8 X9 E4 t- D& I6 v System.err.println("The process will be terminated.");
+ i2 K' z9 X5 q+ _ System.exit(1);
1 S: P8 ^2 d- ~ return null;6 N. z+ u/ c' w
}6 V8 C1 M' @, K8 w
return sel;
/ _7 t% z1 I2 G9 ` }
/ V* h3 Z( i2 m# Z) c8 x6 }9 t/ j
8 v N- C8 j- J; D$ v7 {/ D% D- J public static Selector getSelector(Object obj, String method) {# l0 R1 E7 W0 D- Q# M
Selector sel;
% c$ ~7 H0 y) n8 C try {* G# x0 G- B1 ~- S6 S% V
sel = new Selector(obj.getClass(), method, false);$ @6 }% K+ E& X, _# Q7 h
} catch (Exception e) {" I1 t2 D7 B) t( n( ]
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 J( |! f' b: V! v# U/ {7 B + (obj.getClass()).getName() + ".");! y/ {( \) l- f5 ~2 p7 r6 b" V
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());2 q3 J+ ?. {9 A9 N
System.err.println("The process will be terminated.");
, j9 f0 a; n# G' t8 z System.exit(1);. ^1 Z. d3 O5 ~
return null;
; I7 f- t2 [3 g- X( h0 Y V6 h }' }, ~0 Z! h, V' I5 T9 g4 j6 r" B
return sel;. F& Z4 s0 B: I9 C
}. q! _% ? z t k
} |