import swarm.Selector;
" |4 W% T- x5 [- ]$ }9 ^( P- m3 S, K% ^# S( w# O
public class SwarmUtils {) }; w7 T: a9 K, i: @+ F
public static Selector getSelector(String name, String method) {
, E/ c. Q, T( x5 l7 u Selector sel;/ ^; I! d6 S! ?, {4 l( n( L
try {
* z8 v: f- g7 X7 P3 c/ D2 y: p sel = new Selector(Class.forName(name), method, false);
! v) p0 K( ^5 j( v3 F; S4 @, W1 c } catch (Exception e) {
# ~4 C$ s+ W1 K( t1 N) T: G$ \ System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; R3 ?! s( M9 ?$ }3 v! F
System.err.println(name + "." + method + " returns " + e.getMessage());
, s+ y5 n y6 a& m8 ~ System.err.println("The process will be terminated.");' U+ c9 D) J* L7 M6 C. q. G
System.exit(1);( o" a# @: x$ \% i& Q
return null;1 }) j( Q5 r& e7 B: w: k
}
: h! t6 v9 v9 @ {' t) p2 Q* F! g return sel;- A- X0 b9 ^/ ]6 d0 N4 p B
}
( K; r6 K6 E3 m5 q' z$ S
6 o& L2 g3 k! M. y public static Selector getSelector(Object obj, String method) {
9 O1 {8 h+ v1 m5 N% f Selector sel;5 k- A/ [: {( M; y* L
try {" X7 `. H8 j; V: e7 \7 p% J4 v. ]$ H
sel = new Selector(obj.getClass(), method, false);9 b0 f8 A0 _$ q1 D% r. Z
} catch (Exception e) {( ]: N2 n G; V- z8 r; N& L
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
' p" M% P' T4 r: t + (obj.getClass()).getName() + ".");
1 q4 U! j4 P. F' l1 H System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());# v" A( D3 B( H4 C
System.err.println("The process will be terminated.");
. V2 x- z- r/ o System.exit(1);5 S! A1 h. W* r# a/ w
return null;1 C( c8 ~# {7 A, |4 X4 C
}
0 |5 U! ?* }0 _' ^ return sel;
. T" B6 K: N( A) W5 O6 v8 L9 o9 S }/ h! T6 }' ^! X' U) z
} |