import swarm.Selector;
) Z8 M. E* y4 ~" _" X; ~+ J [
public class SwarmUtils {
4 l8 ~1 T! P" l8 }: q public static Selector getSelector(String name, String method) {* q, A; C/ S9 E& }
Selector sel;/ U8 m/ X4 X" B3 l! j/ d. q
try {) I0 N; J5 j1 m9 n! F
sel = new Selector(Class.forName(name), method, false);; u' c* c+ T8 j% R& H
} catch (Exception e) {
7 }9 S2 ]& _' T1 M$ n System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 {, A/ {7 \) T* i' v. T System.err.println(name + "." + method + " returns " + e.getMessage());
7 Y" d) y: z* _5 h( m7 R System.err.println("The process will be terminated.");
- Y! G2 K+ v, L. F% @ System.exit(1);
; F: g2 j I2 T" l2 V W return null;
2 u. g& ~ q- H* O% p3 U6 o }
a, T2 _& v0 Z7 U; @" _9 P return sel;+ h# M; i2 w2 b, q# D
}
) A( a6 a7 ?! \( n! Z, x3 D4 S1 r1 C3 L1 Q: ]- {0 r& V# d
public static Selector getSelector(Object obj, String method) {
, E8 R4 I& o) J4 t* F; f0 ] Selector sel;( v8 s4 f1 b& Q+ Y, O, E- l
try {
4 h" A; b z* S2 E- u sel = new Selector(obj.getClass(), method, false);4 ` y1 V7 N" Y5 O3 F
} catch (Exception e) {
+ p- m% x6 S% M6 I: u6 g9 \) \! M" q System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "9 B; Y) k4 M% d0 H# y& r
+ (obj.getClass()).getName() + ".");
' L: @% k$ q. Z8 q* R3 X$ L" n System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& M' x: p- Q3 B- |( r5 D! ]/ m System.err.println("The process will be terminated.");
$ `: C# ~7 ]$ m+ S$ ? System.exit(1);
' O$ v: M, F6 h8 b0 R return null;
8 W% I- q& Q4 R } _1 r" r& @5 X7 _3 a* @/ i
return sel;
y3 a" }; E7 V7 E }
) Q0 t: T4 ~4 }9 ^7 g/ O R} |