import swarm.Selector;9 b5 s+ k3 S6 l- b8 ^
r6 _, W* @5 |public class SwarmUtils {# ~" t2 D- m1 O
public static Selector getSelector(String name, String method) {
3 B& T! K _* d- A7 }7 F" J Selector sel;
- Y' i: y( K7 O- e$ E try {
9 u5 t6 K) w9 ~$ }- E sel = new Selector(Class.forName(name), method, false); `2 }' R8 @ O+ }7 N6 s
} catch (Exception e) {
6 A& E( }" W4 e System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( I. [' e, e: v
System.err.println(name + "." + method + " returns " + e.getMessage());
4 Q8 t, V0 x+ V% a System.err.println("The process will be terminated.");
* j; v2 M" ~6 g& f2 M7 ]/ T System.exit(1);9 {1 D( P2 C( ~# r
return null;) g9 n+ }9 h- G0 G+ k$ q
}
) ?5 N' h6 t- @1 F1 Q5 K% @. H7 m return sel;
. ^2 p- B, Q# r8 k }1 m# Z) ]0 e5 ~" H
7 O" J8 |% S5 K! k5 u
public static Selector getSelector(Object obj, String method) {' h' l" O/ P; q2 Z4 j/ Y
Selector sel;) E w( n6 X. b8 Y' v
try {
/ j5 s0 T+ x9 ]( `* w8 W; s+ W sel = new Selector(obj.getClass(), method, false);& b1 M) d7 e+ B2 C
} catch (Exception e) {
) g* F# o4 J7 n' J: [% z# F System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "* R& ]' d" _8 h5 F5 c. S
+ (obj.getClass()).getName() + ".");1 x( {: k% @. D
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
6 Z+ T8 ? h5 |+ k% Z" r. U System.err.println("The process will be terminated.");
4 t2 X% ^0 k: w8 C9 y) w3 m System.exit(1);
/ N [7 m& t! e1 ?/ ]$ L return null;
# D, G( U5 a7 e } S, n! T1 R9 ~+ Z2 T
return sel;
5 U) W' M! y# P9 K8 b, G }
* F) m' l9 L% ^6 R: n2 C; }} |