import swarm.Selector;6 ?) T+ o& E! g6 i
( B* U: W: u) ~7 t1 f5 ?( K3 opublic class SwarmUtils {
0 o( _7 v% a8 O6 H c! r public static Selector getSelector(String name, String method) {
/ t& a$ X/ Q* _' z3 H Selector sel;% I6 N- W8 l1 @1 ]6 R- L2 K7 s j' d
try { c3 U4 \) V" _% g& U
sel = new Selector(Class.forName(name), method, false);
' {+ ^& W* _* } } catch (Exception e) {
2 ~, [6 P7 b- }" U& r0 u System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
0 A; b0 O) o& B0 _: O% t* q System.err.println(name + "." + method + " returns " + e.getMessage());
: G5 U, d3 u. }- I System.err.println("The process will be terminated.");
3 h) g- ]8 x/ c! p9 e; [ System.exit(1);
7 v. @" z/ a, A9 g return null;2 j; R9 w1 J- T0 u% W) F; `
}
% W1 z- T) P8 {& ]; O. g4 p. b" O return sel;
; e2 a- c% M I) ^+ b4 i4 a }9 {- ]7 H7 F0 a! @# k9 g
# G: |6 o$ d5 K ~0 d; v) z3 ~" O public static Selector getSelector(Object obj, String method) {% J+ [) Q7 m4 }0 U
Selector sel;
9 y: e1 v1 {$ o: [8 z* B% y try {
" `/ ^3 {9 p$ @! r! x sel = new Selector(obj.getClass(), method, false);
" ~& H2 E5 y I } catch (Exception e) {
# d8 J) u9 Q1 w& r System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
# z( d8 h. P' `) q + (obj.getClass()).getName() + ".");: ~6 f8 l: x- p5 ^; }- s: c
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());- t5 ?2 n/ n' |( g' e3 j$ A
System.err.println("The process will be terminated.");
! \+ \+ W/ |" h7 d8 q System.exit(1);
9 S8 ~& H y. `- r return null;
7 w% n# Z* `+ o G/ r }% t$ R3 x6 H; _4 l5 T( Q7 {: Q$ C- ^
return sel;
3 `7 X6 k( R1 U3 I }
: @+ s% M: u3 D1 h2 h- H' j} |