View Javadoc
1   package org.andromda.cartridges.jsf.portlet.myfaces.tomahawk.support;
2   
3   import java.io.InputStream;
4   import java.net.MalformedURLException;
5   import java.net.URL;
6   import java.util.Enumeration;
7   import java.util.Set;
8   
9   import javax.portlet.PortletContext;
10  import javax.servlet.RequestDispatcher;
11  import javax.servlet.Servlet;
12  import javax.servlet.ServletContext;
13  import javax.servlet.ServletException;
14  
15  /**
16   *
17   */
18  public class ServletContextWrapper implements ServletContext
19  {
20      private PortletContext portletContext;
21  
22      /**
23       * @param portletContext
24       */
25      public ServletContextWrapper(PortletContext portletContext)
26      {
27          this.portletContext = portletContext;
28      }
29  
30      /**
31       * @see javax.servlet.ServletContext#getAttribute(String)
32       */
33      public Object getAttribute(String arg0)
34      {
35          return portletContext.getAttribute(arg0);
36      }
37  
38      /**
39       * @see javax.servlet.ServletContext#getAttributeNames()
40       */
41      public Enumeration getAttributeNames()
42      {
43          return portletContext.getAttributeNames();
44      }
45  
46      /**
47       * return null
48       * @see javax.servlet.ServletContext#getContext(String)
49       */
50      public ServletContext getContext(String arg0)
51      {
52          // TODO Portlet API does not have this method
53          return null;
54      }
55  
56      /**
57       * @see javax.servlet.ServletContext#getInitParameter(String)
58       */
59      public String getInitParameter(String arg0)
60      {
61          return portletContext.getInitParameter(arg0);
62      }
63  
64      /**
65       * @see javax.servlet.ServletContext#getInitParameterNames()
66       */
67      public Enumeration getInitParameterNames()
68      {
69          return portletContext.getInitParameterNames();
70      }
71  
72      /**
73       * @see javax.servlet.ServletContext#getMajorVersion()
74       */
75      public int getMajorVersion()
76      {
77          return portletContext.getMajorVersion();
78      }
79  
80      /**
81       * @see javax.servlet.ServletContext#getMimeType(String)
82       */
83      public String getMimeType(String arg0)
84      {
85          return portletContext.getMimeType(arg0);
86      }
87  
88      /**
89       * @see javax.servlet.ServletContext#getMinorVersion()
90       */
91      public int getMinorVersion()
92      {
93          return portletContext.getMinorVersion();
94      }
95  
96      /**
97       * return null
98       * @see javax.servlet.ServletContext#getNamedDispatcher(String)
99       */
100     public RequestDispatcher getNamedDispatcher(String arg0)
101     {
102         // TODO Portlet API does not have this method
103         return null;
104     }
105 
106     /**
107      * @see javax.servlet.ServletContext#getRealPath(String)
108      */
109     public String getRealPath(String arg0)
110     {
111         return portletContext.getRealPath(arg0);
112     }
113 
114     /**
115      * return null
116      * @see javax.servlet.ServletContext#getRequestDispatcher(String)
117      */
118     public RequestDispatcher getRequestDispatcher(String arg0)
119     {
120         // TODO Portlet API does not have this method
121         return null;
122     }
123 
124     /**
125      * @see javax.servlet.ServletContext#getResource(String)
126      */
127     public URL getResource(String arg0) throws MalformedURLException
128     {
129         return portletContext.getResource(arg0);
130     }
131 
132     /**
133      * @see javax.servlet.ServletContext#getResourceAsStream(String)
134      */
135     public InputStream getResourceAsStream(String arg0)
136     {
137         return portletContext.getResourceAsStream(arg0);
138     }
139 
140     /**
141      * @see javax.servlet.ServletContext#getResourcePaths(String)
142      */
143     public Set getResourcePaths(String arg0)
144     {
145         return portletContext.getResourcePaths(arg0);
146     }
147 
148     /**
149      * @see javax.servlet.ServletContext#getServerInfo()
150      */
151     public String getServerInfo()
152     {
153         return portletContext.getServerInfo();
154     }
155 
156     /**
157      * return null
158      * @see javax.servlet.ServletContext#getServlet(String)
159      * @deprecated
160      */
161     @Deprecated
162     public Servlet getServlet(String arg0) throws ServletException
163     {
164         // TODO Portlet API does not have this method
165         return null;
166     }
167 
168     /**
169      * @see javax.servlet.ServletContext#getServletContextName()
170      */
171     public String getServletContextName()
172     {
173         return portletContext.getPortletContextName();
174     }
175 
176     /**
177      * return null
178      * @see javax.servlet.ServletContext#getServletNames()
179      * @deprecated
180      */
181     @Deprecated
182     public Enumeration getServletNames() {
183         // TODO Portlet API does not have this method
184         return null;
185     }
186 
187     /**
188      * return null
189      * @see javax.servlet.ServletContext#getServlets()
190      * @deprecated
191      */
192     @Deprecated
193     public Enumeration getServlets()
194     {
195         // TODO Portlet API does not have this method
196         return null;
197     }
198 
199     /**
200      * @see javax.servlet.ServletContext#log(Exception, String)
201      * @deprecated
202      */
203     @Deprecated
204     public void log(Exception arg0, String arg1)
205     {
206         portletContext.log(arg1, new Exception(arg0));
207     }
208 
209     /**
210      * @see javax.servlet.ServletContext#log(String,
211      *      Throwable)
212      */
213     public void log(String arg0, Throwable arg1)
214     {
215         portletContext.log(arg0, arg1);
216     }
217 
218     /**
219      * @see javax.servlet.ServletContext#log(String)
220      */
221     public void log(String arg0)
222     {
223         portletContext.log(arg0);
224     }
225 
226     /**
227      * @see javax.servlet.ServletContext#removeAttribute(String)
228      */
229     public void removeAttribute(String arg0)
230     {
231         portletContext.removeAttribute(arg0);
232     }
233 
234     /**
235      * @see javax.servlet.ServletContext#setAttribute(String,
236      *      Object)
237      */
238     public void setAttribute(String arg0, Object arg1)
239     {
240         portletContext.setAttribute(arg0, arg1);
241     }
242 
243     /**
244      * @see javax.servlet.ServletContext#getContextPath()
245      */
246     public String getContextPath()
247     {
248         return portletContext.getPortletContextName();
249     }
250 }