KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > webapp > http > core > ResourceServer


1 package com.icesoft.faces.webapp.http.core;
2
3 import com.icesoft.faces.webapp.http.common.Configuration;
4 import com.icesoft.faces.webapp.http.common.Request;
5 import com.icesoft.faces.webapp.http.common.Server;
6 import com.icesoft.faces.webapp.http.common.standard.CacheControlledServer;
7 import com.icesoft.faces.webapp.http.common.standard.CompressingServer;
8 import com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer;
9
10 public class ResourceServer implements Server {
11     private Server dispatcher;
12
13     public ResourceServer(Configuration configuration) {
14         PathDispatcherServer pathDispatcher = new PathDispatcherServer();
15         pathDispatcher.dispatchOn(".*xmlhttp\\/javascript-blocked$", new RedirectOnJSBlocked(configuration));
16         pathDispatcher.dispatchOn(".*xmlhttp\\/.*\\/.*\\.js$", new CacheControlledServer(new ServeJSCode()));
17         pathDispatcher.dispatchOn(".*xmlhttp\\/css\\/.*", new CacheControlledServer(new ServeCSSResource()));
18         pathDispatcher.dispatchOn(".*xmlhttp\\/blank\\.iface$", new ServeBlankPage());
19
20         if (configuration.getAttributeAsBoolean("compressResources", true)) {
21             dispatcher = new CompressingServer(pathDispatcher);
22         } else {
23             dispatcher = pathDispatcher;
24         }
25     }
26
27     public void service(Request request) throws Exception JavaDoc {
28         dispatcher.service(request);
29     }
30
31     public void shutdown() {
32         dispatcher.shutdown();
33     }
34 }
35
Popular Tags