01: package com.icesoft.faces.webapp.http.core;
02:
03: import com.icesoft.faces.context.View;
04: import com.icesoft.faces.webapp.http.common.Request;
05: import com.icesoft.faces.webapp.http.common.Response;
06: import com.icesoft.faces.webapp.http.common.ResponseHandler;
07: import com.icesoft.faces.webapp.http.common.Server;
08: import com.icesoft.faces.webapp.http.common.standard.OKHandler;
09:
10: import java.util.Map;
11:
12: public class DisposeViews implements Server {
13: private static final ResponseHandler CloseConnection = new ResponseHandler() {
14: public void respond(Response response) throws Exception {
15: response.setHeader("Connection", "close");
16: response.writeBody().write("\\n\\n".getBytes());
17: }
18: };
19: private Map views;
20:
21: public DisposeViews(Map views) {
22: this .views = views;
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: String viewIdentifier = viewIdentifiers[i];
30: View view = (View) views.remove(viewIdentifier);
31: // Jira 1616 Logout throws NPE.
32: if (view != null) {
33: view.dispose();
34: }
35: }
36:
37: request.respondWith(OKHandler.HANDLER);
38: }
39:
40: public void shutdown() {
41: }
42: }
|