import swarm.Selector;
# K7 a$ L( S; y5 H9 }
8 Z( Q. @4 U" L, d' N& ?$ v4 rpublic class SwarmUtils {! `% A s' S- t2 t6 k
public static Selector getSelector(String name, String method) {+ T+ e; j" L, H# f& X8 E
Selector sel;8 l* l. U) y. y
try {
- Z9 |( N; R* a; D* `& x; |9 ^ sel = new Selector(Class.forName(name), method, false);* C0 P3 r3 s: l! t8 ^! P) f7 P" { w/ M
} catch (Exception e) {6 l; g2 z3 Y5 ^ R
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ v0 a: k1 k, p+ L, K: o& R) b& R( N
System.err.println(name + "." + method + " returns " + e.getMessage());
, a9 g7 [' w: W# {1 J) A! q System.err.println("The process will be terminated.");0 f6 B3 |, |# `0 t, E% _
System.exit(1);2 A2 O# Q8 i5 O
return null;6 X$ u% B+ S) c( v% g
}1 U9 ^. S% c8 G: |) m
return sel;4 ]/ n! ?! Q: G9 p8 U1 R. k) n5 t
}
5 v; J w5 C4 I
6 {3 M" c" N2 v( o1 { P1 y public static Selector getSelector(Object obj, String method) {2 c* s! k6 c8 Y" ~0 j
Selector sel;
/ |9 B$ H" E: S2 H+ q try {
& `4 \6 U+ i/ g7 X! j& n sel = new Selector(obj.getClass(), method, false);
+ O Q' d2 C7 Z6 m3 w9 k/ ]9 ` } catch (Exception e) {+ j$ u0 {# a( A2 @& J6 O& D
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
$ W3 `6 y- l8 h( a: O/ T1 J + (obj.getClass()).getName() + ".");
( X, e; s9 G J# ], | System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());" @* r1 O8 W# S
System.err.println("The process will be terminated.");) d: f& X. h8 J1 }# l7 G$ o9 Q
System.exit(1);9 V0 @! B, ]# y% j+ l9 M ]! s( C# x
return null;
- q) l# ]# n- {2 P+ g% K }7 D0 B" K3 i7 z; ]
return sel;
0 ~2 L8 b& P! X4 s& @$ c }5 p3 h. ]6 e- f, \
} |