import swarm.Selector;' D: q* ~/ P( Q% U0 ~
" P$ B1 \$ e7 @8 l$ P. Opublic class SwarmUtils {; m% S7 v( U6 a" `5 }% A9 |
public static Selector getSelector(String name, String method) {9 P3 R" J& f G, [
Selector sel;
# r0 @5 R8 V6 v+ `% U try {- Z& \% H# h! a
sel = new Selector(Class.forName(name), method, false);
" q) S6 X9 W! Y% J% ~ } catch (Exception e) {
" m9 S, @0 _$ Q System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");1 n7 y2 ` ?. L' A: `! q" A
System.err.println(name + "." + method + " returns " + e.getMessage());
: ]: s4 e$ I R5 ^) _ System.err.println("The process will be terminated.");" X7 s8 Q* d' H8 ~
System.exit(1);6 Y' Q5 |" d* |; `# M
return null;# L( a# |1 H. P
}7 K/ p: f1 P: e2 p! s( ^" H/ i# k
return sel;- k2 Z+ c; c- o' C9 e! S
}2 o+ ]1 c# q8 \) R$ X$ Y0 i% ^
, b1 Y( u" {( Y- f( Q2 o; P1 U5 H
public static Selector getSelector(Object obj, String method) {
. X1 Y5 v1 a6 r k5 G Selector sel;
; ?; R- M; a2 B |, V) {5 m; F try {
/ Z, P2 R4 F. c8 m( Q; ^2 k: I- I sel = new Selector(obj.getClass(), method, false);
- t( m" K! S5 W$ `, [* Y3 C2 w( v } catch (Exception e) {- |: a* h' p; v- Z2 P& X! a8 `
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ x- \/ v, Z5 v( ?( z + (obj.getClass()).getName() + ".");
/ p5 T/ y0 g- ^2 q System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& B# P% o: V) Z& L$ n& B: m System.err.println("The process will be terminated.");' t1 x; D& u& Z# e4 e
System.exit(1);
0 I( ?- n, S X return null;, e# G6 ?' N4 b: W' ]3 r8 D
}
5 ^: ^3 t+ s/ r4 F6 J return sel;
- e, F4 B7 P3 Q, q7 @# k }
+ t6 g$ \- D) c8 V- [} |