import swarm.Selector;5 z! n8 K+ D( z2 q
( m& I( `3 n- Z# y" K. c5 `! Tpublic class SwarmUtils { m4 `6 q N/ @* f' q
public static Selector getSelector(String name, String method) {
. N: I9 } n/ q1 o3 L Selector sel;7 h b7 a: B: o+ q
try {" a8 g: m6 S) M3 Q$ y$ z
sel = new Selector(Class.forName(name), method, false);2 ~6 h3 U5 B$ o/ J# c3 h1 U. c, e
} catch (Exception e) {
' U( O- c: Y, a* U3 E. @ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
+ A, Y7 p& \; O System.err.println(name + "." + method + " returns " + e.getMessage());7 z }# r0 K7 v0 N( Z$ }
System.err.println("The process will be terminated.");: \) |7 m4 Z5 ?3 G
System.exit(1);8 u; c- x% p3 D0 y/ R; R
return null;
; b t. G& O7 U" x G }
' _4 e1 m- g% u3 i return sel;# O6 e5 k2 B: ]7 C- r" A
}4 i1 Z) e( h o0 K$ j6 _0 p
: @6 E1 y, }- p+ i, K, q7 P4 y
public static Selector getSelector(Object obj, String method) {
/ y4 W( h1 f6 @0 Q+ r Selector sel;1 O4 U! O) l v& P) U, T
try {
/ J; N, p( s1 \; K sel = new Selector(obj.getClass(), method, false); ?$ q: A7 ]" _
} catch (Exception e) {4 H2 a# X) ^9 c. p- _9 a
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 D6 q5 F, g- ~4 l- W; `( D% ? + (obj.getClass()).getName() + ".");
( X0 W4 @! z, E f9 [ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
- L/ Q" M k$ M) Q* W$ ^6 C. I: [ System.err.println("The process will be terminated.");$ B1 x V0 c, @% `8 R% }
System.exit(1);
, y+ K* ?! H, C+ W) R return null;
( l8 t: C1 P V/ V$ w }
e0 S+ o, o: { return sel;
' N, @8 }. s# K7 ` P4 ^ }
% O& o' M# g8 u- S g# g( m7 I} |