import swarm.Selector;
1 Y# ~2 U) w$ \; t
- m& j7 [, d0 O* p. Lpublic class SwarmUtils {
) y+ w, P9 Y; z. h- @+ l2 K7 e" m public static Selector getSelector(String name, String method) {2 j# P% N* B$ {( G' e* B* I9 h; F
Selector sel;- T) M' B. P. }/ k/ x0 P+ k
try {
- \- m: |# P" C; {, ?: B sel = new Selector(Class.forName(name), method, false);: M2 S6 z0 L3 }. T1 G* r
} catch (Exception e) {) F, S/ `3 _. }* O
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
% W( @: r8 v$ r! L5 \ System.err.println(name + "." + method + " returns " + e.getMessage());
5 l) g" L& T' N System.err.println("The process will be terminated.");
- R: y- Z4 k& \7 X: c/ w System.exit(1);8 l: J, R& X4 u3 m
return null;
" P4 X& x5 d2 Z8 m; V3 [ }
. v0 m' g O ~! H/ ? return sel;
. p4 W3 P; j0 f3 [* r9 v- I }3 `' D3 L1 ^7 j8 Z
, y" V; r/ l* n3 \( P public static Selector getSelector(Object obj, String method) {
8 r4 X8 E4 C, J7 y2 n3 ^4 { Selector sel; Z# Q' J" m' f+ v' h# t5 y; t/ |
try {
5 x* Z; q. h+ G! [/ Z sel = new Selector(obj.getClass(), method, false);" p/ m; a8 i! T8 D* z% f
} catch (Exception e) {: u/ W5 S7 ]2 F, E5 d5 ?7 `" }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "4 {0 D6 F2 |3 W G# E' V% `5 q
+ (obj.getClass()).getName() + ".");
2 @) y. U5 u3 P* m System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' s# V! d8 @, N$ c" C System.err.println("The process will be terminated.");
: T5 Y+ H8 ^1 q0 S System.exit(1);
4 R W) O% [9 e9 T1 g return null;
5 R7 y3 x7 o8 a% d7 n( G! C }/ s/ p7 ]; U" I9 s H
return sel;
9 ^ p4 a6 G( L7 e' n/ M! S5 G }
; E* p' w1 }- g; {4 ^+ M2 h} |