import swarm.Selector;
9 }2 j. Y! A' u- Z- {* q: z# i# U
1 u, E& H4 t* r0 U2 zpublic class SwarmUtils {
, o; \1 j& c& R5 H public static Selector getSelector(String name, String method) {- P; |& L& X6 f
Selector sel;: i2 j" Z6 k, M+ k
try {
: m; s( d# z1 R! o) R7 ~5 t sel = new Selector(Class.forName(name), method, false);
3 R3 T3 u, n) P5 Q% n: G/ _- s } catch (Exception e) {
) u: E* N/ o& \4 P9 Q System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) E* K5 R% V6 x
System.err.println(name + "." + method + " returns " + e.getMessage());2 q+ x x" z1 a( C
System.err.println("The process will be terminated.");1 I9 Z" | G- F
System.exit(1);
: ?1 F& K- W8 _, o return null;
0 { O7 ]" h7 w! |( O% h3 O I9 } }/ Y$ o0 K: P/ z, J" Q8 v
return sel;
0 H0 {1 Q# a, U2 v( i8 o9 t3 ? }
+ {) |: |; H4 a; `0 }. w4 C5 T9 I0 Z+ O, V0 q
public static Selector getSelector(Object obj, String method) {
! } g+ p9 {- k' z- |& b2 U Selector sel;
" D% w1 B% Y3 p try {
" J M* M! M6 b sel = new Selector(obj.getClass(), method, false);
% l, I" u* X/ B/ V } catch (Exception e) {
0 t! I0 Q" K, _( ~+ y! F7 ^ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 x C m' M' _! ? + (obj.getClass()).getName() + ".");
/ h' a; U4 C5 _8 V System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());& V) O( M! ^: p& q2 M
System.err.println("The process will be terminated.");
: r( ], T# }9 ~0 u; g System.exit(1);
. f6 b ?5 s: t9 c8 j3 T return null;
- B I' h ] N8 k }
6 `* k: w. V- P' n) E! ? return sel;
& |( {( r6 j: k! Q; i1 `$ B }
3 _( t7 ]7 C2 T/ }0 @4 g( T; A} |