import swarm.Selector;& [$ v8 [( e" l* X) a& Y8 d
+ B- o" h- W" y- F/ spublic class SwarmUtils {
; B' ^! F$ `+ C( a! F7 v; M2 } public static Selector getSelector(String name, String method) {* `/ u7 M7 v0 @5 S3 P4 J# b* s/ `
Selector sel;
' n1 o' s9 E# n3 t7 r* a0 g try { h$ b& I+ ^5 n0 V8 E! u% t
sel = new Selector(Class.forName(name), method, false);
) Y6 x* W& K! j8 u4 z: t6 a! U } catch (Exception e) {
7 B. T. w0 r- v+ {6 ` B Z System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ q3 K: v) y: j8 L Q" Q, a9 Z
System.err.println(name + "." + method + " returns " + e.getMessage());
1 x, B+ n* z: F" l" F System.err.println("The process will be terminated.");# x) X6 l1 O8 g* w5 h( B, }
System.exit(1);. z& k2 Z7 Y8 Z7 q
return null;6 {- t: J: D5 ^0 _( E
}
0 G9 g+ V" Q+ i return sel;
) d* p9 n: i3 n8 P" B' o' s, {7 \ }: z" w: n1 c8 V1 o5 B( G! k5 d
+ e5 j" w2 a* o$ z3 U public static Selector getSelector(Object obj, String method) {
0 }+ ?( {2 u3 Y: W2 e6 q/ {, T0 D$ | Selector sel;) r% w) R2 ~( e; X ^1 d
try {
; J" k3 W9 P6 w& \/ E1 z' }$ _ C sel = new Selector(obj.getClass(), method, false);
8 o: w! K2 N" B# {* T6 l* T } catch (Exception e) {) N7 _ w1 [; T% ]
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; s+ f1 ~5 F% z2 B
+ (obj.getClass()).getName() + ".");
) o" U: a- _1 c' x/ y& }3 x) u$ l3 z7 S# T System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& {, p) Z' P R6 j! M' s System.err.println("The process will be terminated.");) R& S: {7 g' i- x, C
System.exit(1);7 L! t. Z6 n7 _, e* L( `7 X
return null;
8 p. p R! i1 S$ j }
8 _4 d: _$ |+ N4 Q return sel; ?) G3 j1 X6 @
}( d" q4 ^/ J( s2 W6 @9 W y {
} |