01: package com.icesoft.faces.webapp.http.core;
02:
03: import com.icesoft.faces.webapp.command.CommandQueue;
04: import com.icesoft.faces.webapp.command.Pong;
05: import com.icesoft.faces.webapp.http.common.Request;
06: import com.icesoft.faces.webapp.http.common.Response;
07: import com.icesoft.faces.webapp.http.common.ResponseHandler;
08: import com.icesoft.faces.webapp.http.common.Server;
09: import org.apache.commons.logging.Log;
10: import org.apache.commons.logging.LogFactory;
11:
12: import java.util.Map;
13:
14: public class ReceivePing implements Server, ResponseHandler {
15:
16: private static Log log = LogFactory.getLog(ReceivePing.class);
17:
18: private static final Pong PONG = new Pong();
19: private Map commandQueues;
20:
21: public ReceivePing(Map commandQueues) {
22: this .commandQueues = commandQueues;
23: }
24:
25: public void service(Request request) throws Exception {
26: String[] viewIdentifiers = request
27: .getParameterAsStrings("ice.view.all");
28: for (int i = 0; i < viewIdentifiers.length; i++) {
29: CommandQueue queue = (CommandQueue) commandQueues
30: .get(viewIdentifiers[i]);
31: if (queue != null) {
32: queue.put(PONG);
33: } else {
34: if (log.isWarnEnabled()) {
35: log.warn("could not get a valid queue for "
36: + viewIdentifiers[i]);
37: }
38: }
39: }
40: request.respondWith(this );
41: }
42:
43: public void respond(Response response) throws Exception {
44: response.setHeader("Content-Length", 0);
45: response.writeBody().write("".getBytes());
46: }
47:
48: public void shutdown() {
49: }
50: }
|