import swarm.Selector; @7 T: k) h: o$ Z" U
9 C; J8 i, J2 o, M p R: C( Ppublic class SwarmUtils {
& k- F/ Z% z f4 ~7 M" j public static Selector getSelector(String name, String method) {
+ M5 D# b6 s2 ^! ~& N Selector sel;
! f$ F% o- c) x% K8 R# D @ try {
1 d3 L% ^9 V! l( t sel = new Selector(Class.forName(name), method, false);
' {* y7 C# j2 a% @7 k6 I } catch (Exception e) {
% h* O" T+ {, p4 v) Z7 y0 `- U U: A System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
! p9 E, _1 ]+ d* m7 U% o5 j System.err.println(name + "." + method + " returns " + e.getMessage());
: L. S" R# ~6 V5 g) h2 q System.err.println("The process will be terminated.");
- z U* a+ U2 a$ P4 a System.exit(1);' ?" q" n% ?' m) f& o A7 M1 k
return null;
% P1 V: X# H# l9 U5 z }
" G6 P! A% s& z: _& B return sel;
, x ?2 F# f. A/ |2 N }4 t+ a3 ~" C- B
; H0 E! H( t+ Z. |
public static Selector getSelector(Object obj, String method) {, v9 d' a+ H! y, C
Selector sel;0 w" t7 v! F& ]& h5 D
try {3 Y/ F! j. Z. r& X( {0 \( `- S% A
sel = new Selector(obj.getClass(), method, false);
) W9 c. P+ _. f5 D } catch (Exception e) {5 T. R9 v- _$ J/ K- d
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
) v6 @7 D5 R9 g" I0 E + (obj.getClass()).getName() + ".");" f2 U6 y& O" F6 @+ g5 o
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());- M/ P2 M; i+ ?2 t
System.err.println("The process will be terminated.");1 Z9 ?! |/ R+ n+ T
System.exit(1);8 k3 i( a/ I& L
return null;9 G0 q7 a! h, ~3 M+ R
}
, L2 x5 H6 L) P return sel;
' U) `3 t: i# ~# K) q! G, C }7 e- l& Y1 N( W7 z+ d* A
} |