import swarm.Selector;- D+ W/ c% R f3 _! V: t- ?
1 ?' L" j; O% b$ U \3 upublic class SwarmUtils {& J2 b0 ]7 R7 i" E/ @7 F' k' ~1 B
public static Selector getSelector(String name, String method) {5 D Y- D: M8 x2 N$ |. }
Selector sel;( r; i! Y& Q& C3 [6 a
try {$ ]3 a: Y$ R7 B/ E6 I
sel = new Selector(Class.forName(name), method, false);0 G* y: u# m7 r# w$ e
} catch (Exception e) {
6 a" o+ }1 q7 h9 [7 J6 j# v% V System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");2 V" l) \7 b' s3 d8 W
System.err.println(name + "." + method + " returns " + e.getMessage());
+ P' n: K t4 [$ H7 f& Q4 Y# q System.err.println("The process will be terminated.");
) {! u" g h5 Q/ R! R' K System.exit(1);) Y, y& ~& m/ c. g& [8 ^: B7 U
return null;
; _$ b/ H0 ^* F; i- n" `% A1 V4 J }
; A( A' g- M8 c return sel;! q4 x4 K) e3 A" ?& d6 y& J
}
7 }' M& W" O3 t! O" G3 a
( S4 V/ h: D1 j& N+ C; B; K public static Selector getSelector(Object obj, String method) {
; T8 u* E Y: d9 D' [3 T3 ^ Selector sel;) t3 I) `% q/ a3 N5 v6 N1 ~
try {- K6 f8 d* O/ @5 X
sel = new Selector(obj.getClass(), method, false);
+ W" ]+ |2 ]" d. p6 P3 C } catch (Exception e) {
T; h: f. G& [) C System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "6 b' ]3 L! B8 A# X& |
+ (obj.getClass()).getName() + ".");2 D5 R. G. U6 l" r
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 j Z& ^0 v7 z$ d0 [) ^. x; H. d' c
System.err.println("The process will be terminated.");
. ]9 H( O" _6 y) I0 D System.exit(1);
T; j: c4 z2 B return null; q+ a7 W: W& W$ G6 Z+ v
}6 H3 K6 R" [- `3 A& }$ E. N
return sel;/ _6 c' z( l4 D6 Y
}8 F, I- p T1 H4 E. e
} |