import swarm.Selector;
7 J+ b# \. ~, r! D1 j3 k
" r- ^' P: T% r* F5 r mpublic class SwarmUtils {- F6 A& M9 g, R! ]# X1 U* s
public static Selector getSelector(String name, String method) {
; X9 I& s& j- J2 D Selector sel;
: y! K, ?# m2 n& R( N$ z; e try {+ k; g6 J8 h: [
sel = new Selector(Class.forName(name), method, false);
2 ^' X4 B7 E( Q6 _) P9 t } catch (Exception e) { k! ~7 P! V( @
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");' u" U5 c" l& \- O! Z9 {/ n& B2 J& o. K
System.err.println(name + "." + method + " returns " + e.getMessage());. s9 B# n0 _+ o4 u1 Y5 x& c( b
System.err.println("The process will be terminated.");
* S9 X- H4 H* k x2 N W) b( p, u System.exit(1);
@+ U5 R" }3 ]7 N) Q+ l return null;( ]3 K5 x# m% f9 m% ^- J4 Z# o
}
) E) V# ^' h, H* S" H return sel;
: e; I5 p( A+ M# `: g: i2 z* H ?; C }
) b7 O! Z( o* m0 U- r% }
' [: H! Y. C( I8 a7 d7 U public static Selector getSelector(Object obj, String method) { R7 U4 _. z0 W0 k, `' r0 }
Selector sel;1 i0 \% g W( L
try {
Y3 a$ V. x4 R) O sel = new Selector(obj.getClass(), method, false);. W: P. l/ }* m$ C- b
} catch (Exception e) {
( L: s( m5 |; t1 t) d9 U5 x/ y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "1 Z/ F, h4 r8 a+ h; ~# F
+ (obj.getClass()).getName() + ".");
, g( L, d' h, x0 |9 ~, r System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
/ d" }1 g- ~: ]4 v5 c System.err.println("The process will be terminated.");
) N* ?) I) v! r- | System.exit(1);
1 D$ R1 [, P0 f) N( s- O/ ~! k return null;
0 ^0 o# L: k) P& m. H3 O }
3 f2 P9 |2 X* e( y% z return sel;( T N5 G+ G! ]; b
}; f+ M) v2 k; h5 y* h
} |