import swarm.Selector;& }- I, `( y+ l; {6 ^2 @* I8 t0 Q
4 o0 w% T3 G+ \" s& b
public class SwarmUtils {' ^- ^+ R/ D h. d
public static Selector getSelector(String name, String method) {6 y/ D. r+ g" R8 F1 W7 }' h- H
Selector sel;
S; q. A' ]: h0 c try {
6 S( @! ?0 c: v* [" M( z sel = new Selector(Class.forName(name), method, false);9 k5 b" t4 R A" ?) b+ }
} catch (Exception e) {/ h1 [& q9 e1 t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 y0 \: }- X0 \, [ System.err.println(name + "." + method + " returns " + e.getMessage());
1 g' f+ @9 g# S/ j6 m% L4 [ System.err.println("The process will be terminated.");
1 e1 R7 _. s# x System.exit(1);
! R$ S5 [* G( U! e4 H9 L return null;
' {5 B) i2 P2 J% k6 A! n- h }( ~0 h& E3 |! B0 N3 u: X* t
return sel;" ~ p! Z9 H: C4 H5 x# V& n1 ]$ ?" r
}
* K# L! N) _- }# q+ M* u1 R/ v8 x: G" `2 ]' B
public static Selector getSelector(Object obj, String method) {
2 |# i: h' y# `8 `9 R% J! Q8 @5 } Selector sel;
$ u; E% y4 O: w" y) q try {
: G# F" m& f' n sel = new Selector(obj.getClass(), method, false);2 t: u/ i8 ^5 M$ P
} catch (Exception e) {, X- [* G* B8 E4 y! c6 L8 w8 }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "" _/ \$ K" a. @4 D* f" t7 K$ n: f8 h
+ (obj.getClass()).getName() + ".");
! t& O, ]+ `! z0 M. r$ u System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
% d+ u9 r- ] ~: I6 B/ Y" Z System.err.println("The process will be terminated.");; {0 ]3 F0 f/ @0 y
System.exit(1);8 b+ [- s7 l) j& W7 }: G. k
return null;
( f( s* f8 |1 Y& a' p( {6 i }' V" v! y# }2 D8 t- ?" {5 H$ y
return sel;( d6 {4 `2 X% @. ?- C
}( J' ^2 |1 ^9 N" b' M
} |