import swarm.Selector;
9 t3 @) G, ?/ n! z l# A
/ t& y6 g+ K" ? C" {9 Ipublic class SwarmUtils {! r1 K* }' b" I
public static Selector getSelector(String name, String method) {
$ R, K* K3 y0 i6 x0 p" p. d) A Selector sel;
! q: C# B9 ^. O4 `- d' h5 ~0 s try {
0 k9 M2 G+ d% a- N sel = new Selector(Class.forName(name), method, false);" t; M# ]. k, O# b# l5 f
} catch (Exception e) {
) a9 a& H/ c9 @: Q7 Z% E System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + "."); J, Z# G8 q$ u2 [& @: k; T9 @
System.err.println(name + "." + method + " returns " + e.getMessage());6 @+ W* f' Q# s: m
System.err.println("The process will be terminated.");
9 o, | W. v+ _2 M System.exit(1);
e/ y' D9 A# E8 ~ return null;
& m j2 F6 b1 f4 l6 m- k }" E# [ f' J3 o
return sel;+ i9 T! K1 ? b3 ~
}
' z8 u6 t1 n' s7 ]& X2 s' ~1 e- b2 P: l8 J+ P1 c" k6 D. Q- w- h* ?
public static Selector getSelector(Object obj, String method) {( u1 V+ g/ F) b6 ?7 D J
Selector sel;% n4 L5 s9 `" m8 K) t3 E
try {
- @* m$ C }. X8 d; B6 Y sel = new Selector(obj.getClass(), method, false);/ Q; t) p! M9 b* p$ E% c2 A+ s# O
} catch (Exception e) {
2 b" A& }6 S& A6 Y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 t, |6 R4 ~8 C/ S9 ~ + (obj.getClass()).getName() + ".");) t/ m! |1 A, D2 |6 c
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());! y+ C6 R) f/ e. O
System.err.println("The process will be terminated.");% d+ E+ d1 P5 P( s3 ]2 [3 Z
System.exit(1);5 y1 N ^' d+ h' f
return null;
5 }/ m4 z; ^& A# q6 B3 A/ l }& Q8 N- M+ m- T5 J5 k3 K
return sel;" q) U6 S6 C( c4 z& L, a# ^
}
6 T" k9 i- n6 K" T# Q, a1 W6 h. Y} |