1 29 30 package com.caucho.jsp; 31 32 import com.caucho.server.webapp.WebApp; 33 import com.caucho.util.FreeList; 34 35 import javax.servlet.Servlet ; 36 import javax.servlet.ServletContext ; 37 import javax.servlet.ServletRequest ; 38 import javax.servlet.ServletResponse ; 39 import javax.servlet.http.HttpSession ; 40 import javax.servlet.jsp.JspApplicationContext ; 41 import javax.servlet.jsp.JspEngineInfo ; 42 import javax.servlet.jsp.JspFactory ; 43 import javax.servlet.jsp.PageContext ; 44 45 public class QJspFactory extends JspFactory { 46 private static JspEngineInfo _engineInfo = new EngineInfo (); 47 48 private static FreeList<PageContextImpl> _freePages = 49 new FreeList<PageContextImpl>(32); 50 51 private static QJspFactory _factory; 52 53 static public QJspFactory create() 54 { 55 if (_factory == null) 56 _factory = new QJspFactory(); 57 58 return _factory; 59 } 60 61 public static PageContextImpl allocatePageContext(Servlet servlet, 62 ServletRequest request, 63 ServletResponse response, 64 String errorPageURL, 65 boolean needsSession, 66 int buffer, 67 boolean autoFlush) 68 { 69 PageContextImpl pc = _freePages.allocate(); 70 if (pc == null) 71 pc = new PageContextImpl(); 72 73 try { 74 pc.initialize(servlet, request, response, errorPageURL, 75 needsSession, buffer, autoFlush); 76 } catch (Exception e) { 77 } 78 79 return pc; 80 } 81 82 85 public static PageContextImpl allocatePageContext(Servlet servlet, 86 WebApp app, 87 ServletRequest request, 88 ServletResponse response, 89 String errorPageURL, 90 HttpSession session, 91 int buffer, 92 boolean autoFlush, 93 boolean isPrintNullAsBlank) 94 { 95 PageContextImpl pc = _freePages.allocate(); 96 if (pc == null) 97 pc = new PageContextImpl(); 98 99 pc.initialize(servlet, app, request, response, errorPageURL, 100 session, buffer, autoFlush, isPrintNullAsBlank); 101 102 return pc; 103 } 104 105 public PageContext getPageContext(Servlet servlet, 106 ServletRequest request, 107 ServletResponse response, 108 String errorPageURL, 109 boolean needsSession, 110 int buffer, 111 boolean autoFlush) 112 { 113 return allocatePageContext(servlet, request, response, 114 errorPageURL, needsSession, 115 buffer, autoFlush); 116 } 117 118 123 public void releasePageContext(PageContext pc) 124 { 125 if (pc != null) { 126 pc.release(); 127 128 if (pc instanceof PageContextImpl) 129 _freePages.free((PageContextImpl) pc); 130 } 131 } 132 133 public static void freePageContext(PageContext pc) 134 { 135 if (pc != null) { 136 pc.release(); 137 138 if (pc instanceof PageContextImpl) 139 _freePages.free((PageContextImpl) pc); 140 } 141 } 142 143 public String getSpecificationVersion() 145 { 146 return getEngineInfo().getSpecificationVersion(); 147 } 148 149 public JspEngineInfo getEngineInfo() 150 { 151 return _engineInfo; 152 } 153 154 public JspApplicationContext getJspApplicationContext(ServletContext context) 155 { 156 return ((WebApp) context).getJspApplicationContext(); 157 } 158 159 static class EngineInfo extends JspEngineInfo { 160 public String getSpecificationVersion() 161 { 162 return "2.0"; 163 } 164 } 165 } 166 | Popular Tags |