import swarm.Selector;
; ]: w' Q9 J# c- g( R: B# `- w8 b5 i0 }$ O8 Q4 W! I K( a% n; A
public class SwarmUtils {5 L( [- N0 K/ J0 @* H( E" v
public static Selector getSelector(String name, String method) {
& {0 q, p, l1 v' ] F$ B) p# Y6 v* [ Selector sel;2 V/ R) B( F: Y" i! p
try {; D6 u+ {% R( P( i: p, G: `: `
sel = new Selector(Class.forName(name), method, false); @" `" l& J7 T0 P8 d; T
} catch (Exception e) {/ s7 `, N& P3 p( e$ o/ B& `0 _) t+ q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");7 s3 Q8 ?4 s4 q- P& R
System.err.println(name + "." + method + " returns " + e.getMessage());
7 S1 D8 f: J8 H+ z& A1 \' q2 } System.err.println("The process will be terminated.");" |0 c+ m0 h( L( v' B9 [0 L+ B9 `
System.exit(1);2 W0 g, I* F: B8 _7 A4 [
return null;% D/ h- b1 F0 m' n L- v% W0 B+ S
}
1 N* c+ g) v3 f1 l return sel;
9 l" O# F9 |( ?# c2 N }, B) ^% C7 D4 ?
- p6 z' s0 Q8 K7 b* x. U
public static Selector getSelector(Object obj, String method) {
/ q Z" d7 O4 j& c) P. x2 H) P7 z Selector sel;
) @- b s. B% _# x, I% K try {1 {* Z# t3 p0 ]- I% S1 q
sel = new Selector(obj.getClass(), method, false);
. m9 E) s3 ?: g- ?) k3 U! q } catch (Exception e) {
7 d) R+ `( [+ R% `" R" | System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "$ C7 @. | }/ |1 ]& E
+ (obj.getClass()).getName() + ".");" K ?" H2 q$ M" }2 @3 }' P0 Q
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
9 j! _. q0 R6 y) Q0 U8 T System.err.println("The process will be terminated.");
" c5 K( z7 Y% G, Z System.exit(1);8 A% ^2 ~5 h: ^/ U& k
return null;7 G3 u) `+ B5 l2 [# g' L* d0 d1 {
}
$ x0 S) q% q: m. Z$ b9 Q/ ]2 V return sel;
$ L7 b9 B6 T' Q$ `2 g6 y }
- a/ c1 I, o; I2 M& Y8 d u} |