import swarm.Selector;
+ v" T2 [5 |; H$ E; G+ H( L, K2 o+ r
. u" D4 a+ |2 X7 `1 a0 m/ cpublic class SwarmUtils {% k) `6 e# C) R: d0 b
public static Selector getSelector(String name, String method) {
3 C0 n6 h! c! S: Z% ~ Selector sel;
; @) d# o8 S2 r& l. Y try {
! E' C d) V3 K6 A- K* ]8 e sel = new Selector(Class.forName(name), method, false);- z' C% O& x, m( {2 k
} catch (Exception e) {) e J7 E+ g8 T+ B% d4 T- }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
% B% Z& o. Z& [7 J4 j3 Q% ~ System.err.println(name + "." + method + " returns " + e.getMessage());# e' Y G. I9 W N* `
System.err.println("The process will be terminated.");, g! _' b+ m2 M4 D8 x# W
System.exit(1);3 f1 W/ ^* h4 Y, c
return null;' U9 B: e5 \7 y: Q# c4 L: u- P
}3 v3 f `' J$ U3 b
return sel;
) w% e) r: o& V% j9 e }
. s9 P" r0 K: R$ a: E3 k# [+ u3 G: N; t3 M
public static Selector getSelector(Object obj, String method) {
& u4 q: r2 C9 R) o$ @ Selector sel;
$ i6 p+ q+ _. Y8 E/ M try {: @. v# }# v" h: ~# m
sel = new Selector(obj.getClass(), method, false);
) J$ g7 s# I; r* o5 | } catch (Exception e) {1 v) L; F: k' j8 d# L
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
0 j6 d+ j/ S8 W/ \ + (obj.getClass()).getName() + ".");2 p" [4 @, f) J4 H' F! {1 G
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());! t8 F/ X+ }/ m/ I4 i3 a9 a
System.err.println("The process will be terminated.");, i. d2 e( P4 t8 | }
System.exit(1);8 F) ~5 l5 `) m' h
return null;
+ O- [( D$ T! @# ?8 [6 W+ s }" n0 L+ W' w4 y: C! l6 ^) g
return sel;3 [/ i( J) W U: _( h+ ]
}
8 W7 v4 o6 H. S9 I( P} |