01: package com.icesoft.faces.webapp.http.core;
02:
03: import com.icesoft.faces.webapp.http.common.Request;
04: import com.icesoft.faces.webapp.http.common.Response;
05: import com.icesoft.faces.webapp.http.common.ResponseHandler;
06: import com.icesoft.faces.webapp.http.common.Server;
07:
08: import javax.faces.FactoryFinder;
09: import javax.faces.context.FacesContext;
10: import javax.faces.lifecycle.Lifecycle;
11: import javax.faces.lifecycle.LifecycleFactory;
12:
13: public class PageServer implements Server {
14: private final static LifecycleFactory LIFECYCLE_FACTORY = (LifecycleFactory) FactoryFinder
15: .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
16: private Lifecycle lifecycle = LIFECYCLE_FACTORY
17: .getLifecycle(LIFECYCLE_FACTORY.DEFAULT_LIFECYCLE);
18:
19: private ResponseHandler responseHandler = new ResponseHandler() {
20: public void respond(Response response) throws Exception {
21: FacesContext facesContext = FacesContext
22: .getCurrentInstance();
23: response.setHeader("Cache-Control", new String[] {
24: "no-cache", "no-store", "must-revalidate" });//HTTP 1.1
25: response.setHeader("Pragma", "no-cache");//HTTP 1.0
26: response.setHeader("Expires", 0);//prevents proxy caching
27: response.setHeader("Content-Type", "text/html");
28: com.icesoft.util.SeamUtilities
29: .removeSeamDebugPhaseListener(lifecycle);
30: lifecycle.execute(facesContext);
31: lifecycle.render(facesContext);
32: }
33: };
34:
35: public void service(Request request) throws Exception {
36: request.respondWith(responseHandler);
37: }
38:
39: public void shutdown() {
40: }
41: }
|