import swarm.Selector;
3 i& k! ?! N" P: z* Q5 X1 x, Z5 o& x) Z. ?0 x
public class SwarmUtils {. V7 z: B0 y8 C& t: y8 @3 m
public static Selector getSelector(String name, String method) {
0 e" ?2 L8 l; `0 K% A Selector sel;8 I: [% X y$ h }, I
try {5 p5 ~1 g* j9 V1 @7 q! p5 }
sel = new Selector(Class.forName(name), method, false);
( x2 }2 W9 \& b4 I' p } catch (Exception e) {
, s8 m7 S$ K1 h/ \$ c System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
# C# p7 P F4 U4 ] System.err.println(name + "." + method + " returns " + e.getMessage());4 |7 E {) H7 i8 l7 }( U
System.err.println("The process will be terminated.");8 f! S% S3 v' e+ G9 u; N
System.exit(1);
G" ]% ~1 i. _- Y" r return null;7 W3 @8 x4 M+ k3 l7 t& [" Z7 z% I
}
( p2 p# j8 g9 [$ Y- R7 c return sel;
1 T# _1 J3 H$ x; P }2 x; H8 [, `) B" {
9 w; o/ N- Y# Q6 f% O- r public static Selector getSelector(Object obj, String method) {
9 Y& r0 ]0 n5 ^) `- l) u. s" [ Selector sel;
, G2 E8 N9 e/ k6 c. f try {
) ^" u& {0 y! {1 E$ _, j sel = new Selector(obj.getClass(), method, false);
- {; [0 f+ f1 a# w0 z. @ } catch (Exception e) {4 r' D. B5 S3 N
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "" i" Z8 d( ?3 W8 {2 |8 v
+ (obj.getClass()).getName() + ".");
; B4 H) R3 b$ G1 }, _* j: G System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());2 `; @! R1 u* ~- R$ g, o
System.err.println("The process will be terminated.");+ E7 r8 m; }3 a+ p7 H \0 x: }
System.exit(1);! ^4 {! c$ e) e! R a6 A' U
return null;
) q& G6 o R- F4 z, t$ P. g }
& r% d0 ?1 C4 k) _ return sel;
% p4 j" j( A$ |' \5 [, A }
- q O( x# x; ? i} |