import swarm.Selector;
- o+ Y" e4 c! i3 ~4 ]) K5 \' o6 h, t4 B8 b8 l" O1 E' F& G
public class SwarmUtils {+ q K/ B/ E7 _3 ]: s% x; S
public static Selector getSelector(String name, String method) {
, x; \0 M; v! k Selector sel;2 h& D( u* g, x" ~- ~# K- C; |
try {
. d$ s. J. }+ @4 f# P4 W sel = new Selector(Class.forName(name), method, false); k& P4 [( c0 h, ?, x5 H7 N
} catch (Exception e) {7 B7 x9 m$ t8 Q( g; Z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");4 ]# N! ?; n& ~& U" p& Z/ m4 _
System.err.println(name + "." + method + " returns " + e.getMessage());2 r# o: j# ?- @5 P7 @
System.err.println("The process will be terminated.");( e5 v, N( ?& }
System.exit(1);
: K9 P1 D7 \+ i( R" h1 }: C, n return null;* k8 U+ g! b+ A: ^7 p' P. P
}
4 t; C$ a3 D$ R ^2 c return sel;
' C* U/ Y, c7 j }5 D( O" h6 E0 \2 A4 A1 i
7 G& P& f, i* e: M public static Selector getSelector(Object obj, String method) {1 f0 o9 L6 j* q" n
Selector sel;. W# C. \4 y1 O+ r( [0 B3 Z
try {
5 q- j x; L8 U0 ], ` sel = new Selector(obj.getClass(), method, false);. M! z/ H6 ^$ u0 f- R4 D
} catch (Exception e) {
8 ? N1 L6 @, ]1 n( x System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
7 V; u* Q( B5 I& B + (obj.getClass()).getName() + ".");9 O! l$ w6 |: m" a2 }! _) ~1 M
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
8 a) D% e# C: f2 ^9 h System.err.println("The process will be terminated.");3 r1 r" `- N }! O. J5 O' r
System.exit(1);( C K3 y0 s2 [9 `& c$ w$ d
return null;
+ w4 s' z, M1 ?% g" W }
c# y- p% b' T return sel;
# r% W1 s! C5 P( n }
% W* f3 ~% F+ @. C$ _} |