import swarm.Selector;- @3 J/ r, R) o# J5 T# S/ r9 @
' e0 z& [" m, F3 O
public class SwarmUtils {: r, X1 I1 S& l; L
public static Selector getSelector(String name, String method) {
0 R S# U& z4 i8 n Selector sel;' ]6 M$ F+ R. v
try {
5 L6 j. V' M$ i- A1 ]- k! W sel = new Selector(Class.forName(name), method, false);
9 u# |* ]* T0 Y1 @ u } catch (Exception e) {
4 B* m9 O3 r" |) t' E8 p# _ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");6 R! Y3 n" `) ~
System.err.println(name + "." + method + " returns " + e.getMessage());
3 w, }: d4 ?- [! D) g System.err.println("The process will be terminated.");
1 W1 Y) U n* [- x System.exit(1);( W4 P% F8 a2 C6 ^; x/ {
return null;- g; p+ r/ J( ?0 t1 P3 [" z4 N/ Q2 d
}; u, _3 r9 \' O, V- b& Z
return sel;
) y: D! Q) B! Z' C3 u8 u: X- v }9 F6 o4 V* n0 i
( G. b# i' M( ]7 [6 E S public static Selector getSelector(Object obj, String method) {
- X3 c3 v7 S8 o; r- @( j Selector sel;
" ^; p" S; G* A try {3 m/ v0 a1 z$ f. V6 P
sel = new Selector(obj.getClass(), method, false);5 ?" k! L/ U9 @( R
} catch (Exception e) {: P @; h/ G% ^
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
% Q* H* q; z" B! T3 i + (obj.getClass()).getName() + ".");# Z! Q- S* ^3 u) Q# f4 A3 T' _8 q
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
/ {; r m) a6 ?; Q& w% [/ n% }& S System.err.println("The process will be terminated.");
% {1 f X- _1 l8 Z, d7 D System.exit(1);' X+ l7 K6 z' o& C% u: C
return null;1 c7 n% A/ h" H/ @+ E
}4 z V$ C; b: V% K
return sel;
* F) O9 R$ p# d: Q( c" e) E& J: w$ d% x0 I }
( s. m% j# Z- J. X7 R} |