KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > ltd > getahead > dwr > WebContextFactory


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package uk.ltd.getahead.dwr;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Collection JavaDoc;
20
21 import javax.servlet.ServletConfig JavaDoc;
22 import javax.servlet.ServletContext JavaDoc;
23 import javax.servlet.ServletException JavaDoc;
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26 import javax.servlet.http.HttpSession JavaDoc;
27
28 import org.directwebremoting.Container;
29 import org.directwebremoting.ScriptSession;
30
31 /**
32  * Accessor for the current WebContext.
33  * @author Joe Walker [joe at getahead dot ltd dot uk]
34  * @deprecated Use org.directwebremoting.WebContextFactory
35  */

36 public class WebContextFactory
37 {
38     /**
39      * Accessor for the current WebContext.
40      * @return The current WebContext or null if the current thread was not
41      * started by DWR.
42      * @deprecated Use org.directwebremoting.WebContextFactory.get()
43      */

44     public static WebContext get()
45     {
46         org.directwebremoting.WebContext wctx = org.directwebremoting.WebContextFactory.get();
47         return new ProxyWebContext(wctx);
48     }
49
50     /**
51      * How we support <code>uk.ltd.getahead.dwr.WebContext</code> when we only
52      * have an <code>org.directwebremoting.WebContext</code>.
53      * @author Joe Walker [joe at getahead dot ltd dot uk]
54      */

55     private static final class ProxyWebContext implements uk.ltd.getahead.dwr.WebContext
56     {
57         /**
58          * @param proxy
59          */

60         public ProxyWebContext(org.directwebremoting.WebContext proxy)
61         {
62             this.proxy = proxy;
63         }
64
65         /* (non-Javadoc)
66          * @see org.directwebremoting.WebContext#forwardToString(java.lang.String)
67          */

68         public String JavaDoc forwardToString(String JavaDoc url) throws ServletException JavaDoc, IOException JavaDoc
69         {
70             return proxy.forwardToString(url);
71         }
72
73         /* (non-Javadoc)
74          * @see org.directwebremoting.WebContext#getAllScriptSessions()
75          */

76         public Collection JavaDoc getAllScriptSessions()
77         {
78             return proxy.getAllScriptSessions();
79         }
80
81         /* (non-Javadoc)
82          * @see org.directwebremoting.WebContext#getContainer()
83          */

84         public Container getContainer()
85         {
86             return proxy.getContainer();
87         }
88
89         /* (non-Javadoc)
90          * @see org.directwebremoting.WebContext#getCurrentPage()
91          */

92         public String JavaDoc getCurrentPage()
93         {
94             return proxy.getCurrentPage();
95         }
96
97         /* (non-Javadoc)
98          * @see org.directwebremoting.WebContext#getHttpServletRequest()
99          */

100         public HttpServletRequest JavaDoc getHttpServletRequest()
101         {
102             return proxy.getHttpServletRequest();
103         }
104
105         /* (non-Javadoc)
106          * @see org.directwebremoting.WebContext#getHttpServletResponse()
107          */

108         public HttpServletResponse JavaDoc getHttpServletResponse()
109         {
110             return proxy.getHttpServletResponse();
111         }
112
113         /* (non-Javadoc)
114          * @see org.directwebremoting.WebContext#getScriptSession()
115          */

116         public ScriptSession getScriptSession()
117         {
118             return proxy.getScriptSession();
119         }
120
121         /* (non-Javadoc)
122          * @see org.directwebremoting.WebContext#getScriptSessionsByPage(java.lang.String)
123          */

124         public Collection JavaDoc getScriptSessionsByPage(String JavaDoc url)
125         {
126             return proxy.getScriptSessionsByPage(url);
127         }
128
129         /* (non-Javadoc)
130          * @see org.directwebremoting.WebContext#getServletConfig()
131          */

132         public ServletConfig JavaDoc getServletConfig()
133         {
134             return proxy.getServletConfig();
135         }
136
137         /* (non-Javadoc)
138          * @see org.directwebremoting.WebContext#getServletContext()
139          */

140         public ServletContext JavaDoc getServletContext()
141         {
142             return proxy.getServletContext();
143         }
144
145         /* (non-Javadoc)
146          * @see org.directwebremoting.WebContext#getSession()
147          */

148         public HttpSession JavaDoc getSession()
149         {
150             return proxy.getSession();
151         }
152
153         /* (non-Javadoc)
154          * @see org.directwebremoting.WebContext#getSession(boolean)
155          */

156         public HttpSession JavaDoc getSession(boolean create)
157         {
158             return proxy.getSession(create);
159         }
160
161         /* (non-Javadoc)
162          * @see org.directwebremoting.WebContext#getVersion()
163          */

164         public String JavaDoc getVersion()
165         {
166             return proxy.getVersion();
167         }
168
169         /* (non-Javadoc)
170          * @see org.directwebremoting.WebContext#setCurrentPageInformation(java.lang.String, java.lang.String)
171          */

172         public void setCurrentPageInformation(String JavaDoc page, String JavaDoc scriptSessionId)
173         {
174             proxy.setCurrentPageInformation(page, scriptSessionId);
175         }
176
177         /**
178          * The WebContext that we proxy to
179          */

180         private org.directwebremoting.WebContext proxy;
181     }
182 }
183
Popular Tags