import swarm.Selector;
3 E. `; D! v2 ?! v' h4 a
; |! i9 ]( x% Z4 }public class SwarmUtils {4 I0 X7 @+ k5 t/ M, X
public static Selector getSelector(String name, String method) {
0 W) Q: Q, f6 n3 J: }5 h( A Selector sel;7 Y4 w& t5 v' C- @# Z
try {0 V5 a4 k( c% _, }
sel = new Selector(Class.forName(name), method, false);1 e; y. O/ m% J- B4 l6 Q
} catch (Exception e) {
6 k4 u6 }: i9 B System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
I. t, C3 b8 Y System.err.println(name + "." + method + " returns " + e.getMessage());
1 @* m/ O2 O" \; ?# T/ M# n System.err.println("The process will be terminated.");
D$ }: d3 q+ b' k+ m" A System.exit(1);. C; a1 N5 L6 y5 S; f
return null;
4 t" b& |2 {8 Z5 r# d Q! [. b } A( p, b! d0 i3 Q5 `- w
return sel;0 C) j* p, m( u& B1 h9 V6 }
}' O6 O1 ]6 u4 F
' g ?1 A2 C* |1 g public static Selector getSelector(Object obj, String method) {) X) `" _$ o" w# j( U2 |9 j
Selector sel;
" u2 d' b' s) v try {
, Y% ?3 P5 Y8 |/ h; X sel = new Selector(obj.getClass(), method, false);
' C8 J8 N' O: z; c2 y5 Q p9 p' [ } catch (Exception e) {
7 V6 Q' P0 l2 f4 u5 w) Y4 _ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "/ h8 L G6 Z6 z& n9 c! P' N o
+ (obj.getClass()).getName() + ".");
; M$ x% ~# I/ ?3 ] System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
- X$ _" g0 @$ q& M( x' Y System.err.println("The process will be terminated.");; e$ c& k/ b+ j) m4 X
System.exit(1);
j% g: f1 h9 c& I8 ~' V return null;
* I. a) N2 E" l% y- O' C: S }, z1 ?. M: @; B. {! P& t9 h9 s) w n* w
return sel;; x4 |2 w6 e" n+ M
}
- h7 E7 X$ }. s" U6 V2 Q} |