import swarm.Selector;' g/ y6 s" E, V" j
3 h+ m" A$ \) {public class SwarmUtils {+ g# L4 b3 m- h6 |
public static Selector getSelector(String name, String method) {
+ U/ D! h( K* S! A. x Selector sel;% {0 I V' C. v! X" q# M
try {; z0 s( g$ A5 W$ A% I% I6 @
sel = new Selector(Class.forName(name), method, false);- K: {7 X! R/ b7 o7 b% R
} catch (Exception e) {
+ K) Q9 f6 I/ K System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");( @* [' z: B- G3 T) s: C
System.err.println(name + "." + method + " returns " + e.getMessage());. t# c, T/ @& m* ~9 C
System.err.println("The process will be terminated.");
( l: ?3 V8 T' m2 p: T0 j System.exit(1);
8 q/ z" Q$ h+ @4 E1 c: w" ` return null;
2 y% {4 C! z+ v Y D- Z, j! R }
; r' n4 k& F3 w) D4 P7 D0 w M return sel;4 d) I9 v. L3 t; O
}
0 L1 Z g3 o7 L: \- l$ k- c* m+ d# a$ e! e: Q
public static Selector getSelector(Object obj, String method) {
$ b4 R' v. N) y9 E* b Selector sel;
4 n$ }, C) V% L6 G6 e7 Z try {4 c3 f; E8 J! l" W. W
sel = new Selector(obj.getClass(), method, false);- q& d. D$ C6 N+ h2 W
} catch (Exception e) {3 q4 H2 \- @, M- v7 \! r
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
6 y4 f, _' o5 r$ g7 p- G + (obj.getClass()).getName() + ".");
/ b3 c) j4 J$ |* s! @3 A( T% | System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());$ G$ z7 I! K0 b) O, N( _; M
System.err.println("The process will be terminated.");
3 h! o U' c6 W( d' {- D1 X+ \ System.exit(1);
# p' x/ E! ]$ D. Y9 k return null;6 {( E) Q0 q. Y4 @% i* y
}; P* _0 h0 i& A1 F( q
return sel;
8 x# q/ ^2 g# U }
' c5 H5 k+ u9 i: Y5 v1 E} |