1 package net.sf.crispy.impl.caucho;
2
3 import java.util.Hashtable;
4 import java.util.Map;
5
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11
12 /**
13 * Parent class from burlap and hessian server side implementation.
14 *
15 * @author Linke
16 *
17 */
18 public class CauchoServlet extends HttpServlet {
19
20 protected static final Log log = LogFactory.getLog (CauchoServlet.class);
21
22 private static final long serialVersionUID = 471335728357234L;
23 private Map cache = new Hashtable();
24
25
26
27
28
29 public Object addCache(String pvKey, Object pvValue) {
30 return cache.put(pvKey, pvValue);
31 }
32
33 public Object getFromCache(String pvKey) { return cache.get(pvKey); }
34 public void clearCahce() { cache.clear(); }
35 public int getCacheSize() { return cache.size(); }
36
37 public String getCacheKey (HttpServletRequest pvRequest) {
38 String lvUri = pvRequest.getRequestURI();
39 if (log.isDebugEnabled()) { log.debug("Request-URI: " + lvUri); }
40 int lvLastIndex = lvUri.lastIndexOf("/");
41 lvUri = lvUri.substring(lvLastIndex + 1);
42 if (log.isDebugEnabled()) { log.debug("Cache-Key: " + lvUri); }
43 return lvUri;
44 }
45
46 }