import swarm.Selector;( ^+ L2 y. n5 Z9 _% r8 s( P
F2 }: O- ^) N! kpublic class SwarmUtils {
( v# d' P' A, U* h! W2 K public static Selector getSelector(String name, String method) {
: c5 N# a$ U' l7 F+ H- }' Q# f) J$ b Selector sel;: G8 t. ?% k7 w
try {
2 V" [) I% t& r sel = new Selector(Class.forName(name), method, false);
: a7 D- n, W% ~8 m! E } catch (Exception e) {, }/ V! T0 ]5 B9 T
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. O6 P* h- S- h A8 ~ System.err.println(name + "." + method + " returns " + e.getMessage());- i1 R# m" V1 e0 j# ]) T; U; O% E
System.err.println("The process will be terminated.");
; n5 g7 e7 H* a System.exit(1);6 S" u" Y& I! H0 d+ i% x1 w
return null;
' U2 D! M" S) \" }3 W; r0 x }
1 H u2 C) p& s* g! M return sel;
. Y3 Z0 [: y) b# Z+ P; N+ h }
2 J W/ x8 l* y8 l8 b o4 S
0 Z U! S: n6 z6 H public static Selector getSelector(Object obj, String method) {
3 L5 |. D, s ^* T3 L M, s+ { Selector sel;9 e7 v$ m2 L; d" m" i6 ]; D
try { r9 m% z. C0 g5 Q& e+ A
sel = new Selector(obj.getClass(), method, false);$ H6 ~+ R) b6 L, n
} catch (Exception e) {
0 f# N' i, Q- X, n5 r% d# \1 y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "; d7 k; }- G1 d3 X
+ (obj.getClass()).getName() + ".");$ H( n1 V0 G% c% w
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
, b1 t! {8 P/ i8 z0 X System.err.println("The process will be terminated.");
' E5 z5 o7 ^0 m: ?0 P System.exit(1);# J1 s' T8 d, ?3 j+ }, F5 z$ o4 h
return null;; b& }: p9 B& f' ]
}2 X7 H# r0 {& q7 n5 N, }
return sel;
# e6 a2 q1 A, k }
8 C& ]: T3 h- }} |