import swarm.Selector;0 P7 \9 N; p+ `: f( t
+ q- U5 v) \" n; Z4 f! r
public class SwarmUtils {
) d X: Z( L B$ r public static Selector getSelector(String name, String method) {
. F% U ~, G' h8 R Selector sel;, C0 T1 T1 |' h6 a2 r' s
try {( g7 S, |7 M5 Q+ h/ N
sel = new Selector(Class.forName(name), method, false);
) s' ?1 g9 D3 I- W3 ` } catch (Exception e) {+ Z& u: f! \4 I2 p$ Y6 s
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
8 M6 R& O( Y3 c7 s System.err.println(name + "." + method + " returns " + e.getMessage());
/ X( g( \9 |& t7 X9 Q/ S System.err.println("The process will be terminated.");; W$ \3 l& E+ J
System.exit(1);
/ L* g4 q+ Q# H1 X3 t: m return null;
6 L) h) V! V9 V" v# q' |: | }! s3 u6 ]( O1 m/ @
return sel;
+ s+ B( e7 S0 [0 a% z% X }$ }( }9 ^& }9 |7 ]: A
( n1 T! |" j& t) }, b$ F
public static Selector getSelector(Object obj, String method) { a, j; M: m$ W% |
Selector sel;
# l% f1 Q! C* T9 R try {
0 S# R# v2 W5 r5 a6 {6 Q4 \ sel = new Selector(obj.getClass(), method, false);
. u, g% \8 T! `/ ~% j } catch (Exception e) {
* Z; |$ J1 m, {" H/ k System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ W: m1 ^* ]$ e0 h+ ~2 y, S. [
+ (obj.getClass()).getName() + ".");
, c7 W( ~. ^) K5 ^ R+ d System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());& g6 p# P! Z5 K- {- K! {* t1 w
System.err.println("The process will be terminated.");
% a# k' F1 U$ a' v1 z System.exit(1);; P/ k' H1 {5 S3 z( m
return null;, G: F8 X! y J' ]+ ~( {+ _
}
; j) T: r! o# @8 s8 l# w* P return sel;
, S3 n) I3 J( r5 J! X }- O" x+ y! V- h0 D
} |