import swarm.Selector;) W" p' ?7 h0 ?* Q2 B
+ i6 _% V. K) c; G! a5 Opublic class SwarmUtils {
. v, w/ \; e) y6 }2 M public static Selector getSelector(String name, String method) {
; U- [) b5 W+ C$ a! H0 I0 @2 n Selector sel;8 G, ]% l% b* ?
try {
0 t4 G2 l# y4 h* q+ |5 U: c sel = new Selector(Class.forName(name), method, false);
# G6 P' l( @0 p D& r0 G R: @ } catch (Exception e) {# q4 t" v/ O! O7 D% H( Y
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
, \* W7 }' [8 N# s: X4 [; O System.err.println(name + "." + method + " returns " + e.getMessage());) N& A" h' T& K' n
System.err.println("The process will be terminated.");* f7 `0 {- b- q( M: n
System.exit(1);& ~# S; C. \0 ]- r2 H' ^
return null;
+ T% p, q- C4 a0 ?- B9 c7 v }$ u0 |. U. l @. h
return sel;
o* p+ [4 H5 B) Y4 a5 T6 n }6 O- | @8 r" R! ^5 l
; a5 R/ q9 e# x; A' `
public static Selector getSelector(Object obj, String method) {
1 Y* V. W/ z9 {8 ~6 I Selector sel;) ?3 V% T k2 B6 _
try {' k. A% x1 i4 B
sel = new Selector(obj.getClass(), method, false);
' v s$ a+ t7 u: V A; ~ } catch (Exception e) {
2 c; }& N, |: O. c/ O3 {' g System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
( y, t5 Y9 O& `+ u + (obj.getClass()).getName() + ".");
7 j% K0 Q: p* O$ `: w System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());6 n R; g( W0 w$ g7 J* v1 J
System.err.println("The process will be terminated.");& z w1 i9 o! I& n' t% z% p3 U
System.exit(1);
* ]3 J& _( c2 V! {% p' H+ ] |, R return null;: `" C/ [9 a7 u# c
}
0 G, i: P) W" d% Z6 w9 H return sel;$ o; X% F. H$ [+ \
}
1 U& a6 o) k) D+ m5 a& H- s1 _} |