import swarm.Selector;
, r+ {2 u9 v* ?0 K; q1 s# y6 o3 X
/ z; g) D% {! m. s1 |, W& d Z5 D8 Epublic class SwarmUtils {
% l9 r p, |0 B) L+ w public static Selector getSelector(String name, String method) {- J) i, }; U L0 T* D' M
Selector sel;
+ L( X2 e. @1 X& e+ Y try {
& r3 R7 R1 c9 i) ^6 i) K$ y sel = new Selector(Class.forName(name), method, false);6 f5 t- j$ j2 v- G3 f5 F
} catch (Exception e) {
; b& [2 { w; u7 j. N System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");5 E) I" w! B: a ~9 s9 {* J- i
System.err.println(name + "." + method + " returns " + e.getMessage());/ H2 f7 \4 a/ h# I, R
System.err.println("The process will be terminated.");
5 P( U+ I( A1 \# Z$ ~ System.exit(1);
& ?3 w: _/ t$ }. l6 f' c3 P return null;; i6 n2 M: ?) y( ]# J5 \- {
}
, B' c/ l" ~8 t H8 b" ^7 G return sel;: B7 j1 t. N( ~' W" u2 v+ U; b" j- X
}# k6 w: V- S( z$ g: G% g
/ L. h7 I1 a C9 Q6 a0 R
public static Selector getSelector(Object obj, String method) {5 B( v+ |! H# A5 Z% _
Selector sel;
$ h* w% Z, e- C try {
# r9 ]6 O: l/ x% v7 T7 @9 u sel = new Selector(obj.getClass(), method, false);4 W$ r9 j& r8 T3 s2 Q/ {, O
} catch (Exception e) {
3 B: |9 o5 L9 r0 c% Z! u6 A1 X System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
- [4 r6 n1 Q E8 M# n8 w + (obj.getClass()).getName() + ".");
! z1 a, H, F3 }- D$ S5 b5 @4 _' Z System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());* C. V0 T: X& _+ }! p$ D
System.err.println("The process will be terminated.");0 U5 @2 v0 X. M' Y
System.exit(1);6 g6 I& p0 ^: X1 o. y0 B2 L# i/ j. d
return null;3 M: `3 W# p" s& Z H
}
0 i+ g8 @) G6 j% b8 S8 W! D! ] return sel;
! H, [5 \' {& b3 ~7 t7 T( n4 P }. C$ v; B q F; O
} |