import swarm.Selector;- A7 n' J0 Q: s8 c1 t A4 u
O# o, f! _2 _9 Cpublic class SwarmUtils {6 {5 X# V- I' f- }3 Z* n2 O/ q
public static Selector getSelector(String name, String method) {! K2 H+ n o: j8 t. a
Selector sel;
" {: Z6 _) h+ x0 k9 a" ] try {
3 ~ Y5 y1 x3 @% A# K3 Q sel = new Selector(Class.forName(name), method, false);( \/ q0 P) U1 h) O3 G8 @
} catch (Exception e) {
( Y, q, ?* r8 B8 b! b: E System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");5 J4 y( v( Q' R! ?
System.err.println(name + "." + method + " returns " + e.getMessage());( ?# N3 E) ], j' V
System.err.println("The process will be terminated.");, d- b# c6 W) J5 y) k; ]
System.exit(1);8 [8 M: I# U# x1 X+ |- v
return null;2 s; b* c: v8 o6 |
}
' x9 j; h( w( Y return sel;
, e9 c h5 U; I% P }
- L5 W! o9 K% M' n) u$ [7 U
4 h4 \0 w/ C( G" j$ Z2 p |& ^1 F public static Selector getSelector(Object obj, String method) {1 @" _) c. {3 `+ F
Selector sel;
: D) q/ ^0 o* e# l2 R( J3 u4 \" C try {0 q& W6 @8 P Q. T0 i4 ? Q7 g! Y' u
sel = new Selector(obj.getClass(), method, false);4 `- g3 f1 w) d/ u
} catch (Exception e) {# E+ S$ ]1 r# e) u9 H! p# ~
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "" p7 }" T2 l- H) V
+ (obj.getClass()).getName() + ".");- J d! s- ?/ v" T5 V" T
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 ]# d5 U& h2 T; W
System.err.println("The process will be terminated.");0 X0 K1 A4 q. O+ C
System.exit(1);- b4 ? b4 L0 V& w% N
return null;$ Z( { j1 N4 M8 m/ `3 t
}3 ?+ O' ]2 _; | L! z! [8 ]5 n+ Z( J
return sel;
0 U1 t, J7 J: H% b: q/ N% S }
. S" h, ^2 K+ W( Q} |