01: /******************************************************************************
02: * ResponderMEDIA.java
03: * ****************************************************************************/package org.openlaszlo.servlets.responders;
04:
05: import java.io.*;
06: import java.util.Properties;
07: import javax.servlet.ServletConfig;
08: import javax.servlet.ServletException;
09: import javax.servlet.http.HttpServletRequest;
10: import javax.servlet.http.HttpServletResponse;
11: import javax.servlet.ServletOutputStream;
12: import org.openlaszlo.cache.MediaCache;
13: import org.openlaszlo.cache.RequestCache;
14: import org.openlaszlo.server.LPS;
15:
16: import org.apache.log4j.Logger;
17:
18: public final class ResponderMEDIA extends ResponderCache {
19: private static MediaCache mCache = null;
20: private static boolean mIsInitialized = false;
21: private static Logger mLogger = Logger
22: .getLogger(ResponderMEDIA.class);
23:
24: public void init(String reqName, ServletConfig config,
25: Properties prop) throws ServletException, IOException {
26: if (!mIsInitialized) {
27: // Initialize media cache
28: String cacheDir = config
29: .getInitParameter("lps.mcache.directory");
30: if (cacheDir == null) {
31: cacheDir = prop.getProperty("mcache.directory");
32: }
33: if (cacheDir == null) {
34: cacheDir = LPS.getWorkDirectory() + File.separator
35: + "mcache";
36: }
37:
38: File cache = checkDirectory(cacheDir);
39: mLogger.info(
40: /* (non-Javadoc)
41: * @i18n.test
42: * @org-mes="Media Cache is at " + p[0]
43: */
44: org.openlaszlo.i18n.LaszloMessages.getMessage(
45: ResponderMEDIA.class.getName(), "051018-50",
46: new Object[] { cacheDir }));
47:
48: try {
49: mCache = new MediaCache(cache, prop);
50: } catch (IOException e) {
51: throw new ServletException(e.getMessage());
52: }
53:
54: mIsInitialized = true;
55: }
56:
57: super .init(reqName, config, mCache, prop);
58: }
59:
60: static public RequestCache getCache() {
61: return mCache;
62: }
63: }
|