import swarm.Selector;, L L: J# S# t% a, l; Z
7 O' Z! A0 b" ^+ f. D; epublic class SwarmUtils {
$ \& P8 R8 l, _! G/ G+ B$ b public static Selector getSelector(String name, String method) {
6 Z9 M) `& }; M9 o5 P x3 Q4 O& h Selector sel;0 M0 P& u- W8 Q1 ]
try {0 `( {; ~ q: l( z! v
sel = new Selector(Class.forName(name), method, false);
" F& L4 i8 ]9 b; F! e } catch (Exception e) {( n6 Q L: s. f& j. s) Z
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");/ ? _) E" N0 Q
System.err.println(name + "." + method + " returns " + e.getMessage());
: E! w7 b' r G' Q( r# | System.err.println("The process will be terminated.");& s8 W/ E, W& ?$ C. l) I# r( s
System.exit(1);% R3 }; m% Q4 Y! F
return null;
5 [; z% c+ d, Y7 p0 J8 u }8 w" m- Q" d( B' i
return sel;* D! n7 Z- J( |2 I5 r$ D; \
}
7 g! r& P! V3 G# a
' u' m5 I$ [/ p public static Selector getSelector(Object obj, String method) {
8 e5 `! K8 B* \" y Selector sel;
! h# X( P6 J! G8 A try {
( p6 L9 ]% @4 C+ s9 g# x sel = new Selector(obj.getClass(), method, false);* V- F& o2 M# L- j
} catch (Exception e) {
I% e% ~+ m- i: [4 [ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "3 G, u. ~! s& |6 }& J" z$ n! s
+ (obj.getClass()).getName() + ".");
; C9 \/ u9 c7 s System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
: W- p" H6 H, u0 I4 \. s+ |" ?- t System.err.println("The process will be terminated.");
" [1 _( J o; U7 a; H System.exit(1);# D, {0 R1 R1 w) d1 ]
return null;
/ c5 x2 Y' z+ i7 p% w }
+ U) d# F) a6 c- j- f return sel;
7 _0 [) l- [ F" | }# R. O# M" T' N# y! D m/ c" l
} |