import swarm.Selector;
9 Z2 [. g6 ~! |6 r
7 E, d1 _9 W8 ]# a5 P7 |public class SwarmUtils {* z& q8 J/ i$ _3 o3 P
public static Selector getSelector(String name, String method) {' j3 t2 j" E6 W y( Y* p/ p2 k
Selector sel;4 m% f' I. P6 z. O, n
try {
5 s7 v1 Q, A% C% w* ^ sel = new Selector(Class.forName(name), method, false);
: ?5 [/ ~1 }. M+ L& s. a } catch (Exception e) {4 V7 ^: h0 Q# d- \* s- G% X, R7 y" Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");5 |$ {. ] W6 P) h" d l
System.err.println(name + "." + method + " returns " + e.getMessage());3 M! \3 ~) z+ C
System.err.println("The process will be terminated.");! `9 {8 |1 `( P/ R ^4 ^; E
System.exit(1);
/ E. |: Q6 @0 j( c return null;
2 k0 Z. g# P. n4 O+ B }( T* k& O; X; ~% Y) G( ^3 Y; v( i
return sel;
4 ^* z: S& T9 z* k/ e: w& G ~9 H }
' [: \0 |% v' H& P4 E* y+ J
7 M8 ]3 I$ S" t% Q* z/ q# D: a public static Selector getSelector(Object obj, String method) {
- @$ b: Z* P: b* q% g; O Selector sel;
- w- `8 D" H* Q6 j) @) n try {. H- h6 \2 l7 ]
sel = new Selector(obj.getClass(), method, false);4 d4 Z$ ?! H/ s+ Q4 n7 }8 |
} catch (Exception e) {* z; W8 C3 O9 Q) T/ p
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
: t m/ [" `; a( D: @4 i$ Y + (obj.getClass()).getName() + ".");
9 D. e) W3 L& |5 q1 Z; t+ a System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' W- q! b% K, D# D4 @" ^ System.err.println("The process will be terminated.");0 g1 z* r; C: m; G+ p( k
System.exit(1);* C+ F0 R \% q1 j1 Y1 ~
return null;9 j- U& i9 j: q) H7 O/ H5 O
}4 f# | \3 I4 L7 P; @
return sel;6 \& f4 y( E% w: I5 t
}
3 a1 u Q) o/ K0 m5 t4 B1 ?% X} |