import swarm.Selector;0 Y5 l* G0 M! R- a; O5 W9 P
& C2 m! Q/ ?: B% u( i2 b: Gpublic class SwarmUtils {* q* d7 F2 R# c8 t; R
public static Selector getSelector(String name, String method) {
, R4 i9 P f4 C Selector sel;, S* `$ s, w* ~$ m7 U
try {, l, `) q# p* f0 J( H; n' D# I
sel = new Selector(Class.forName(name), method, false);2 W/ y, c* q$ h3 y; f }. z+ v
} catch (Exception e) {; z5 p" d. F! h8 }1 S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
* F) w+ ?' S6 e% @; ]4 _6 x! E8 @ System.err.println(name + "." + method + " returns " + e.getMessage());% |8 H: |0 _) F( }% S+ \
System.err.println("The process will be terminated.");- d; E* P% j+ ^* Z5 o
System.exit(1);
- I' q% H6 u$ z- E return null;
! s7 R, k! p. q! V* D4 R2 N3 n }: C; m# I% a: [
return sel;) f1 E2 v+ B/ T! Z
}
7 c9 P4 G5 S5 F/ B2 b6 I$ g& S
* b; P% {% D8 [) l' W public static Selector getSelector(Object obj, String method) {
$ b( `/ e9 ?% C6 j Selector sel;
4 L6 S+ U& v! t4 t' f/ M try {6 [5 _4 B/ U% g- ?+ ]& i8 N% p
sel = new Selector(obj.getClass(), method, false);
4 L+ P2 \7 W% X } catch (Exception e) {
: y: p# [" G3 B7 Y& f System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
. O9 S* t5 V. ? @6 F: m + (obj.getClass()).getName() + ".");
) [# i2 y, j" _ System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());6 p% Q0 \6 `: V
System.err.println("The process will be terminated.");
/ U: M5 y# C Z% O$ W0 K- x System.exit(1);
$ }4 B2 L1 ^: f1 q return null;" p3 Z+ K( }+ T: T# ~
}
# ^. K) ]: B7 Y* f/ g return sel;
) V3 d# [2 q3 I) ?" `3 D }0 A" n7 L; N' D, q- p
} |