1 package org.apache.beehive.controls.runtime.servlet; 2 19 20 import java.beans.beancontext.BeanContextServices ; 21 import java.beans.beancontext.BeanContextServiceProvider ; 22 import java.util.Iterator ; 23 24 import javax.servlet.ServletContext ; 25 import javax.servlet.ServletRequest ; 26 import javax.servlet.ServletRequestWrapper ; 27 import javax.servlet.ServletResponse ; 28 import javax.servlet.ServletResponseWrapper ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletRequestWrapper ; 31 import javax.servlet.http.HttpServletResponse ; 32 import javax.servlet.http.HttpServletResponseWrapper ; 33 34 38 class ServletServiceProvider implements BeanContextServiceProvider 39 { 40 static final private ServletServiceProvider _provider = new ServletServiceProvider(); 41 42 static final ServletServiceProvider getProvider() { return _provider; } 43 44 ServletServiceProvider() {} 45 46 public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, 47 Object serviceSelector) 48 { 49 if (! (bcs instanceof ServletBeanContext)) 54 return null; 55 56 ServletBeanContext sbc = (ServletBeanContext)bcs; 57 if (serviceClass.equals(ServletContext .class)) 58 return new ServletContextService(sbc); 59 60 if (serviceClass.equals(HttpServletRequest .class)) 61 { 62 HttpRequestService requestService = new HttpRequestService(sbc); 63 if (sbc.useWrappers()) 64 return requestService.getHttpRequestWrapper(); 65 return requestService; 66 } 67 68 if (serviceClass.equals(HttpServletResponse .class)) 69 { 70 HttpResponseService responseService = new HttpResponseService(sbc); 71 if (sbc.useWrappers()) 72 return responseService.getHttpResponseWrapper(); 73 return responseService; 74 } 75 76 if (serviceClass.equals(ServletRequest .class)) 77 { 78 ServletRequestService requestService = new ServletRequestService(sbc); 79 if (sbc.useWrappers()) 80 return requestService.getRequestWrapper(); 81 return requestService; 82 } 83 84 if (serviceClass.equals(ServletResponse .class)) 85 { 86 ServletResponseService responseService = new ServletResponseService(sbc); 87 if (sbc.useWrappers()) 88 return responseService.getResponseWrapper(); 89 return responseService; 90 } 91 92 return null; 93 } 94 95 public void releaseService(BeanContextServices bcs, Object requestor, Object service) 96 { 97 } 99 100 public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) 101 { 102 return null; } 104 } 105 | Popular Tags |