import swarm.Selector;4 y4 {8 R. S1 d. p2 f& F! I- G( ]
* E( m8 q& ^. P& H7 e. Epublic class SwarmUtils {) E+ o( f% m! d L# I; L
public static Selector getSelector(String name, String method) {8 F, h& d" ~$ s. F. g
Selector sel;) k8 i4 g1 E- }) v; ]$ V* ?: c
try {
# K0 u6 d6 ?9 r; ` sel = new Selector(Class.forName(name), method, false);) i' [. Z3 D- y, R; a( ]: T9 j1 K
} catch (Exception e) {
7 A2 M4 r- f" C( T6 g! Z6 \; ] System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
3 L" ~" D9 i, i0 Z# \6 e- [ System.err.println(name + "." + method + " returns " + e.getMessage());7 X2 m1 p7 X4 i3 b$ i
System.err.println("The process will be terminated.");' w$ G# F( p. d) u+ s
System.exit(1);
4 k; S2 F. h) F4 E* ]4 {! x0 R return null;
! V7 B9 X }' E } t% G- Y; M( f" R
return sel;1 ?5 G3 ?# Y" Q
}
9 p8 k1 x* v/ B) u7 i. e- w. G; ]8 q! u4 V
public static Selector getSelector(Object obj, String method) {; _* ^+ `1 Z/ |
Selector sel;5 [1 `+ X M. W* s
try {* u, }/ b" k1 D# ~$ ?& r
sel = new Selector(obj.getClass(), method, false);
( Z( G3 u" d7 m# V c" n u9 } } catch (Exception e) {# g" X5 G. E' A: p& V
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "5 ^1 o2 y8 x: ?6 |5 L: M5 Y
+ (obj.getClass()).getName() + ".");
$ Y( f8 o/ t$ f' E( j System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());; i6 w% B( g S' Y+ Z3 E
System.err.println("The process will be terminated.");7 k1 {8 m4 b# e- L) J/ T" `, L
System.exit(1);
9 _6 Y) a. F# F, T* `7 Q6 A return null;2 `- Q; q: k( L" u
}9 k. Q2 w, o+ m
return sel;
: ]) n1 b& |( Q; G }
! ?& b; ?/ q: _# ?3 {} |