1 48 49 50 package com.caucho.portal.generic; 51 52 import javax.portlet.PortletContext; 53 import javax.portlet.PortletRequestDispatcher; 54 import javax.servlet.ServletContext ; 55 import java.io.InputStream ; 56 import java.net.URL ; 57 import java.util.Enumeration ; 58 import java.util.Set ; 59 import java.util.logging.Level ; 60 import java.util.logging.Logger ; 61 62 66 public class HttpPortletContext 67 implements PortletContext 68 { 69 static protected final Logger log = 70 Logger.getLogger(HttpPortletContext.class.getName()); 71 72 private ServletContext _servletContext; 73 74 public HttpPortletContext(ServletContext servletContext) 75 { 76 _servletContext = servletContext; 77 } 78 79 82 public String getServerInfo() 83 { 84 return _servletContext.getServerInfo(); 85 } 86 87 90 public int getMinorVersion() 91 { 92 return _servletContext.getMinorVersion(); 93 } 94 95 98 public int getMajorVersion() 99 { 100 return _servletContext.getMajorVersion(); 101 } 102 103 106 public PortletRequestDispatcher getRequestDispatcher(String path) 107 { 108 HttpPortletRequestDispatcher portletDispatcher 109 = new HttpPortletRequestDispatcher(); 110 111 if (portletDispatcher.startWithPath(_servletContext, path)) 112 return portletDispatcher; 113 else { 114 portletDispatcher.finish(); 115 return null; 116 } 117 } 118 119 122 public PortletRequestDispatcher getNamedDispatcher(String name) 123 { 124 HttpPortletRequestDispatcher portletDispatcher 125 = new HttpPortletRequestDispatcher(); 126 127 if (portletDispatcher.startWithName(_servletContext, name)) { 128 return portletDispatcher; 129 } 130 else { 131 portletDispatcher.finish(); 132 return null; 133 } 134 } 135 136 139 public InputStream getResourceAsStream(String path) 140 { 141 return _servletContext.getResourceAsStream(path); 142 } 143 144 147 public String getMimeType(String file) 148 { 149 return _servletContext.getMimeType(file); 150 } 151 152 155 public String getRealPath(String path) 156 { 157 return _servletContext.getRealPath(path); 158 } 159 160 163 public Set getResourcePaths(String path) 164 { 165 return _servletContext.getResourcePaths(path); 166 } 167 168 171 public URL getResource(String path) throws java.net.MalformedURLException 172 { 173 return _servletContext.getResource(path); 174 } 175 176 179 public String getInitParameter(String name) 180 { 181 return _servletContext.getInitParameter(name); 182 } 183 184 187 public Enumeration getInitParameterNames() 188 { 189 return _servletContext.getInitParameterNames(); 190 } 191 192 195 public Object getAttribute(String name) 196 { 197 return _servletContext.getAttribute(name); 198 } 199 200 203 public Enumeration getAttributeNames() 204 { 205 return _servletContext.getAttributeNames(); 206 } 207 208 211 public void removeAttribute(String name) 212 { 213 _servletContext.removeAttribute(name); 214 } 215 216 219 public void setAttribute(String name, Object object) 220 { 221 if (log.isLoggable(Level.FINEST)) { 222 log.finest("setAttribute(" + name + ")"); 223 } 224 _servletContext.setAttribute(name,object); 225 } 226 227 230 public void log(String msg) 231 { 232 log(msg, null); 233 } 234 235 238 public void log(String message, Throwable e) 239 { 240 if (e != null) 241 log.log(Level.WARNING, message, e); 242 else 243 log.info(message); 244 } 245 246 249 public String getPortletContextName() 250 { 251 return _servletContext.getServletContextName(); 252 } 253 254 } 255 256 | Popular Tags |