import swarm.Selector;4 t' D% n+ R- M- I2 n* l
4 k/ O$ _: @, T- P2 epublic class SwarmUtils {
+ |% W8 a! O1 c0 V5 o o2 ] public static Selector getSelector(String name, String method) {
5 u0 _: v6 C c {( D" [; h) v3 B Selector sel;
! {' \2 z- l! Y9 ~: Z; Y/ I try {
. D' c9 l7 K' b3 ^& f% f- x sel = new Selector(Class.forName(name), method, false);
2 Y2 ?; [3 G* U2 e$ T# [! O } catch (Exception e) {7 B. _' l: H) X0 u
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");/ j: x$ j- P m8 G
System.err.println(name + "." + method + " returns " + e.getMessage());
1 L7 D) ~- l) N7 X1 Z, u System.err.println("The process will be terminated.");8 @5 m. f q+ G; c0 W
System.exit(1);9 K$ E9 L+ }7 E" M
return null;- @1 D% S& l+ `) U, P9 ^4 ?" v5 D
}9 H8 B: u6 s8 Y& V
return sel;2 K9 a3 y( l* g& x; H) E+ G: i
}
8 |9 _# t* _+ T6 F
+ _) x1 Z4 w2 M( Q public static Selector getSelector(Object obj, String method) {: B; L' l2 Z+ m. T
Selector sel;
1 r; @# y9 M( G6 \7 ^4 J try {
0 K$ d2 V0 p2 ?* E8 f; l ] sel = new Selector(obj.getClass(), method, false);
. O) S% H1 o( ?( D2 O; i$ | } catch (Exception e) {( w7 V& @4 l; I! u* ]& C$ I6 M
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "4 [8 z) w7 E, [ R/ o% W+ Z! X
+ (obj.getClass()).getName() + ".");
3 x, w! N' I. t" m! z5 B) W System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());. Z+ R5 |0 |* d8 X$ h0 }
System.err.println("The process will be terminated.");
K4 j3 Q6 T8 N9 n System.exit(1);3 b4 p* |5 R; B8 B4 U% Y, G
return null;3 h: v2 {! @8 {' c: y3 l: T
}' P8 L( q! W' p" r
return sel;3 I; d5 Q \) n- i. M- E
}
$ V0 {: _$ l2 S+ W# m} |