import swarm.Selector;
+ K- ]9 R/ n1 g3 _: @' s$ i! _- K4 j; U! }' }, \
public class SwarmUtils {
4 h0 U" W* F. t public static Selector getSelector(String name, String method) {, v, e1 W- h: v% R: e
Selector sel;
' d2 H& K0 j+ E try {
! ~. _( G, W( T sel = new Selector(Class.forName(name), method, false);
" l |6 C: D) @; T } catch (Exception e) {8 v' C& s& n- a3 o: Z$ A2 }2 L
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
h2 L2 \$ a# G2 }4 O- z5 @ System.err.println(name + "." + method + " returns " + e.getMessage());, I7 E0 `! M, r" {: A/ M
System.err.println("The process will be terminated.");( s7 }2 D1 v* O* p k0 o
System.exit(1);
; D$ A, ~" Z, q8 a3 z; S7 A return null;2 ^* {' Z% g; H7 H7 ~7 {# T/ v& z
}
' a2 ?0 f' i, R! D return sel;- W" m$ I% u4 }/ e
}% w6 n0 V* |1 v. M. t7 @$ f
! z1 Y# M5 `0 f t# R public static Selector getSelector(Object obj, String method) {
5 o; [% }2 n4 B ?7 t) x Selector sel;
- O5 n' ^4 w$ o* o9 L9 e4 I" } try {
2 M. Q- M! Q5 u0 P# C% s sel = new Selector(obj.getClass(), method, false);& R3 Q# w' t0 A* x/ w3 m$ Y
} catch (Exception e) {+ }0 P1 v5 D& j" K# o
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 S; |0 }. l/ b: ] + (obj.getClass()).getName() + ".");
3 |9 u% e# a6 U# @ a4 b System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' V' T$ F& [/ s+ c& C System.err.println("The process will be terminated.");
, j, z0 i3 ~7 U6 j0 ~2 B( s1 H: a System.exit(1);
! V& \2 b6 N6 ]& \5 S return null;
8 T$ S0 `% U& C) C" G, g }9 k/ @" v3 u: e( }4 e
return sel;/ p" |6 i) y$ ]$ i
}7 f6 X' Y' a) }5 a$ l
} |