import swarm.Selector;
# z1 \8 ^4 B5 v( {
" p. ~% c( V W( t9 X& o2 Q& `( gpublic class SwarmUtils {( {/ z8 G( r; e& z0 Y5 r, k
public static Selector getSelector(String name, String method) {9 i6 s' H; Y# N( \) j% A
Selector sel;
1 G; k& z* i! l& J: j try {0 K: d. {( t5 W% Y# j( O) h1 ?
sel = new Selector(Class.forName(name), method, false);: Y& G& C9 {4 ?4 r& ?
} catch (Exception e) {
8 v! l0 Z7 [) s System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
) h; U0 E3 K. s+ T System.err.println(name + "." + method + " returns " + e.getMessage());& C$ V4 J0 k! o" a8 @
System.err.println("The process will be terminated.");
! E, W3 y5 m- q System.exit(1);
: q6 y* M' F! N# U# F return null;
& C9 k$ N4 f P: c7 M }
3 J( ?& ]2 b, B L# _ return sel;$ H: E: n+ ?9 l
}
7 @; M5 H/ B6 g) n: r; C3 N" l/ X8 ~- m6 N( q
public static Selector getSelector(Object obj, String method) {5 j- X. s" R$ d% l4 @7 a% h; _
Selector sel;) i3 |; T# I. J5 Q) u3 j' i
try {: V6 U1 G. s) z6 e# p9 L9 e
sel = new Selector(obj.getClass(), method, false);0 a. T9 s0 _! T6 S! k
} catch (Exception e) {
6 X1 E* ?# O# f4 c. u System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 G# G2 p$ a0 W: j* X i + (obj.getClass()).getName() + ".");$ c3 O |2 M3 L9 D( o6 M
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage()); k4 M; ]7 _, H2 e3 e' _
System.err.println("The process will be terminated.");
; y& t2 d& i/ ~0 | System.exit(1);/ s/ v4 L$ e0 H8 D" |1 V, p" W9 |
return null;5 z$ s+ j1 q8 e3 Y
}* S' w9 H$ N7 h
return sel;' b" U- ~1 E+ u. I" V# O
}2 J8 w4 l) m: X# u5 @0 Z
} |