import swarm.Selector;, Q9 }; V3 y* ^5 B+ C
- c7 A I( j) A. k5 [1 kpublic class SwarmUtils {, C& f1 a6 O/ z* ~4 d1 H
public static Selector getSelector(String name, String method) {& f& i3 w- |1 F2 I3 h- |
Selector sel;! `9 e& [8 z5 ^& {5 T" G7 I
try {0 U: x" K3 j2 B
sel = new Selector(Class.forName(name), method, false);3 l) d( W0 K' \' V+ i* E* C0 W7 f
} catch (Exception e) {% P8 M- B+ t- w+ J4 U- k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: a9 n1 H- t: J System.err.println(name + "." + method + " returns " + e.getMessage());; t# M/ v q% M
System.err.println("The process will be terminated.");; d8 n- }/ j! P" Z
System.exit(1);
) r: u5 C9 ^+ W6 L$ W0 l return null;! E; f. L* g1 A) \- e
}
5 _8 q& p4 M3 r1 S- z' D& j+ E- ~ return sel;! U' a2 K2 m/ i! i( {6 V j
}9 _* X0 C; h; Y) _/ i
9 C8 z. L6 d6 L' I
public static Selector getSelector(Object obj, String method) {2 X. y4 z7 F* V3 `% b
Selector sel;
) x; \; u1 E: g! D" z4 b try {
+ h5 t9 Z, F+ B7 a! a* N) T sel = new Selector(obj.getClass(), method, false);
; K b6 z G% P3 C: E/ } } catch (Exception e) {
6 ^( i. u. h5 n8 t2 D System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 V% J S. K0 _
+ (obj.getClass()).getName() + ".");$ g2 `. R# q0 I2 M) N
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
% s& O9 m5 o" f) ^: k0 U( p; ?0 y System.err.println("The process will be terminated.");( w! [0 r: {3 t7 e2 L$ ]
System.exit(1);
, a+ L9 P2 f' Q% I% l9 n% L return null;) |* u) Y% K D5 r- c7 D
}; g* c6 [" S9 I U3 Q
return sel;
1 P- ]% E- d$ T$ m l5 H }
4 F2 @: G9 |* U& s( X/ f9 _} |