import swarm.Selector;
7 z1 V* z6 e W. R4 r
- R& G; C b' e, kpublic class SwarmUtils {2 y W! l5 ~6 [+ }
public static Selector getSelector(String name, String method) {& o/ x; T9 S" J
Selector sel;
$ c2 R' X, G; | try {. E# d; k8 l- n8 Z+ c9 G" ]
sel = new Selector(Class.forName(name), method, false);
) J9 Z- F G+ i! Y } catch (Exception e) {
0 N5 e; I, e- ]4 ^* r* _- B; c System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");, V! ]- `8 W( `- K
System.err.println(name + "." + method + " returns " + e.getMessage());
2 \/ T5 R; V4 L* Z( J6 Y System.err.println("The process will be terminated.");
3 C2 Q( w# j2 \$ G* O* R& C/ {3 s5 K System.exit(1);
0 v, G4 y. f1 S0 o return null;1 C' _6 s. A5 `
}( @- C" I/ V$ ~9 q4 @/ p: W
return sel;
# S) p h! b/ ~* J1 g }
6 O9 Z% _4 I! ~; J4 c+ X9 g2 j) ~$ f0 \+ y' n: |; l" b
public static Selector getSelector(Object obj, String method) {
/ J/ u7 l3 P) ? Selector sel;( {" r. f. e9 ~% x
try {
3 B, `) r) k; ]. L1 P- Q9 p# \5 I sel = new Selector(obj.getClass(), method, false);
9 ]; |& ]1 S4 f7 |4 ]1 t7 t } catch (Exception e) {/ l/ j! g% k8 E3 _# v9 l
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
* q7 \: ]+ v" N% o: f8 f + (obj.getClass()).getName() + ".");: ?0 A* v: G; n! c* L
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
0 M! a9 D$ v( z: m. I System.err.println("The process will be terminated.");
& H" \: A6 q5 u System.exit(1);
& I6 G! V6 ]' E5 W% ~; z; L) g, w6 Q return null;; p4 x' H y+ e2 [
}
7 \$ B6 v9 u0 M$ r# I1 \3 s return sel;; z& F9 M" S2 g0 w
}. L/ {0 Y1 u8 J+ }/ _
} |