import swarm.Selector;
6 @) A: t2 i1 Q8 Q( V+ o
! l# f' m1 n$ M: p& Dpublic class SwarmUtils {
# s# } o: z* i3 u6 F public static Selector getSelector(String name, String method) {6 v5 z' c9 c3 `6 Z: c
Selector sel;! i) | ?! M* ?1 Z9 n: c
try {
; ]! S b" h9 c: M0 u; T0 {! q5 T sel = new Selector(Class.forName(name), method, false);
9 p& [5 Y! I- K8 k } catch (Exception e) {
* A' i# @, N: Z( r) J+ y' \! @ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
; q) S. N4 J+ n( m System.err.println(name + "." + method + " returns " + e.getMessage());* t, j) X; e w# |: i
System.err.println("The process will be terminated.");
1 B+ C" x Q2 U/ i1 z: |; ? System.exit(1);
+ b7 J' k- M; J ]8 {$ W return null;
! m: ]* y* I7 V. S* n" P1 E }
/ h' G, h1 a3 G9 p/ d; u$ F return sel;; r8 ` s9 ^" }! d
}0 X. U3 w, z: P4 f0 p
% m7 O' ~2 ]- F; l2 P: | public static Selector getSelector(Object obj, String method) {/ X0 N6 h5 X k) H9 @7 `' C
Selector sel;
1 `/ s) u* i+ e& a5 Y; ? try {
) H$ A, P: y, v7 L, S7 T" P sel = new Selector(obj.getClass(), method, false);$ ]2 u- b; _3 m! n
} catch (Exception e) {5 \7 P- f+ A$ `8 [: y3 F
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
# k# O) X, Q7 f0 X* ]4 ^ + (obj.getClass()).getName() + ".");. {) f1 d& w' E* P# c8 p! G
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
, q9 B% k" d' X# l$ v System.err.println("The process will be terminated.");
6 X% D; U2 i" c" B System.exit(1);
1 n4 H- A- d5 Q' A9 b2 g% s" Z3 M return null;
4 R1 D `! U) w% f6 N }8 x- q C$ Y0 @" x. z
return sel;
7 T5 g5 V: i5 k0 f5 c- V }
' G6 I2 X" j8 l} |