1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import java.util.Properties ; 14 import javax.servlet.ServletConfig ; 15 import javax.servlet.ServletException ; 16 import javax.servlet.http.HttpServletRequest ; 17 import javax.servlet.http.HttpServletResponse ; 18 import javax.servlet.ServletOutputStream ; 19 import org.openlaszlo.cache.MediaCache; 20 import org.openlaszlo.cache.RequestCache; 21 import org.openlaszlo.server.LPS; 22 23 import org.apache.log4j.Logger; 24 25 public final class ResponderMEDIA extends ResponderCache 26 { 27 private static MediaCache mCache = null; 28 private static boolean mIsInitialized = false; 29 private static Logger mLogger = Logger.getLogger(ResponderMEDIA.class); 30 31 public void init(String reqName, ServletConfig config, Properties prop) 32 throws ServletException , IOException 33 { 34 if (! mIsInitialized) { 35 String cacheDir = config.getInitParameter("lps.mcache.directory"); 37 if (cacheDir == null) { 38 cacheDir = prop.getProperty("mcache.directory"); 39 } 40 if (cacheDir == null) { 41 cacheDir = LPS.getWorkDirectory() + File.separator + "mcache"; 42 } 43 44 File cache = checkDirectory(cacheDir); 45 mLogger.info("Media Cache is at " + cacheDir); 46 47 try { 48 mCache = new MediaCache(cache, prop); 49 } catch (IOException e) { 50 throw new ServletException (e.getMessage()); 51 } 52 53 mIsInitialized = true; 54 } 55 56 super.init(reqName, config, mCache, prop); 57 } 58 59 static public RequestCache getCache() 60 { 61 return mCache; 62 } 63 } 64 | Popular Tags |