import swarm.Selector;6 ~$ J3 g- @5 A/ I; Q# r
* r& g3 c! v2 g" O1 G) Z! l+ Npublic class SwarmUtils {7 t7 p2 e6 _( `) m6 l
public static Selector getSelector(String name, String method) {) M$ h( ~3 ?. @2 e4 k0 I1 `
Selector sel;# `: {3 Y" l' l2 A
try {
& {- {* @7 x9 T0 h* t: {; | sel = new Selector(Class.forName(name), method, false);
- B( a. b# b( j } catch (Exception e) {% \- ?+ v, R7 ^7 i/ Z9 r5 t
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");3 r1 ~/ A' x5 T# A/ r
System.err.println(name + "." + method + " returns " + e.getMessage());# X! w( A: G: p
System.err.println("The process will be terminated.");
], ?3 M9 }) x5 s System.exit(1);3 e8 C0 v* z. Q9 e5 e) S) ]+ t
return null;
$ C: |5 z6 ~5 }" d5 X5 u }+ \! j9 A/ _# k+ d/ o' I9 L
return sel;
2 n& ~0 i7 ^; l8 x9 { }2 ?! V# h3 v V1 _3 R0 ?
( K% k$ e, i* _1 X" [! q5 H2 K
public static Selector getSelector(Object obj, String method) {
1 B4 `+ S7 Q6 I, l. ^6 |0 V3 j Selector sel;
2 d; [. g9 N+ h7 X; y! { try {+ X; e$ }$ L F. d; @
sel = new Selector(obj.getClass(), method, false);* n9 `8 b& \$ L
} catch (Exception e) {
) }7 y) |/ h& R5 X System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 w: k; S# O) k) _ + (obj.getClass()).getName() + ".");9 m# f# ~# W( q M! v) C* N
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());( Y- O( M" u$ k1 l+ b6 u
System.err.println("The process will be terminated.");
7 D. U1 R$ V( W6 j3 r System.exit(1);
5 |; D# w% I( d" D0 ~/ r return null;
$ _9 \ H `/ N. X' r }) X5 B: ?5 V. m8 k% n
return sel;$ n6 j8 w8 J% v+ E4 u
}
s& C k; T; q. m$ e} |