if(st.st == "killed")
logger.log(Level.WARNING, "Thread " + rt + " refused to die; killing again");
if(now - st.lastkill > 5000) {
- rt.stop();
+ if(forcelimit)
+ rt.stop();
+ else
+ rt.interrupt();
st.st = "killed";
st.lastkill = now;
} else {
}
public void shutdown() {
- if(root instanceof ContextResponder)
- ((ContextResponder)root).destroy();
+ if(root instanceof Destroyable)
+ ((Destroyable)root).destroy();
try {
long last = 0;
while(true) {
}
public RequestThread respond(Request req) {
- return(new RequestThread(root, req, workers, "Worker thread " + reqs++));
+ return(ctx.worker(root, req, workers, "Worker thread " + reqs++));
+ }
+
+ public long requests() {
+ return(reqs);
}
private Responder bootstrap(final Class<?> bootclass) {
}
return(null);
}
+
+ public static class CreateException extends Exception {
+ public CreateException(String message) {
+ super(message);
+ }
+
+ public CreateException(String message, Throwable cause) {
+ super(message, cause);
+ }
+ }
+
+ public static ThreadContext create(ServerContext ctx, ClassLoader cl) throws CreateException {
+ String nm = "JSvc Service";
+ if(ctx.name() != null)
+ nm = "JSvc Service for " + ctx.name();
+
+ String clnm = ctx.libconfig("jsvc.bootstrap", null);
+ if(clnm == null)
+ throw(new CreateException("No JSvc bootstrapper specified"));
+ Class<?> bc;
+ try {
+ bc = cl.loadClass(clnm);
+ } catch(ClassNotFoundException e) {
+ throw(new CreateException("Invalid JSvc bootstrapper specified", e));
+ }
+ return(new ThreadContext(null, nm, ctx, bc));
+ }
}