import swarm.Selector;+ G/ Z) `6 f# e
8 N+ e7 Z" g: g. Q- Bpublic class SwarmUtils {4 u0 J: c1 P& i' A
public static Selector getSelector(String name, String method) {
) p; i$ L8 A# O. z* G* i Selector sel;
+ b' Z. s9 a4 K- V5 ?+ H! h. Q try {% r! X3 v* H& V9 d$ ^+ H! C
sel = new Selector(Class.forName(name), method, false);
5 ~( v7 M! n. g9 F6 \4 s, x( k } catch (Exception e) {3 s8 r) o5 X. o, N0 Z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
; P- I4 F `2 ]9 H1 S System.err.println(name + "." + method + " returns " + e.getMessage());4 ?0 A0 ^2 E. e
System.err.println("The process will be terminated.");& z: O" Y" m6 s4 E2 m
System.exit(1);
6 m8 t) \1 H% ]) } return null;' C. p7 q; A: [) c+ P+ ^
}
( H5 B. {5 G' U% ]- Z return sel;* G/ |; u8 N4 Z/ d3 J: `
}3 e5 {* ?$ u# j* t1 ]" j
; B6 e) g# L" { W! z public static Selector getSelector(Object obj, String method) {
) |& Q9 Z! \0 c/ H) f. j Selector sel;
. v1 C. [+ | I4 h( j try {
* M7 B, j! S4 I- Z9 U3 S sel = new Selector(obj.getClass(), method, false);4 B9 V* h/ I7 A* X
} catch (Exception e) {% V8 s9 \6 I5 e# v3 D* L6 S: O# t% K, {
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ". b* J2 d% h7 p" ~" E
+ (obj.getClass()).getName() + ".");: {6 Y P8 v! |- Y! S
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());, s% l9 b3 `# i6 o9 k1 `
System.err.println("The process will be terminated.");# T& Y8 W. z( q; V6 a* N: b6 X
System.exit(1); k& p/ l- k# T9 x' T
return null;
: ?( `- ]& N8 D9 y4 X }6 S& b& ?' D$ h' G/ [3 z8 l
return sel;8 ^7 ~6 j9 v$ |2 C& r! H3 V/ ^- Z2 t6 G: w
}4 e/ l6 e* M0 k! s6 t' e9 [' I2 c- y) G
} |