import swarm.Selector;
8 p: E0 e* D7 Y$ ^) L9 ^
# y1 y) Z1 D& \% m% [public class SwarmUtils {
7 q2 M' M# T& {$ M/ ?, S7 I public static Selector getSelector(String name, String method) {
, \/ B5 i0 O+ j5 { Selector sel; [* p" i1 k3 i% E+ `3 ~
try {4 C/ s% }" Q) Q5 k8 J0 ?2 ~
sel = new Selector(Class.forName(name), method, false);) E/ G8 o- i2 o8 k9 X: j
} catch (Exception e) {; k9 `, ] _4 ^, c' s
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: h% F8 s1 [( i/ s System.err.println(name + "." + method + " returns " + e.getMessage());" k4 R# [8 L. d" E" Q: ?! t
System.err.println("The process will be terminated.");1 d8 b/ s, U/ }
System.exit(1);- a( F- b; V2 }: t. Z
return null;0 I' g! A9 e% m- u* C; G- Z2 H
}
( B, A) E8 U9 Q% v. y/ R return sel;
' M/ s( A9 y% a }! G, y' ]$ T. _, ?
$ v& s+ `( E) b% N! V; c
public static Selector getSelector(Object obj, String method) {% } T- E; W4 ^1 \; x# |0 z2 B% ^, Y) Z" ]
Selector sel;$ ?. }9 q& o! y4 L6 H, u6 e" e2 Q- Y
try {
% b! b- \- n% ?) c- L3 T sel = new Selector(obj.getClass(), method, false);
+ c3 r! V4 j4 | } catch (Exception e) {
1 ]( R& p6 s/ D' ] System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
% z4 `7 n1 K: p; ^' K+ |. K + (obj.getClass()).getName() + ".");
- G7 v! M1 I3 l( ^! L: L! J$ a" P+ l System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
( { m% O8 P% l System.err.println("The process will be terminated.");' Y6 `4 s. G/ J) O8 w) p
System.exit(1);# V0 N, ^% P9 [# y; h( G/ l8 V
return null;9 y# A9 Z7 Q! I8 o7 [! m
}" Y7 j8 s+ J& i4 p
return sel;7 Z0 x9 {3 U, C) a7 V/ i
}
U2 U& }, Z5 d" V% S} |