import swarm.Selector;8 {6 e- T5 |& x/ s* U3 z% ]
& h$ z; D% \( h" o- J; F
public class SwarmUtils {- n* o: P6 E; z
public static Selector getSelector(String name, String method) {
; d; W9 D) z2 a8 ^/ z. K+ a Selector sel;1 e6 g1 @# q# t! E
try {
; ~# z4 r7 P! I2 j+ n9 F sel = new Selector(Class.forName(name), method, false);3 T0 {1 d' {9 U
} catch (Exception e) {( v3 ]$ r! x/ u) _0 S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ d$ p1 x4 M6 E: L
System.err.println(name + "." + method + " returns " + e.getMessage());
9 |% ]' {' J+ @8 e! G7 \# E System.err.println("The process will be terminated.");
+ N# e# L0 o/ _) l System.exit(1);" L3 E; p$ {1 D+ A4 C$ G
return null;+ m# o0 k9 Y5 F9 G% K: q, K1 R
}8 P7 c( d# s+ @% A S
return sel;9 _( K# d, J$ o" @7 F
}
+ @6 ]& L9 Z# a# ~7 B9 ?
8 O% p4 T, J7 s! ?% f public static Selector getSelector(Object obj, String method) {
: e; Q9 B) X2 _% r4 Y3 C# k# O Selector sel; o3 c1 M! a# a0 H
try {' H; W5 S- M4 `6 u3 j' X( _# ^- i
sel = new Selector(obj.getClass(), method, false);; Z5 m( Q+ u3 p; |2 x- }- ~0 |
} catch (Exception e) {; Z; S6 k x& C
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
$ b: J- B7 l+ D + (obj.getClass()).getName() + ".");* w4 s7 o5 J) V% g- W
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 ?( E' d9 x, z$ d3 d' L( F, ~( X8 v
System.err.println("The process will be terminated.");
9 d) B8 w1 q) A$ I' d6 o+ F System.exit(1);
: `$ s. _/ m8 m; m8 ~ return null;
! @5 o- y2 l- k% |4 L' O }
6 v% p4 e$ N, D% [ return sel;- I) k( v; }. [
} W9 W! k. r" ^! {; t( Y
} |