import swarm.Selector;, |5 }$ b( l1 C6 p. q4 u
2 c! _. d6 H0 _. \ c8 Qpublic class SwarmUtils {
: `. S6 q4 `: ?, R/ s/ n public static Selector getSelector(String name, String method) {- z5 a. M. U( C" z' ^5 M- A2 N
Selector sel;5 U6 _. m; A0 W+ v+ ^8 X% a' e1 @
try {
. j* I, a* c- q1 n% i sel = new Selector(Class.forName(name), method, false);
6 K1 h( h" ^- J( @6 g' B } catch (Exception e) {
6 S% W0 [4 R: O2 G. B. `: J. W System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 z4 |- @# i) Q9 R- d# H+ e* ] System.err.println(name + "." + method + " returns " + e.getMessage());. k& @" T2 N( }& Y
System.err.println("The process will be terminated.");" I* {: c! A; @' z
System.exit(1);# O h9 F/ | o# f- L
return null;
, m8 D$ ?0 _3 V }
2 x1 S/ I& Z9 {$ u* O. ^ return sel;
# ]7 h8 D$ u& M6 s9 l/ S }
|# j- U% q X: M Q3 u
7 L+ @5 H0 J9 C8 S; O, `* f6 } public static Selector getSelector(Object obj, String method) {" }( x7 {1 V5 w8 }7 e
Selector sel;
: p4 E2 y# R0 V2 D' H1 A try {
! X! }- c# i3 k9 v# G# e& |6 y9 R, C sel = new Selector(obj.getClass(), method, false);
3 d- |4 s' f( y& E* S( E2 m2 v7 w } catch (Exception e) {
9 R' D2 f8 I2 C# f( i System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "/ X% Y- b8 t! z6 j
+ (obj.getClass()).getName() + ".");5 L" Z3 }( `& [' Q
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());, n6 }6 N8 I$ e [' T$ S
System.err.println("The process will be terminated.");
) n! S# ?! I# u System.exit(1);) |1 T) |) x# [+ J5 K
return null;
+ Z1 @* ~6 P3 w% B) W9 j }
3 e1 h5 B8 y7 K$ | return sel;
# p4 q: _! V( z) [' I/ C: P3 S }
$ G6 g( T# V9 b: ]" w# z} |