KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.directwebremoting.WebContext;
31 import org.directwebremoting.WebContextFactory;
32
33 /**
34  * Class to enable us to access servlet parameters.
35  * @author Joe Walker [joe at getahead dot ltd dot uk]
36  * @deprecated Use WebContext / WebContextFactory for better results
37  */

38 public class ExecutionContext implements WebContext
39 {
40     /**
41      * Create an ExecutionContext for compatibility purposes with a real
42      * WebContext to proxy to.
43      * @param proxy The WebContext to proxy to.
44      */

45     private ExecutionContext(WebContext proxy)
46     {
47         this.proxy = proxy;
48     }
49
50     /* (non-Javadoc)
51      * @see uk.ltd.getahead.dwr.WebContext#getSession()
52      */

53     public HttpSession JavaDoc getSession()
54     {
55         return proxy.getSession();
56     }
57
58     /* (non-Javadoc)
59      * @see uk.ltd.getahead.dwr.WebContext#getSession(boolean)
60      */

61     public HttpSession JavaDoc getSession(boolean create)
62     {
63         return proxy.getSession(create);
64     }
65
66     /* (non-Javadoc)
67      * @see uk.ltd.getahead.dwr.WebContext#getServletConfig()
68      */

69     public ServletConfig JavaDoc getServletConfig()
70     {
71         return proxy.getServletConfig();
72     }
73
74     /* (non-Javadoc)
75      * @see uk.ltd.getahead.dwr.WebContext#getServletContext()
76      */

77     public ServletContext JavaDoc getServletContext()
78     {
79         return proxy.getServletContext();
80     }
81
82     /* (non-Javadoc)
83      * @see uk.ltd.getahead.dwr.WebContext#getHttpServletRequest()
84      */

85     public HttpServletRequest JavaDoc getHttpServletRequest()
86     {
87         return proxy.getHttpServletRequest();
88     }
89
90     /* (non-Javadoc)
91      * @see uk.ltd.getahead.dwr.WebContext#getHttpServletResponse()
92      */

93     public HttpServletResponse JavaDoc getHttpServletResponse()
94     {
95         return proxy.getHttpServletResponse();
96     }
97
98     /* (non-Javadoc)
99      * @see uk.ltd.getahead.dwr.WebContext#forwardToString(java.lang.String)
100      */

101     public String JavaDoc forwardToString(String JavaDoc url) throws ServletException JavaDoc, IOException JavaDoc
102     {
103         return proxy.forwardToString(url);
104     }
105
106     /* (non-Javadoc)
107      * @see uk.ltd.getahead.dwr.WebContext#getVersion()
108      */

109     public String JavaDoc getVersion()
110     {
111         return proxy.getVersion();
112     }
113
114     /* (non-Javadoc)
115      * @see uk.ltd.getahead.dwr.WebContext#getBrowser()
116      */

117     public ScriptSession getScriptSession()
118     {
119         throw new UnsupportedOperationException JavaDoc("Use WebContextFactory.get().getPage()");
120     }
121
122     /* (non-Javadoc)
123      * @see uk.ltd.getahead.dwr.WebContext#getAllScriptSessions()
124      */

125     public Collection JavaDoc getAllScriptSessions()
126     {
127         throw new UnsupportedOperationException JavaDoc("Use WebContextFactory.get().getAllScriptSessions()");
128     }
129
130     /* (non-Javadoc)
131      * @see uk.ltd.getahead.dwr.WebContext#getScriptSessionsByPage(java.lang.String)
132      */

133     public Collection JavaDoc getScriptSessionsByPage(String JavaDoc page)
134     {
135         throw new UnsupportedOperationException JavaDoc("Use WebContextFactory.get().getScriptSessionsByPage()");
136     }
137
138     /* (non-Javadoc)
139      * @see uk.ltd.getahead.dwr.WebContext#getContainer()
140      */

141     public Container getContainer()
142     {
143         throw new UnsupportedOperationException JavaDoc("Use WebContextFactory.get().getContainer()");
144     }
145
146     /* (non-Javadoc)
147      * @see uk.ltd.getahead.dwr.WebContext#setScriptSessionId(java.lang.String)
148      */

149     public void setCurrentPageInformation(String JavaDoc page, String JavaDoc scriptSessionId)
150     {
151         throw new UnsupportedOperationException JavaDoc("Use WebContextFactory.get().setPageAndSessionIds()");
152     }
153
154     /* (non-Javadoc)
155      * @see uk.ltd.getahead.dwr.WebContext#getCurrentPage()
156      */

157     public String JavaDoc getCurrentPage()
158     {
159         throw new UnsupportedOperationException JavaDoc("Use WebContextFactory.get().toJavascript()");
160     }
161
162     /**
163      * Accessor for the current ExecutionContext.
164      * @return The current ExecutionContext or null if the current thread was
165      * not started by DWR.
166      * @deprecated Use WebContextFactory.get() for better results
167      */

168     public static ExecutionContext get()
169     {
170         WebContext context = WebContextFactory.get();
171         if (context == null)
172         {
173             return null;
174         }
175
176         return new ExecutionContext(context);
177     }
178
179     /**
180      * The real WebContext to proxy to
181      */

182     private WebContext proxy = null;
183 }
184
Popular Tags