import swarm.Selector;& M; s8 k6 s9 Z. K9 u+ y
" L& y5 g! l3 n/ |% m ]
public class SwarmUtils {; {. w0 q5 Z8 }
public static Selector getSelector(String name, String method) {1 ?3 b+ p! u% Y
Selector sel;
3 q) Z. V- X* r$ H' L# v" c try {. P, L2 ~4 W9 Z' R; l
sel = new Selector(Class.forName(name), method, false);
. _' W" z6 S p5 x% L3 H% {# ]: P } catch (Exception e) {" ]- C5 b- s6 u j4 X8 v. m8 s Z0 ^
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 T) L; Y* P) m9 r1 t S System.err.println(name + "." + method + " returns " + e.getMessage());1 t& p' ^3 `3 x; t4 R7 f9 k) e" B
System.err.println("The process will be terminated.");
1 |5 p7 [' v4 |9 ? System.exit(1);! V' Y& ^# r- F# C* o7 X* N, [- j7 r
return null;
9 ]* p& [, j& U1 X6 r+ \6 W! | g }
3 n. w" | b1 {0 ]8 {2 }0 [ return sel;1 P" {9 i6 `7 s# n: E& v9 F* ^
}
4 F, z( j& {5 n: x$ Y9 \! G& Z# v$ M, k0 ~1 r
public static Selector getSelector(Object obj, String method) {
3 s5 x& M4 G M Selector sel;! Z2 H2 k8 ^) u( p
try {
% u4 M7 V) c! v$ i7 S, b6 J5 k1 i sel = new Selector(obj.getClass(), method, false);1 X- H4 r5 c9 Y
} catch (Exception e) {- k* c! y+ n, o) Y' O0 @' c
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "5 }9 R: R3 f3 @
+ (obj.getClass()).getName() + ".");
2 \2 s9 c$ C" b8 F$ H4 j/ G System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& K9 v! L8 N' |; H" ^4 i9 r System.err.println("The process will be terminated.");0 f9 \+ l: @% c0 ?0 V3 t
System.exit(1);' e, t2 M2 ?" p M" A
return null;
9 C) O& `/ i8 t3 Y! p: z4 ` }
! ~6 q' I7 L3 _+ j4 Q8 @0 h8 s return sel;
- D& n# b# X% ?3 { }5 w0 K/ i4 D+ [
} |