1 package net.sf.uitags.js; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletConfig ; 6 import javax.servlet.ServletException ; 7 import javax.servlet.http.HttpServlet ; 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpServletResponse ; 10 11 17 public final class JsProviderServlet extends HttpServlet { 18 19 private static final long serialVersionUID = 100L; 20 21 25 27 static final String DIR = "directory"; 28 static final String SUITES = "suites"; 29 static final String CUSTOM_FILES = "customFiles"; 30 static final String DEBUG = "debug"; 31 32 33 34 38 private JsFiles jsFiles; 39 40 41 42 46 public void init(ServletConfig config) throws ServletException { 47 Suites suites = Suites.getInstance(config.getInitParameter(SUITES)); 48 FileFinder fileFinder = FileFinder.getInstance( 49 config.getServletContext(), config.getInitParameter(DIR)); 50 51 this.jsFiles = new JsFiles(suites, fileFinder); 52 this.jsFiles.setCustomFileNames(config.getInitParameter(CUSTOM_FILES)); 53 this.jsFiles.setInDebugMode( 54 Boolean.valueOf(config.getInitParameter(DEBUG)).booleanValue()); 55 } 56 57 58 59 63 66 protected void doPost(HttpServletRequest request, HttpServletResponse response) 67 throws ServletException , IOException { 68 super.doPost(request, response); 69 } 70 71 protected void doGet(HttpServletRequest request, HttpServletResponse response) 72 throws ServletException , IOException { 73 response.getOutputStream().println(this.jsFiles.getContents()); 74 } 75 76 protected long getLastModified(HttpServletRequest arg0) { 77 long lastModified = this.jsFiles.getLastModified(); 78 return (lastModified == 0)? -1 : lastModified; 79 } 80 } 81 | Popular Tags |