import swarm.Selector;
+ [/ J) h1 I' b6 G( w4 b3 R
! l' V; r; b- U7 A' a# tpublic class SwarmUtils {+ [# V. Z; W* Q Y5 x8 m% t' }
public static Selector getSelector(String name, String method) {# w4 v' g0 P( Y$ N7 S7 h& f: W
Selector sel;
( d' J& [3 {& f) e. u/ l T try {) b+ Y6 M0 {# N z" w- ?( u9 I
sel = new Selector(Class.forName(name), method, false);
% w9 k3 L7 X7 Q; }: A" r& f# o4 m8 R H } catch (Exception e) {5 ~/ U" o+ a6 w, V7 X. C
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");/ g) ?1 e' G& }
System.err.println(name + "." + method + " returns " + e.getMessage());
3 _) A3 O# z( M System.err.println("The process will be terminated.");
; n+ n$ p/ u/ B+ Z; d. `* v System.exit(1);
4 H) u3 x+ b$ ?( W: E# i return null;
, N4 G; ~* u" ]8 K+ q% h/ { }" C( n6 o4 O; J6 P
return sel;3 _) V8 r7 m( p/ b+ n
}
2 o) @ m2 @8 a1 E& M# X% Z1 i; E) b* I5 D
public static Selector getSelector(Object obj, String method) {* s X5 k! N/ }6 R
Selector sel;' u4 j$ z, k- ^+ T
try {
; Q: Y. @- v( a5 X6 B sel = new Selector(obj.getClass(), method, false);
( e9 I# g+ p: i% W8 E( O$ i) K } catch (Exception e) {
9 ^6 r0 S+ t# f ` System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "2 ?1 B3 T* L0 j! Z2 |
+ (obj.getClass()).getName() + ".");0 f: ^' U) n, n+ i
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());0 c( D, q9 d# q" R- O- M
System.err.println("The process will be terminated.");
9 ~9 X( ^( H% e* z System.exit(1);5 a6 v& v4 C/ _0 I
return null;# w9 X ^% \& i: p9 ^
}$ s+ q( R7 X* x4 @0 S- F
return sel;
$ K' U5 ]# j. ^2 u }$ f( ~ j8 Y* y+ z, o
} |