import swarm.Selector;
+ g. y; L8 z3 S+ ^6 I" \
9 R' ?0 U$ o/ k! ppublic class SwarmUtils {
$ a" l; Z/ Q8 t& O4 c t1 D' m public static Selector getSelector(String name, String method) {7 X6 g& {' G! l0 g y7 R
Selector sel;: k/ ]6 \$ r) P1 g
try {; J1 ]6 X( d5 @0 j7 ~- A( S/ q) g
sel = new Selector(Class.forName(name), method, false);+ c- V' U; j' ]$ j
} catch (Exception e) {4 I* t$ y3 F6 F. Z/ w" D" O/ {
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ e n$ s5 A5 }
System.err.println(name + "." + method + " returns " + e.getMessage());/ L5 w' q+ P2 ]" u
System.err.println("The process will be terminated.");4 Z+ l8 j* u5 X" \: }) \+ o: I
System.exit(1);. E& `: [ L* u/ Q$ F0 D( z
return null;
; q! g t% y) M9 r q" s% n# u }1 I6 \: U' B' j* z L$ Y
return sel;
7 [. g0 d3 ~2 j8 `6 z }
; K3 ]( O( B1 l( g; z5 Z
. ~/ k! O4 f; L3 }9 ?8 S" Y s public static Selector getSelector(Object obj, String method) {3 K6 f2 F* k0 T$ ~
Selector sel;9 T0 t' j9 {) } i
try {
| [4 z# Z3 N- }4 c3 [5 N sel = new Selector(obj.getClass(), method, false);
% F: E. n U C5 C5 @" D0 W( `# m } catch (Exception e) {' p" T; _2 V7 e! T b5 Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
! c& {! g# `! Z: V8 X + (obj.getClass()).getName() + ".");
9 A/ K! ~& {- z1 R& n6 ?/ a System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
8 t5 Y0 D2 _( P System.err.println("The process will be terminated.");
, @* H8 k2 _5 L5 V0 t+ n System.exit(1);
$ @2 I' Z% L. _* {5 L V return null;
" C; `$ s& F! K6 h3 } }' H# K2 i8 n* [/ j
return sel;; R4 ^4 W0 q* q* Q$ F0 C: E
}0 P) d! g% c* R$ f1 A
} |