import swarm.Selector;
3 {& X& ^$ H9 {: r* b& e' O
" b: s; k' N4 p4 [8 \public class SwarmUtils {
* x0 z% f( M( V# C0 e( g) N: W; m public static Selector getSelector(String name, String method) {
$ ~, N$ ~7 x5 s" G# T Selector sel;& T* R4 ?* w4 j/ S2 m
try {
# C" c. K/ i" s6 {7 N' O' M sel = new Selector(Class.forName(name), method, false);2 N8 L/ J8 y$ h1 K) \$ v7 `- _
} catch (Exception e) {
+ v/ m5 e4 @' m% _0 I9 R System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 Q0 f; @- j0 h4 C9 J9 I System.err.println(name + "." + method + " returns " + e.getMessage());
8 M9 x! G+ }7 [" b System.err.println("The process will be terminated.");# `* f5 D, o* i* N3 S+ u* X. F$ j
System.exit(1);
0 G- K n0 Y% k( w; c return null;
9 T/ |" V( r/ H% O# e- p& t }7 Y( W8 \ u+ o; ^, g, b, v, `
return sel;
# F v1 s- p4 { }# ?( h: n5 I' B
9 S# n/ O4 A+ ^
public static Selector getSelector(Object obj, String method) {
' M6 i2 V0 {6 X9 H# B Y. l' y6 n( V Selector sel;: R1 Q8 f# y0 o0 B2 V/ R
try {8 U5 B# J4 j% I( ?
sel = new Selector(obj.getClass(), method, false);& c- \ M/ i, O1 Z: C* j
} catch (Exception e) {; `1 n4 ~! J" T' E {9 u
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ F7 a* E, v8 o2 @
+ (obj.getClass()).getName() + ".");
1 @% K- q/ @4 P: I2 h System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());& h, |' p' E6 ]0 v3 @- P; g/ F
System.err.println("The process will be terminated.");' p, B+ M+ I. h6 L
System.exit(1);) H% N' o" }: |; r
return null;/ |# |% m% _9 N5 D; h, O- w
}0 Y( B+ Y1 W' r1 `
return sel;
5 y9 J, e5 w' F, p }, w# z' p7 g- r$ |9 a4 E
} |