import swarm.Selector;
- g5 u' V/ [; H( A8 R( H: C6 s. i: F# L% O' h6 p) T2 X8 z
public class SwarmUtils {
8 ^* l2 d% \1 U1 z7 x; s: G' q public static Selector getSelector(String name, String method) {" \, |4 a" ^2 e+ Q4 z5 N8 z4 C
Selector sel;
( x( ]. b, u0 b9 A& \ try {
; D) q% r, u4 B1 h9 l8 t) R sel = new Selector(Class.forName(name), method, false);% @( I5 P/ p% @. h
} catch (Exception e) {
& f% d# v7 X+ v4 f+ F+ G% D; [ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");' ]4 z9 N) y1 _( V) |2 t, I
System.err.println(name + "." + method + " returns " + e.getMessage());
3 e! s R/ v9 h) a* X) S System.err.println("The process will be terminated.");0 s7 Z+ Q7 C7 p/ K1 ^
System.exit(1);" d* n! i' j8 k, m! m" }0 u
return null;
) `, O. s6 F" t }
A% F) [% o) I- M! x9 q return sel;
& c6 X M# V- A0 ?) R }$ e5 l( U/ _- n, `& O
+ @6 {5 c( x- `: S
public static Selector getSelector(Object obj, String method) {* W: b$ }! l1 @0 a. Z4 N
Selector sel;. @8 h* B( Y( |( |) n7 x/ r
try { K y7 H6 e: Z
sel = new Selector(obj.getClass(), method, false);
3 a) M. E* M6 Z, V4 h& U } catch (Exception e) {
. w9 k( m+ v& Y$ y D: f. x% B- T System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
3 ?& J9 F" Z; @2 q + (obj.getClass()).getName() + ".");
g) v! N) m+ f' b4 s0 m6 A System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
. C8 T9 c+ |" i+ I" ]2 H1 I& e9 @ System.err.println("The process will be terminated.");
+ n! Z' \: d% {% f# B$ O! _ System.exit(1);
( L) l% H D5 D* f8 E return null;( v" P% P5 I. z1 b3 D$ K
}
" w, e, g7 R! F: X' V. G5 _ return sel;+ W1 [% I, E# V! y+ U% k( w
}
; R* v$ U( q4 ^+ x; X' Q} |