import swarm.Selector;
( C3 c4 h: u% C4 M1 _( V" c& } S& N, e9 |, {& Y# u" ^2 [
public class SwarmUtils {- A/ f6 P7 j$ f4 J* A
public static Selector getSelector(String name, String method) {( \1 }: \& Z; P+ f% ^2 V$ j+ }% o3 n
Selector sel;
- d! |$ h" K" P: C! \( E } try {- C4 Y5 m, I" J9 w
sel = new Selector(Class.forName(name), method, false);
$ U$ g4 q: C9 n( `6 |9 a } catch (Exception e) {
% ]; ]6 R8 r8 L4 L, b6 p6 a System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 J1 D: \: W- b, { System.err.println(name + "." + method + " returns " + e.getMessage());' J* F* M: G8 e3 L$ M; V) y
System.err.println("The process will be terminated.");0 ^! W4 ~0 n: A9 E
System.exit(1);
- u, \! t" i7 a1 p& A+ Y) g) W return null;( I5 t" r) [6 u# o- A0 l: G
}
% J5 S8 M2 V& Z. [" O3 m* z N return sel;, U' E* M. A0 `2 h! Z& {- S
}# ~" y1 y, t+ l0 K0 R
3 T9 L3 e# A4 ]. e; j; p/ V* g
public static Selector getSelector(Object obj, String method) {6 O. F5 {8 [! F6 F& w+ l7 h
Selector sel;
`5 x5 i8 i0 a( s4 A8 x try {
' w- q* I' `; Z9 `( f% S. d0 G( R# c sel = new Selector(obj.getClass(), method, false);: X$ U% h) f6 V+ V' N) T* b
} catch (Exception e) {' J8 v6 B" m8 I' r* J7 o9 @4 S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 \ l+ Q$ g" D# T+ d2 l + (obj.getClass()).getName() + ".");
1 F) }9 \* J3 d System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());( k# U6 w& Z$ z" y- g" T1 r' O( }
System.err.println("The process will be terminated.");7 P- I+ S9 e# C" a+ {0 F8 O
System.exit(1);. O4 G- t1 P0 h% I* a9 J, A3 v0 s: w
return null;
, E x8 H- b7 f }( F+ U& }1 N& V8 G7 ~3 c6 f( F
return sel;
( e( t: `: D4 W: G) f( E: \5 x3 E }
: t3 u0 x6 U) L+ J# Y" v} |