import swarm.Selector;! ?" W K9 {; n' k7 G
q6 O; g! H# ]$ [1 P7 y9 Tpublic class SwarmUtils {
- o7 ~- u, G c1 [' C% [6 o) ? public static Selector getSelector(String name, String method) {% t& q8 ?0 ] W$ Z1 l
Selector sel;
6 Q7 p O5 n. q$ E6 H: A! | try {
( s2 U4 w; {7 m1 z sel = new Selector(Class.forName(name), method, false);6 Q4 ?) e" R1 S, d* o* O: O. K8 v
} catch (Exception e) {; j1 w" ~; _. | X- f( Q4 a
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
O1 q, a; I. e* Q System.err.println(name + "." + method + " returns " + e.getMessage());6 \. h: F- c8 s1 Y9 p& y
System.err.println("The process will be terminated.");. a2 D4 ?- `/ p2 R6 B; X+ r" i
System.exit(1);0 y7 L0 f5 a4 f5 h) @
return null;
6 r8 |* S& [0 m$ |. s7 x, |& s }/ f. ~; g4 z0 U' L9 K. i
return sel;
- A# I) d6 n/ e/ ~5 Y }
' U+ a* r, e4 i0 q- g9 T2 `2 s& g: q" t( }
public static Selector getSelector(Object obj, String method) {2 N; u2 w4 H7 v/ o, Q. I
Selector sel;
5 T7 }4 p9 P5 e. a& _4 v- V try {. g1 K' i% T6 q1 U O9 ^+ s% i9 K, W
sel = new Selector(obj.getClass(), method, false);) E7 G: k6 d5 ]: c$ ^
} catch (Exception e) {
7 F/ k! L2 A! b7 ^$ ~ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
6 O5 z, R+ s; \7 T/ v7 Q + (obj.getClass()).getName() + ".");" r5 P# A5 S0 j& J; g; W0 p
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
4 z+ _. a' @* d; v# g+ G System.err.println("The process will be terminated.");/ f1 o' w" V+ [6 L% B
System.exit(1);" i A) ~6 ^+ J) Z! ?# ^# V' U/ t
return null;
* o5 s H1 [+ e: u5 g, Z2 b. j }
+ A0 @% v4 C# f! e6 y0 C( C9 w. m return sel;9 v' R$ n& y- w8 N0 z
}
% T4 ~6 _! L8 L' {3 | |- |# R} |