import swarm.Selector;
) I: z) ?' C! G# h1 y* M' O4 w4 s1 O: p/ P7 ~
public class SwarmUtils {# M P( b. H. _' _! l
public static Selector getSelector(String name, String method) {5 ~$ k' o8 w" {: w9 @6 N
Selector sel;% q0 X3 w! n( d A8 |
try {
1 b% d& t( _& L9 t' H' j. |- |% { sel = new Selector(Class.forName(name), method, false);
- g G( j; t/ ^ } catch (Exception e) {
7 O7 D3 f0 ?- g' a8 f System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");4 b! E$ q$ s9 Y9 z/ L+ |, r
System.err.println(name + "." + method + " returns " + e.getMessage());: x% Q/ H: [( _
System.err.println("The process will be terminated.");( f9 Q8 L4 }; b
System.exit(1);
8 N9 d. N% z1 \/ _ return null;# d# S# j. v* K' }
}
s6 ]- n( U5 J/ q/ A% c0 y return sel;
( e; r! l" q# Y5 U }$ U7 R7 U# O# \* U
" y# O7 _6 i) O2 N' T
public static Selector getSelector(Object obj, String method) {
8 g6 Y/ u3 k; K; B Selector sel;. a1 S- Z$ \9 r& D
try {9 y3 {3 ]$ T. Y6 ?* c. p4 V: b
sel = new Selector(obj.getClass(), method, false);
0 K7 X8 q+ ?# e3 a+ [7 Y1 C' K5 v } catch (Exception e) {
0 s$ K7 d5 [3 B. n2 M* t, n System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
1 g% _4 X: C [( `( _4 v' F1 D4 e6 X + (obj.getClass()).getName() + ".");; {1 I2 Q( V' `9 Y0 W
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 V6 a/ t/ w3 Q' a$ d& J
System.err.println("The process will be terminated.");
U; T* \! E* L0 f u System.exit(1);
+ ]9 ], a, w8 D7 Z3 n; w- v return null;
; l" @# S& w9 v5 e! p }
& n' j1 d, I8 ~: p8 z- U return sel;
7 d* i9 L1 t7 `) d4 R }
' M% K1 t2 B% e1 q1 F} |