import swarm.Selector;
e3 T z6 G$ a( R$ s, L4 U* L' q& {6 _2 ?- y q7 Y
public class SwarmUtils {: b1 K$ j) t& f+ C; L
public static Selector getSelector(String name, String method) {
+ M+ e0 A; R# U3 C. n Selector sel;
9 |4 C9 E$ I1 J3 S) Q8 j try {# p6 R1 j$ Q" L3 q$ |- @. l0 s
sel = new Selector(Class.forName(name), method, false);* P: I( T. ^; z* f; L
} catch (Exception e) {
( H: \" n! w* s9 I System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");# h( b2 A$ Q" f. ]- o: \1 E
System.err.println(name + "." + method + " returns " + e.getMessage());
8 Q3 h8 u) F4 e) t/ ?1 d* `$ u6 r System.err.println("The process will be terminated.");. ]( d! c( Z' R: b# m
System.exit(1);
/ e- V% L) t; I+ Q6 _, q return null;4 G) ]( x0 n( D3 k7 z
}
/ F9 \3 R6 c5 @9 ]" v8 Y return sel;& f0 H. w/ C9 B5 |, S# \" b) J: o2 W
}
% A: [! Q9 T N! }; U6 v/ V
" K. I1 p3 G* l2 V public static Selector getSelector(Object obj, String method) {
, t% h. E3 Y. h$ b Selector sel;
7 s x, W- F/ r6 u try {
: z1 f5 |7 z5 y- J$ }" C7 o4 p sel = new Selector(obj.getClass(), method, false);
2 `2 h6 i, Z' q) v/ l } catch (Exception e) {" S; D {/ D7 `; R# Q- V! `0 c# z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 i0 V% A2 P- c
+ (obj.getClass()).getName() + ".");
2 z B# a# c, B. S2 M System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 c7 a2 I2 q) D K g# L8 E. Z5 H
System.err.println("The process will be terminated.");
- w$ y" N& `0 j6 c7 |( L System.exit(1);7 L3 a9 \6 }& s* d" M" C3 I
return null;
- d% P6 A8 c' U3 L& g4 p/ I: R5 V }/ m* C* n! h7 [' ^
return sel;
/ m9 I" i; [% d( E! a% d }6 d- v* O) ]9 D ~3 Q1 L
} |