import swarm.Selector;
( Z5 I2 m$ D0 A6 G1 A4 L7 _4 V& L" Q; I: f7 y
public class SwarmUtils {
b9 _4 X- g P, L3 e9 ^. M- V2 q, ? public static Selector getSelector(String name, String method) {2 v# A) H9 K; |: q' I
Selector sel;& f1 A7 x: Q3 }: x
try {
( a" R+ h/ k9 ] p sel = new Selector(Class.forName(name), method, false);
: o T8 H$ H) _ A' \/ A" m } catch (Exception e) {
; M& V" {+ o1 s1 u3 I: W( A System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
3 F4 T' A. g9 }( ? u System.err.println(name + "." + method + " returns " + e.getMessage());
: i- p- m# p5 z8 r* o; Z% l( q System.err.println("The process will be terminated.");
5 E' K& j' P3 A/ m4 `: H8 q System.exit(1);. L( ~" a4 Y* F$ w2 G
return null;- Z7 }' T+ m3 C3 Y
}! I: B2 Q$ F- P Q( n# F, D
return sel;# E3 s- |' |& e9 D, r* L: J
}
O, G M, q8 {" b: m4 P4 }" j4 @8 {
3 b. b7 Y: V) u7 y Y" K public static Selector getSelector(Object obj, String method) {
" q3 ?. Z1 S3 J+ `) i. } Selector sel;2 D4 Z+ E! [) V* s, X
try { _( O# `# Z: Y4 F6 t- `
sel = new Selector(obj.getClass(), method, false);6 J0 B% R9 L% U8 v; V
} catch (Exception e) {
1 x8 X4 u8 m. d! P, P# _) { B! `1 j; E System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "! [$ @$ [5 O9 ]% Y$ Y
+ (obj.getClass()).getName() + ".");# E9 a* K- v* z5 ]3 f: b. I, h
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
) o" R# c8 u" Z% O3 t4 v, G& I8 I System.err.println("The process will be terminated.");
% I' W5 a0 ^' u* _ System.exit(1);7 T" {3 S3 {) { a! o! X- Q
return null;% B0 m: Q$ w/ Q2 d! A9 ]! |
}4 S S9 [4 f6 F( J4 w
return sel;+ r/ r* A8 s5 L' Q, D2 c
}7 q( B( J5 N. }$ b: A* F' G! m4 ~ `
} |