import swarm.Selector;
6 F9 x4 T0 ?# v
( m( J# r3 @, j0 Xpublic class SwarmUtils {
; ]9 I# p) ^" m! @2 a' Y N4 E public static Selector getSelector(String name, String method) {
" {+ j. V& |# {9 u6 e4 u5 ? Selector sel;
/ Y6 K# D" x3 S& }! m5 g! E3 A try {
# V+ s' [9 o* O n+ p2 _& O) _- T, F sel = new Selector(Class.forName(name), method, false);# ?! V' [* ^" _; f/ ]& ~( H
} catch (Exception e) {
0 @3 A5 ?9 m* f$ C \ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");- }( C% b/ {1 l1 U& a* x: R" z
System.err.println(name + "." + method + " returns " + e.getMessage());
3 q; i. p1 g* R% j# ?- L+ K' w System.err.println("The process will be terminated.");
V5 Y L# c* _" ? System.exit(1);, Q$ j/ r* R [! A7 V/ Q4 J: X
return null;% l! R1 t7 f) D j2 W
}
: @* u, Q+ ]/ G Y$ [" S' ~ return sel;
' [1 A5 h% `1 z0 g$ m }
' q8 P" C4 ^: c* a1 v, H6 }
) p g$ H0 X6 w3 M% o+ F3 \ public static Selector getSelector(Object obj, String method) {
& ?1 ^4 H4 u$ M4 c$ \! C+ m( m Selector sel;% U( \- r1 X9 D
try {, x* q4 W# g. K- u# V h' l8 u
sel = new Selector(obj.getClass(), method, false);8 e$ E8 Y+ U) R# U0 h' K
} catch (Exception e) {
( m# ]0 I. V# l' T0 U% s System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
" L. z, o" ~) G' I" V + (obj.getClass()).getName() + ".");
5 s$ P, g3 @" o7 ^ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
( M, ^# @, G n8 S; r4 v& r. [! D System.err.println("The process will be terminated.");, |! v% I: Y7 V. L+ C; F* i- r, @
System.exit(1);
' k- M) ]0 G) C9 G; r return null;
' ?2 T9 I7 S @- T. k5 L7 o }+ q. |. e/ y: A2 _. Z
return sel;: i2 q' z* m6 q' E
}
1 I, H2 T8 P, U# g% B. Y7 Y} |