import swarm.Selector;
5 T9 n% w& d# c2 j3 W, d# j( v' \) A( B% V8 w4 g9 Q" V
public class SwarmUtils {! k) U! N% s0 |
public static Selector getSelector(String name, String method) {
# W+ e' c8 }- `- N6 N4 A0 i; y Selector sel;
; m9 A( ]$ ?* B X c try {
- z9 {% G( Q# B: J1 c sel = new Selector(Class.forName(name), method, false);% y d# j% `* Q. R3 u/ [
} catch (Exception e) {
0 F) {0 o' i$ W @ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 Z `8 A* v/ d. w System.err.println(name + "." + method + " returns " + e.getMessage());( p+ E, Z, c2 y# R: D: c
System.err.println("The process will be terminated.");
' v& P8 T7 t% U. _2 b System.exit(1);: e2 ^9 ?& o$ R/ G- r% a
return null;
" O" C* |% ], a; _% } }# H0 ]: C" ^; v/ O/ o4 h7 r) x2 f
return sel;
% z8 K h. }. A; ] }
* h# h9 v6 F! m# H/ f+ d/ E! z8 `6 d `9 k
public static Selector getSelector(Object obj, String method) {
0 K! r4 S) k+ z5 X Selector sel; h9 f* x% I. W# r$ \
try {
) _/ k( k l% G* [ sel = new Selector(obj.getClass(), method, false);- e8 {0 K- v) T. m+ v0 x
} catch (Exception e) {
: @# A! G% g5 V) C8 | System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 \7 {! `% I% o/ Y% b) t2 z$ c + (obj.getClass()).getName() + ".");
u& U5 d4 \8 `( ?/ H2 E System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ c- a+ T! O) s: G System.err.println("The process will be terminated.");1 H3 {) W, @- D% D
System.exit(1);
& B/ ?% W. Q- |# Z. l+ L return null;
/ o5 z: R* Y S$ I% E$ J7 p. v }8 i n2 Q2 ^6 d6 g8 M
return sel;2 y* m0 V) |+ O. r. f% ]$ ?
}
3 _, k$ \* y% m4 t, @} |