import swarm.Selector;* d: Y$ `4 D; Y0 P
/ b8 [$ s2 e" ~: L9 k: rpublic class SwarmUtils {
- [" d5 w* H& f5 O! ]. A$ r0 E2 K public static Selector getSelector(String name, String method) {
. x; Y9 g$ t$ r- i5 |* g' Q1 D6 ` Selector sel; t% s& H1 ^1 z1 v
try {
- x6 A" ?+ R' ^, B( U' Y6 q sel = new Selector(Class.forName(name), method, false);2 o! o( j; J: g6 `9 A: \
} catch (Exception e) {
. A( A0 g0 W1 H3 F System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; J/ Y3 Y# `, z
System.err.println(name + "." + method + " returns " + e.getMessage());
6 V& d1 H# y. } System.err.println("The process will be terminated.");8 k# Y" s& C+ M3 D! z1 i0 m: j" o3 B
System.exit(1);
2 D) Y1 v9 D+ U R8 N return null;
# C' ~8 C/ ]) D& N+ Y }
# O9 c( I p2 V% | return sel;( ^3 r7 `7 V( |
}" T5 Y; l& j* T, D0 e) A& v9 h
/ l" I# X$ _8 k q+ _4 ` public static Selector getSelector(Object obj, String method) {" F& j4 d) [/ }7 C! z
Selector sel;
3 N6 [! u0 q2 O' P3 V try {* K; i# r7 p( d/ b# I
sel = new Selector(obj.getClass(), method, false);! O2 d0 n' K6 N* v; c
} catch (Exception e) {
2 M! _" [) }+ F7 b7 k System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "' n& Q7 s& I- _7 I+ C
+ (obj.getClass()).getName() + ".");. A7 B+ s2 D. E9 u
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
1 n! e' g4 C# @* Z* u System.err.println("The process will be terminated.");! i- R# @5 S4 R% \3 x
System.exit(1);+ s/ d( q1 d3 X
return null;
5 y. S Z5 u @. d }
' X1 q; z8 _9 X$ O3 r return sel;
! j/ [0 \1 \/ F8 I7 S6 U3 n& ^ }
: i/ ~& }* W6 Y1 s, W( S. h3 N} |