import swarm.Selector;3 n# Q4 H- m+ O A8 R0 x- ]
0 x# `) S9 p7 _3 k4 H& Q6 |public class SwarmUtils {% t& f, H& [3 L2 d
public static Selector getSelector(String name, String method) {; a9 ^5 S. k( |
Selector sel;
o& K1 K" b; u8 o1 d2 j try {" o5 F" x0 {7 _8 H" L* U# G
sel = new Selector(Class.forName(name), method, false); G0 l. Q+ g; `" z
} catch (Exception e) {
+ A& C* h) \1 y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; Z8 e( `( ?9 e+ c o! n
System.err.println(name + "." + method + " returns " + e.getMessage());3 K; ^0 M. ? w' j8 a- @
System.err.println("The process will be terminated.");
+ Q1 A8 m& j: U& a" F7 E2 Y System.exit(1);
: o0 A5 ~* |( C5 A( h* s. z, ` return null;
1 G0 x# o/ _; G2 g: _2 D }4 x" K0 F! |- I8 V) h
return sel;
) a& Z6 `7 N# s, w( w) h. u- E$ g6 D }
3 r3 f' r; X. F; w# |7 [1 z+ i4 t! l' L6 Y* p) S- X1 |7 J7 a
public static Selector getSelector(Object obj, String method) {' x! o, ^% |& r. U: u
Selector sel;
- m1 \% J! F6 V# ~/ k) A% U+ f0 [. w try {
8 B% @' \& h# ? sel = new Selector(obj.getClass(), method, false);% _! P; H# C. ?/ g' X
} catch (Exception e) {
2 i: f8 N9 Z1 L. \( p3 z+ N System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; @, x4 L- D. {0 U
+ (obj.getClass()).getName() + ".");' c/ |' n+ Y$ `0 J2 Q
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
* E# ?6 O7 |* I8 }) C System.err.println("The process will be terminated.");
& h0 l: N9 @: M" U& R* ` System.exit(1);
; h- n# h" Y/ ^5 }8 i' J return null;
: J% |6 o. ?& q1 {0 @5 F }
" y4 Q$ Z& ^8 S/ m" {0 V. D return sel;0 w1 z, ?$ o/ ?
}! \ g. |( ]8 ]6 X! ~
} |