import swarm.Selector;
+ F& h1 k1 v) I6 a! f- A& a7 y
& `1 r- M5 Y0 S9 {) o1 Vpublic class SwarmUtils {) s: {* c/ K. V, v
public static Selector getSelector(String name, String method) {
V/ O$ z* n- A1 w* v Selector sel;5 l4 C! \$ `7 p2 ]3 ?
try {$ v. }; V: A: T9 X; Q( y
sel = new Selector(Class.forName(name), method, false);
, Y3 n$ S6 c6 D8 [ } catch (Exception e) {6 s0 J3 ?& I8 o" u. ]# r& [: m W
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
, }( z( C/ r5 H* S+ \; y8 V System.err.println(name + "." + method + " returns " + e.getMessage());
! C: [" S8 f* k+ Z/ Q System.err.println("The process will be terminated.");
. V4 w# x. v) E" h% M* k System.exit(1);
' S6 B8 H5 [ n) j6 _& d return null;
`! |/ t- z, j2 [, }8 r3 ^# ] }: D" O( e0 N4 I7 n0 I& }
return sel;! d+ m" ~2 u9 U
}7 u0 T4 C5 N* u! i# O; {' z1 [
: B% i& g: `% e+ H3 f public static Selector getSelector(Object obj, String method) {1 w3 z& Y$ ]% [/ v, S
Selector sel;6 O- i' `# \7 u2 `; s; J9 \: X
try {4 Y- \1 P3 A/ [7 u
sel = new Selector(obj.getClass(), method, false);2 T' o1 I `3 G" r, f% i& j
} catch (Exception e) {
4 C$ ]/ v; r1 J3 [0 {- E+ o System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ i5 m7 r5 j1 C' A- s" W
+ (obj.getClass()).getName() + ".");/ g- r1 @5 S5 Y2 C+ o2 Y+ ]
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' C2 C1 s* [3 r+ V* P& ?. g, d- K System.err.println("The process will be terminated.");
9 D {' b3 ^% s System.exit(1);3 W" _/ \# B! L) U2 `/ a! |
return null;2 _' M9 t0 u: g+ j
}6 {: D0 a/ ~$ ]* u+ j7 P+ W
return sel; ~6 h. s/ W: @" [9 C3 H
}6 W$ K' ~6 o; H3 H
} |