import swarm.Selector;( u' s, ?4 c0 g% o
. e) N% v3 M+ w$ ~9 `public class SwarmUtils {
: Z- l b4 _, @. e3 q public static Selector getSelector(String name, String method) {
3 U' D2 o! |) U, c/ U Selector sel;
g" ~; {) Z) I9 z try {
) Y' T7 F- u8 o5 B" c sel = new Selector(Class.forName(name), method, false);/ Y' v1 O# L" W' u
} catch (Exception e) {9 r% G: B! }" l$ ?0 k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: l$ O# m( u8 N$ {. p2 d System.err.println(name + "." + method + " returns " + e.getMessage());
1 C6 ~9 c- x) v$ `% y System.err.println("The process will be terminated.");
9 H& X3 m3 O5 w; ] System.exit(1);' I7 W4 j8 S* a7 }
return null;& V3 J! p, g" e
}: A# E) a- T3 r" k$ t
return sel;; l3 _' @2 z2 `, j# C) P }+ @
}2 h( V) F9 C8 u
# i3 R( ^* o. P4 S. F public static Selector getSelector(Object obj, String method) {
: h3 D* h! @6 L Selector sel;
, F F( e3 c4 J& j3 s. ~. @ try {* c/ q" H& C* a' U; K8 l
sel = new Selector(obj.getClass(), method, false); W# R& t& O6 b0 z+ y Z7 {
} catch (Exception e) {
8 G3 n# H) O. A3 S0 j/ G0 p System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 f% {/ A6 Z; Q' X. {- C% l E + (obj.getClass()).getName() + ".");! `% Q! [- Y9 i( r7 e. B2 Z! m2 o
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());7 o* u' R6 f3 T t
System.err.println("The process will be terminated.");
6 W5 u7 X% c4 V System.exit(1);" p, ] N0 e0 q! A
return null;2 x/ Z- `9 K9 h+ D2 Q. r9 v2 i
}
( U$ @% M. F2 b4 ~4 y+ C' P return sel;: l- D; J: l S% i
}
9 N! M7 I9 _9 Z m1 h% T( x} |