import swarm.Selector;+ o1 \$ y. ~, y l
7 y9 _, H3 B. h. J" @- {
public class SwarmUtils {0 y/ V$ s7 Q1 P' n) _3 b
public static Selector getSelector(String name, String method) {+ C' E8 G2 {! |( i, F
Selector sel;
8 \( n) S4 \! b, O try {
3 X7 D- ^$ O* u# W- F sel = new Selector(Class.forName(name), method, false);
1 D- p' I! S. Z J+ ~; ]( v } catch (Exception e) {
4 R5 I% p, l, |2 \7 } System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
' c. L! O# O, a0 z System.err.println(name + "." + method + " returns " + e.getMessage());
1 F* u9 m. b4 D& S7 f+ L System.err.println("The process will be terminated.");
2 b, T3 i: ?3 b3 y System.exit(1);2 r$ H p4 i& n% l Q
return null;' {' L( p" @: T% i7 X& `; B3 D2 {
}% I% n( Y" w1 u9 v
return sel;- E1 s) ~8 Q/ X( d; D' |. }
}$ Q2 t" `; A( M9 D' L
2 p0 h; {" k# U7 K4 g) ^& _# C
public static Selector getSelector(Object obj, String method) {
& b9 Z6 K0 A/ g N; {& C ` Selector sel;
! ~2 r8 L& ]; t( u# t- Q2 d8 K try {" \/ }7 ?1 b x( W
sel = new Selector(obj.getClass(), method, false);( x. r! X: V! u1 o% z
} catch (Exception e) {1 K' O$ F+ g4 B3 k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
! t7 }1 `4 a% |7 O% O + (obj.getClass()).getName() + ".");
+ B9 J7 ]- n( [ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
) j7 ?6 d( c9 B4 J System.err.println("The process will be terminated.");
7 |/ P% d( |! q* u System.exit(1);0 Y4 {0 }/ d, Q- i/ h2 |
return null;
) h% G6 n3 J; t1 [$ F4 J }# M! |: W, r8 A; @ ?
return sel;# f8 {* g8 U) ?* p$ V, |8 t* ]* S4 E
}
1 | F/ d( D- a} |