import swarm.Selector;
2 f: B) E( M- c0 _( e* @
9 w3 j# V3 W4 x. T. _, r5 ?( {public class SwarmUtils {9 S$ m K0 W$ [+ b. y1 [6 |
public static Selector getSelector(String name, String method) {
' s& p) K$ ^, T: g; {4 ` Selector sel;
& Z1 @- [5 {8 V try {& Y1 \8 I5 [( i# n* F! |% i
sel = new Selector(Class.forName(name), method, false);% A0 m/ Z5 M( r2 E
} catch (Exception e) {: K6 U9 Y7 G% i9 j* Z- X7 a
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");9 M P/ S+ Y" {, F# Z
System.err.println(name + "." + method + " returns " + e.getMessage());
' U }2 u1 T3 l1 t System.err.println("The process will be terminated.");
* a1 _' L- B9 d1 ?) G System.exit(1);1 s! K8 L: B4 @0 g" g
return null;9 E0 a$ ?, ^/ M$ c, J, @
}
% n7 i! D& ^9 _: G6 A' i return sel;
5 T- _5 @* L8 a5 W8 o1 W }, P' O7 n7 U \ ~: N7 q
3 j! |/ i$ h1 ]. ~ public static Selector getSelector(Object obj, String method) {
; Z3 Y4 d7 T) B3 w# u Selector sel;
: A3 H0 E0 E8 A3 t) D- e* |' C- [ try {
. u. U4 e' [- S1 ^+ ^% I) O0 h sel = new Selector(obj.getClass(), method, false);
, w6 |. X( @: Q' H9 z7 E } catch (Exception e) {/ b/ a; p9 K5 k- d
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "0 B* J" ]8 I- Y/ r
+ (obj.getClass()).getName() + ".");$ G, J( X& G' S: u2 V% {
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());3 }$ a+ n. i+ A) Y
System.err.println("The process will be terminated.");
, o2 m; `7 k: q7 \5 [/ Z) \6 x System.exit(1); ~: c; R) T1 |
return null;
. ]/ A' e+ g" [6 V+ q, Y1 D }
7 U4 Y5 O3 M) Q3 ]1 m return sel;
- O& O7 Q0 ]9 m5 G0 c }7 c! K4 K0 |7 g9 L" x' ?
} |