import swarm.Selector;7 l. A- x" d# x, i* S5 }: }
: {- W% A) J7 a! p* G: {! `* e
public class SwarmUtils {, S+ e0 j0 [9 O) L& a
public static Selector getSelector(String name, String method) {0 A0 L5 _$ P3 }
Selector sel;' Z8 P6 k$ ]3 V: j! P, P
try {
% {% d7 S7 |2 ^ O: v/ ` sel = new Selector(Class.forName(name), method, false);
( \) p! v" W9 ^+ l, v$ g. S8 ^& H } catch (Exception e) {2 O5 a+ W# `: I: X; ~# C0 [- R G
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 D: _1 V- T) A* ^, O System.err.println(name + "." + method + " returns " + e.getMessage());
f8 _+ z; Y9 Z8 z2 @) ~ System.err.println("The process will be terminated.");
! P% S0 C8 ~/ q* F. C9 [& | System.exit(1);0 k& `3 d/ J/ p
return null;
0 Q( S! o4 C0 O9 Z3 [4 w }$ Q: _ C0 Z& g5 P
return sel;
& k6 ]2 a5 t: k, B0 K }7 C8 m- O( L9 X3 D7 s9 E' `' L5 t
/ F8 S! |6 g/ @
public static Selector getSelector(Object obj, String method) {
- N$ `$ W' B; p7 P8 P" d( m, I Selector sel;9 o4 F) U. R8 x; a7 L
try { F6 t0 O5 L6 r# Y( ?
sel = new Selector(obj.getClass(), method, false);1 g) d7 m8 J6 |' w, M
} catch (Exception e) {
. f. M7 T/ n5 i System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
) B2 X9 O# |; q3 X8 K: q + (obj.getClass()).getName() + ".");
4 o# v8 ^( \3 {1 H System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ {2 @" p7 l8 h4 A4 r% U. w0 f+ O System.err.println("The process will be terminated.");
2 [; f3 L2 Q1 m$ G System.exit(1);/ O7 z" {3 T4 [8 u) ?$ N& z
return null;! ~# d( v! v% i/ m7 ?) `! b
}* e& L% }& [5 i
return sel;
+ O( f2 e9 G* l7 `$ b }
/ C; O' q3 h% Q \ M+ y5 d} |