import swarm.Selector;6 l& _8 q! Z$ |( ]3 ]
3 v: r8 u9 B* O/ q( vpublic class SwarmUtils {
% j5 u0 B5 s( ^1 x- l public static Selector getSelector(String name, String method) {
: _8 l7 m/ u. @! @ Selector sel;
1 l0 W# C) c( X7 t# u try {
; m2 y* w# t# {; `" L8 S4 ? sel = new Selector(Class.forName(name), method, false);
; I8 E# j! q }7 `- t } catch (Exception e) {7 z" ^% t/ A( S( O
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");, x/ ?0 f" K J/ x$ Y U0 ]0 g
System.err.println(name + "." + method + " returns " + e.getMessage());0 M }4 z& E8 K7 C8 P, D1 {* y% V- f
System.err.println("The process will be terminated.");
8 C" G) g0 C7 i% P- \6 h- W System.exit(1);( A4 y& o; a+ J* Q. D, L% Y
return null;
* L7 G1 L5 V& i* B }3 d, U; k# c0 {6 X
return sel;
! A( e! m7 ], ~) j) Q* B4 d/ H7 @ }5 E- M: J! m% Z
, e5 I& D$ u: m* K% A) e J public static Selector getSelector(Object obj, String method) {/ c, h" V$ w0 z- u) K
Selector sel;
2 a2 Y* q4 e1 J0 @+ F9 A2 ]- g& _ try {
/ w0 D! ~" t x% P5 @4 | sel = new Selector(obj.getClass(), method, false);8 ^% I; t: E$ n6 z" F" Z
} catch (Exception e) {
/ E2 L6 M8 j3 h, O/ s! E System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "- ~% v. H5 k2 n2 p! E
+ (obj.getClass()).getName() + ".");3 y d' Z, {! j1 L
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());/ i3 I, c) |1 [2 }- T; @% G
System.err.println("The process will be terminated.");8 K% T2 j+ r$ p4 s1 ^1 m
System.exit(1);* q G* v9 B$ P: |
return null;
1 d. H. F2 w6 W. ~; B }. o$ T, X& }! D6 y. `
return sel;
% h9 @* q3 X1 e4 } }
7 T( D' S: {: a; K8 z1 @} |