import swarm.Selector;+ a I+ s S" _" \- Y- J# q$ D
% M7 s; V6 q: ^. u& O0 Lpublic class SwarmUtils {
) z/ U9 s/ V/ u- T0 q* g0 M public static Selector getSelector(String name, String method) {
; L9 E/ X1 H* w( d( J; ] Selector sel;
4 P$ E2 J. l# f+ L try {
`3 ]* I, ^8 Q% F0 _, K sel = new Selector(Class.forName(name), method, false);, b: @3 O4 \5 d# g" W
} catch (Exception e) {9 e8 |1 W+ l+ L& z3 }, M
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; V# C* M: J1 D, y+ ]# ^
System.err.println(name + "." + method + " returns " + e.getMessage());
; F5 y l" \$ t/ c- F6 ] System.err.println("The process will be terminated.");
n: {; t$ C5 Z7 `' } System.exit(1);
! u2 s2 q3 I0 C+ ~ ?- y return null;: p7 O* m9 y" V* N- w& u; ~* j& P7 Y
}2 X+ f! g$ ^- x, Q+ {/ |
return sel;9 c# M6 Y' Y1 j, j$ P
}; F" U6 f% L J* `
' {# ~8 Q8 z9 ~' ?" @3 h6 q
public static Selector getSelector(Object obj, String method) {
0 X/ g, R# p& g: S) B) j Selector sel;
u- t \" e2 }6 O try {: g4 O7 {' X2 C
sel = new Selector(obj.getClass(), method, false);
. K& u% K- I2 R- N5 d. J } catch (Exception e) {
5 T+ ^" D4 ]6 r2 L. o System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
# B& ?3 ]1 V( w% A* @- d) d + (obj.getClass()).getName() + ".");, |+ H7 R, R; a, _+ J b# S
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
! I1 t" M9 j8 [( W4 Y7 `# f1 X N System.err.println("The process will be terminated.");" Y+ o q! q! e0 E( `
System.exit(1);
) T# ^) W# e4 x2 w2 T9 d return null;- b7 Y" r6 P: M% v" f1 ~9 c7 ]& _
}
; h( f) O) t3 r) N9 G+ v( W! n return sel; G' F% ^6 _& F, O" J2 l
}
W. Q9 ]0 I9 F7 Y9 f0 D} |