import swarm.Selector;- |7 q, O8 P! t; F5 p% t
4 o7 ]( [$ S2 m# w- X3 k* B, K+ h# kpublic class SwarmUtils {# Z5 R6 A5 t8 |5 W0 |! E. |
public static Selector getSelector(String name, String method) {2 U4 e% G- f- }, s9 t
Selector sel;- V! R) g# [. B' l
try {
# E( m/ l( J" k3 r% c sel = new Selector(Class.forName(name), method, false);& \! a h6 s/ P% _8 c8 K8 @. E
} catch (Exception e) {3 ~3 @8 X' }4 J0 k- A! u$ ]9 ?
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");) R: M \, ^2 e
System.err.println(name + "." + method + " returns " + e.getMessage());+ l Q8 i4 C1 O# r7 t5 E
System.err.println("The process will be terminated.");! }7 b* T& k9 x3 Q, I- r
System.exit(1);- z# {6 O4 b; l4 `: w; d0 e
return null;8 R5 Y/ r3 n2 T* C' {
}- R- j! }5 J$ E# [. p! M5 E& T4 D
return sel;
& |. D/ M. o$ j+ r# ]8 a) K }0 _& J/ T3 n" m9 @
) \" N P9 e" U; ~3 u4 M public static Selector getSelector(Object obj, String method) {
% i. L( ]: D# \! q% s6 W3 ~ Selector sel;
2 g/ [4 q) O' t8 I. B2 [8 t try {) M. H a) ?8 L' B" G0 O6 s% d
sel = new Selector(obj.getClass(), method, false);% ?8 \6 c5 x1 c9 Q' x; x
} catch (Exception e) {
! R1 W$ d! y. W4 ` System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ") G, M& p4 Z) ^0 E" b
+ (obj.getClass()).getName() + ".");
7 C9 x; c0 j$ T K System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
! A/ v7 |. S. l4 W1 D* d System.err.println("The process will be terminated.");
' @: }9 Q3 D9 L System.exit(1);3 ?4 ?- i: C9 S/ ^' Z, Q" B' E
return null;
7 ^+ l5 `9 @( P: J( R }* c- k* W* r5 ]9 R2 o3 i
return sel;
. t @+ {. O' @8 p. O( S }: j" w, R) {8 ^7 L/ ?
} |