import swarm.Selector;6 E; ^* A& y0 }! a) W" \* y2 {, d' o
) o7 E8 v3 Y8 a* S+ D
public class SwarmUtils {, \7 C9 d* o( K6 @: x
public static Selector getSelector(String name, String method) {1 @+ o7 S! F4 ], U5 `' b
Selector sel;5 E% V8 K& t4 I; }/ l
try {
$ i/ t! ]9 @ g( N& R sel = new Selector(Class.forName(name), method, false);( A6 x1 c5 q0 l) i5 F
} catch (Exception e) {' _2 V* W: P- N0 i8 I
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
- Y2 Y3 @' u3 x, T System.err.println(name + "." + method + " returns " + e.getMessage());# S9 N8 Y: _: @
System.err.println("The process will be terminated.");/ F% q1 i1 h, v2 Z
System.exit(1);& \ z8 S8 W6 C! E( g: H
return null;
( d# w4 j: \) S) R! x }) z. u4 B# R( l# W# y
return sel;8 m; i* _0 K2 F: P
}
4 c% C6 w$ Y8 P: n9 W* T0 z% m0 N' c% r. F* K
public static Selector getSelector(Object obj, String method) {
5 ]0 b' `, d$ b& M y3 k& z: w3 Z Selector sel;6 p" d( M9 O# C# a
try {5 l" n% M& G% s- f. v' M
sel = new Selector(obj.getClass(), method, false);5 X+ f. y1 I9 \4 s/ n
} catch (Exception e) {7 m! x- Q9 l. v+ E$ ]
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
9 g; d* b% o9 T. P + (obj.getClass()).getName() + ".");
6 ^! b6 l; S7 `# H2 Q System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
9 ?: w; M5 Q: b; [% n* T- T2 g System.err.println("The process will be terminated.");
1 D9 t/ M% v' v4 h6 T2 W% B/ O& e System.exit(1);7 X: Z5 P$ N* d4 D- b M, @2 |
return null;5 C0 u6 Y/ a+ E$ _ w/ b; X+ k8 k
}
3 {* k9 [: P1 b3 F& G* r, l/ f return sel;
' N% Q( y1 k7 K0 a }
8 [! G- I- P/ q} |