import swarm.Selector;; m- s! T- z1 K% I- O, J
/ r, Q0 M& H( a3 P
public class SwarmUtils {" [. T6 D1 V6 N, K, @" I
public static Selector getSelector(String name, String method) {# A( q! W& c- p
Selector sel;
9 o& P7 s5 M% y6 x8 k% }: D try {6 m: j8 |" c3 }
sel = new Selector(Class.forName(name), method, false);
' U' @: L' i( Z8 j& _ } catch (Exception e) {
1 x0 w" `3 D0 D- i5 A3 K, Y* R* P System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) i8 _3 B- B" j$ u" ` [
System.err.println(name + "." + method + " returns " + e.getMessage()); u/ e( a0 R% b3 N* T$ g: ~
System.err.println("The process will be terminated.");2 ~# ]% x; P* H
System.exit(1);
- z2 G& ~0 x7 H) }5 h return null;
# P) }9 p6 |! x( G% C6 M/ P }
2 _$ z: V/ v9 V3 L! w return sel;
! A, \* {9 O' v% k }7 \. M' v! t0 \: B
: U8 `# n# q2 ~3 S: [ public static Selector getSelector(Object obj, String method) {! r$ A" ^1 i4 V5 q
Selector sel;3 y; _& A8 O; c
try {
' B1 z' b9 [/ ?& e# v sel = new Selector(obj.getClass(), method, false);8 l1 P0 @& r9 ]6 g; n( `6 E2 _; J
} catch (Exception e) {
8 G2 d( N. I4 H System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
& g. J3 ]0 ^% }2 }$ U3 } + (obj.getClass()).getName() + ".");
5 a1 {! A5 ?! | @7 w3 i System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());+ f# i' @1 ^5 h
System.err.println("The process will be terminated.");
$ S9 f% ?( }7 e* ? T; K# y System.exit(1);0 o1 V0 \7 k6 F0 t7 q0 B5 f9 |& U
return null;* L( P. A9 F, d
}2 [1 v3 r6 P. p( T: G1 A
return sel;% p4 p+ C! H% p1 [; X2 U
}
* B8 m V" q$ F3 H2 u9 K/ F} |