import swarm.Selector;1 }( [: H6 W- a1 S0 t! `
Z+ S; J8 J5 x2 }/ O- e* Lpublic class SwarmUtils {$ q+ u: o# ]- t0 S3 }9 b
public static Selector getSelector(String name, String method) {/ @. w$ c1 Y( e& \/ h/ i
Selector sel;
) v' N5 i( Z7 `$ t7 J try {6 A. g* ^: { k) X/ K/ l
sel = new Selector(Class.forName(name), method, false);
6 i1 A# S/ m4 u: L* l% i# M } catch (Exception e) {
) |5 B! ]- c2 h6 R System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");3 k0 M, d9 ~/ Z7 n
System.err.println(name + "." + method + " returns " + e.getMessage());
" F5 d. J8 p( N System.err.println("The process will be terminated.");
# Y% V. ] O# i2 }% X System.exit(1);
' \! C" a. l, F( w# p return null;
8 D2 y' t( o. h, q) g2 F/ b5 v* ~ }: _7 S" Q* [. x$ S" ?
return sel;
3 x! C* K# a, {- P5 r$ I2 j! w/ e* ` }1 q' H- E! e5 B% q) P# z
( i* w5 V* C0 S8 T$ i( q
public static Selector getSelector(Object obj, String method) {
/ L: X5 b4 u1 Q! M0 W! C5 l Selector sel;2 B) [/ _+ |# d
try {
0 _/ R" W6 N1 y( f2 G% ` sel = new Selector(obj.getClass(), method, false);8 N2 Q9 f7 T5 Y" t4 ~
} catch (Exception e) {8 d* p1 c( w, L) b, \: e
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ X- A: r# x" t& p + (obj.getClass()).getName() + ".");
* Q! u! d* S2 m System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
- u. N+ ?" I b1 K3 g System.err.println("The process will be terminated.");
, [! ~2 d+ R8 t, H/ M! |4 a/ O8 C System.exit(1);
2 b! R! V0 y6 a( ~- w$ v" N return null;; L) ?" Y+ W' N6 a
}' @9 p2 m' n; A; X' ?
return sel; r1 C2 m# l m& |
}
9 J: t' A h/ A; |. ^} |