import swarm.Selector;
|! Y. _/ s6 _+ A8 d$ L# v1 K4 M/ ]
, M# ]) ~ u3 T: I$ A6 Hpublic class SwarmUtils {" t* g \8 I/ N- `! k* d! _
public static Selector getSelector(String name, String method) {" K. M( l, C( e. k
Selector sel;
8 J5 D7 X" q- h- c( U i try {5 j) [: w8 @* o8 g: I
sel = new Selector(Class.forName(name), method, false);
_- h! R& V, [9 A7 B8 g( r1 _ } catch (Exception e) {4 B4 r+ c! x3 `' a5 h7 X/ v
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 A. A" j- ~8 ]% K3 {( H% [ System.err.println(name + "." + method + " returns " + e.getMessage());
% W U% Z6 h) P2 n& S System.err.println("The process will be terminated.");
+ R( S* J% Y5 o3 Q1 [4 o System.exit(1);/ Y( e$ `4 I1 {4 f
return null;
! d! Z$ u. \. ]6 ]" G1 z9 @ }
; H* M- t* ~ l9 _6 B return sel;
/ k u. D# r/ F' S( q4 Z }
. ~+ S: ~5 L/ P" f' Q! n$ a! V, x( @, b) j
public static Selector getSelector(Object obj, String method) {, s+ A1 U% |8 @& C6 r! n6 k1 W
Selector sel;: Q1 |) E- I9 h6 j$ S
try {
# c5 d( V* X6 u0 a sel = new Selector(obj.getClass(), method, false);. }9 v7 E- L ?# x4 L: B) E- e
} catch (Exception e) {) c# Q& `! c! n% b: J6 Z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 V" a) k; n. @1 b9 S. H + (obj.getClass()).getName() + ".");
# n. e+ T9 I" q$ R8 ` R5 W System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
L$ e! g+ ^, S, v" q! v System.err.println("The process will be terminated.");& e& @2 w7 Y# a& g6 F
System.exit(1);
* ^3 i" D+ Q; k& _9 H4 J, i \# L return null;
# m5 G0 u$ _9 y. a7 c }1 ?) I, e8 r, o( ]9 x
return sel;
+ p4 N/ x0 J- i1 ~7 A0 E" m# A0 z& f }; Z8 }& z" \! m" p' p. K
} |