1 16 package org.directwebremoting.convert; 17 18 import javax.servlet.ServletConfig ; 19 import javax.servlet.ServletContext ; 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.http.HttpServletResponse ; 22 import javax.servlet.http.HttpSession ; 23 24 import org.directwebremoting.WebContext; 25 import org.directwebremoting.WebContextFactory; 26 import org.directwebremoting.dwrp.SimpleOutboundVariable; 27 import org.directwebremoting.extend.Converter; 28 import org.directwebremoting.extend.InboundContext; 29 import org.directwebremoting.extend.InboundVariable; 30 import org.directwebremoting.extend.OutboundContext; 31 import org.directwebremoting.extend.OutboundVariable; 32 33 38 public class ServletConverter extends BaseV20Converter implements Converter 39 { 40 43 public Object convertInbound(Class paramType, InboundVariable iv, InboundContext inctx) 44 { 45 WebContext webcx = WebContextFactory.get(); 46 47 if (HttpServletRequest .class.isAssignableFrom(paramType)) 48 { 49 return webcx.getHttpServletRequest(); 50 } 51 52 if (HttpServletResponse .class.isAssignableFrom(paramType)) 53 { 54 return webcx.getHttpServletResponse(); 55 } 56 57 if (ServletConfig .class.isAssignableFrom(paramType)) 58 { 59 return webcx.getServletConfig(); 60 } 61 62 if (ServletContext .class.isAssignableFrom(paramType)) 63 { 64 return webcx.getServletContext(); 65 } 66 67 if (HttpSession .class.isAssignableFrom(paramType)) 68 { 69 return webcx.getSession(true); 70 } 71 72 return null; 73 } 74 75 78 public OutboundVariable convertOutbound(Object data, OutboundContext outctx) 79 { 80 return new SimpleOutboundVariable("null", outctx, true); 81 } 82 } 83
| Popular Tags
|