001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.transport.tcp.server.glassfish;
038:
039: import com.sun.xml.ws.api.DistributedPropertySet;
040: import java.io.BufferedReader;
041: import java.io.IOException;
042: import java.io.PrintWriter;
043: import java.io.UnsupportedEncodingException;
044: import java.security.Principal;
045: import java.util.Enumeration;
046: import java.util.Locale;
047: import java.util.Map;
048: import javax.servlet.RequestDispatcher;
049: import javax.servlet.ServletInputStream;
050: import javax.servlet.ServletOutputStream;
051: import javax.servlet.http.Cookie;
052: import javax.servlet.http.HttpServletRequest;
053: import javax.servlet.http.HttpServletResponse;
054: import javax.servlet.http.HttpSession;
055: import javax.xml.ws.handler.MessageContext;
056:
057: /**
058: * @author Alexey Stashok
059: */
060: public final class ServletFakeArtifactSet extends
061: DistributedPropertySet {
062:
063: private static final PropertyMap model;
064:
065: private final HttpServletRequest request;
066: private final HttpServletResponse response;
067:
068: static {
069: model = parse(ServletFakeArtifactSet.class);
070: }
071:
072: public DistributedPropertySet.PropertyMap getPropertyMap() {
073: return model;
074: }
075:
076: public ServletFakeArtifactSet(final String requestURL,
077: final String servletPath) {
078: request = createRequest(requestURL, servletPath);
079: response = createResponse();
080: }
081:
082: @Property(MessageContext.SERVLET_RESPONSE)
083: public HttpServletResponse getResponse() {
084: return response;
085: }
086:
087: @Property(MessageContext.SERVLET_REQUEST)
088: public HttpServletRequest getRequest() {
089: return request;
090: }
091:
092: private static HttpServletRequest createRequest(
093: final String requestURL, final String servletPath) {
094: return new FakeServletHttpRequest(requestURL, servletPath);
095: }
096:
097: private static HttpServletResponse createResponse() {
098: return new FakeServletHttpResponse();
099: }
100:
101: public static final class FakeServletHttpRequest implements
102: HttpServletRequest {
103: private final StringBuffer requestURL;
104: private final String requestURI;
105: private final String servletPath;
106:
107: public FakeServletHttpRequest(final String requestURL,
108: final String servletPath) {
109: this .requestURI = requestURL;
110: this .requestURL = new StringBuffer(requestURL);
111: this .servletPath = servletPath;
112: }
113:
114: public String getAuthType() {
115: return null;
116: }
117:
118: public Cookie[] getCookies() {
119: return null;
120: }
121:
122: public long getDateHeader(final String string) {
123: return 0L;
124: }
125:
126: public String getHeader(final String string) {
127: return null;
128: }
129:
130: public Enumeration getHeaders(final String string) {
131: return null;
132: }
133:
134: public Enumeration getHeaderNames() {
135: return null;
136: }
137:
138: public int getIntHeader(final String string) {
139: return -1;
140: }
141:
142: public String getMethod() {
143: return "POST";
144: }
145:
146: public String getPathInfo() {
147: return null;
148: }
149:
150: public String getPathTranslated() {
151: return null;
152: }
153:
154: public String getContextPath() {
155: return null;
156: }
157:
158: public String getQueryString() {
159: return null;
160: }
161:
162: public String getRemoteUser() {
163: return null;
164: }
165:
166: public boolean isUserInRole(final String string) {
167: return true;
168: }
169:
170: public Principal getUserPrincipal() {
171: return null;
172: }
173:
174: public String getRequestedSessionId() {
175: return null;
176: }
177:
178: public String getRequestURI() {
179: return requestURI;
180: }
181:
182: public StringBuffer getRequestURL() {
183: return requestURL;
184: }
185:
186: public String getServletPath() {
187: return servletPath;
188: }
189:
190: public HttpSession getSession(final boolean b) {
191: return null;
192: }
193:
194: public HttpSession getSession() {
195: return null;
196: }
197:
198: public boolean isRequestedSessionIdValid() {
199: return true;
200: }
201:
202: public boolean isRequestedSessionIdFromCookie() {
203: return true;
204: }
205:
206: public boolean isRequestedSessionIdFromURL() {
207: return true;
208: }
209:
210: public boolean isRequestedSessionIdFromUrl() {
211: return true;
212: }
213:
214: public Object getAttribute(final String string) {
215: return null;
216: }
217:
218: public Enumeration getAttributeNames() {
219: return null;
220: }
221:
222: public String getCharacterEncoding() {
223: return null;
224: }
225:
226: public void setCharacterEncoding(final String string)
227: throws UnsupportedEncodingException {
228: }
229:
230: public int getContentLength() {
231: return 0;
232: }
233:
234: public String getContentType() {
235: return null;
236: }
237:
238: public ServletInputStream getInputStream() throws IOException {
239: return null;
240: }
241:
242: public String getParameter(final String string) {
243: return null;
244: }
245:
246: public Enumeration getParameterNames() {
247: return null;
248: }
249:
250: public String[] getParameterValues(final String string) {
251: return null;
252: }
253:
254: public Map getParameterMap() {
255: return null;
256: }
257:
258: public String getProtocol() {
259: return null;
260: }
261:
262: public String getScheme() {
263: return null;
264: }
265:
266: public String getServerName() {
267: return null;
268: }
269:
270: public int getServerPort() {
271: return 0;
272: }
273:
274: public BufferedReader getReader() throws IOException {
275: return null;
276: }
277:
278: public String getRemoteAddr() {
279: return null;
280: }
281:
282: public String getRemoteHost() {
283: return null;
284: }
285:
286: public void setAttribute(final String string,
287: final Object object) {
288: }
289:
290: public void removeAttribute(final String string) {
291: }
292:
293: public Locale getLocale() {
294: return null;
295: }
296:
297: public Enumeration getLocales() {
298: return null;
299: }
300:
301: public boolean isSecure() {
302: return false;
303: }
304:
305: public RequestDispatcher getRequestDispatcher(
306: final String string) {
307: return null;
308: }
309:
310: public String getRealPath(final String string) {
311: return null;
312: }
313:
314: public int getRemotePort() {
315: return 0;
316: }
317:
318: public String getLocalName() {
319: return null;
320: }
321:
322: public String getLocalAddr() {
323: return null;
324: }
325:
326: public int getLocalPort() {
327: return 0;
328: }
329: }
330:
331: public static final class FakeServletHttpResponse implements
332: HttpServletResponse {
333: public void addCookie(final Cookie cookie) {
334: }
335:
336: public boolean containsHeader(final String string) {
337: return true;
338: }
339:
340: public String encodeURL(final String string) {
341: return null;
342: }
343:
344: public String encodeRedirectURL(final String string) {
345: return null;
346: }
347:
348: public String encodeUrl(final String string) {
349: return null;
350: }
351:
352: public String encodeRedirectUrl(final String string) {
353: return null;
354: }
355:
356: public void sendError(final int i, final String string)
357: throws IOException {
358: }
359:
360: public void sendError(final int i) throws IOException {
361: }
362:
363: public void sendRedirect(final String string)
364: throws IOException {
365: }
366:
367: public void setDateHeader(final String string, final long l) {
368: }
369:
370: public void addDateHeader(final String string, final long l) {
371: }
372:
373: public void setHeader(final String string, final String string0) {
374: }
375:
376: public void addHeader(final String string, final String string0) {
377: }
378:
379: public void setIntHeader(final String string, final int i) {
380: }
381:
382: public void addIntHeader(final String string, final int i) {
383: }
384:
385: public void setStatus(final int i) {
386: }
387:
388: public void setStatus(final int i, final String string) {
389: }
390:
391: public String getCharacterEncoding() {
392: return null;
393: }
394:
395: public String getContentType() {
396: return null;
397: }
398:
399: public ServletOutputStream getOutputStream() throws IOException {
400: return null;
401: }
402:
403: public PrintWriter getWriter() throws IOException {
404: return null;
405: }
406:
407: public void setCharacterEncoding(final String string) {
408: }
409:
410: public void setContentLength(final int i) {
411: }
412:
413: public void setContentType(final String string) {
414: }
415:
416: public void setBufferSize(final int i) {
417: }
418:
419: public int getBufferSize() {
420: return 0;
421: }
422:
423: public void flushBuffer() throws IOException {
424: }
425:
426: public void resetBuffer() {
427: }
428:
429: public boolean isCommitted() {
430: return true;
431: }
432:
433: public void reset() {
434: }
435:
436: public void setLocale(final Locale locale) {
437: }
438:
439: public Locale getLocale() {
440: return null;
441: }
442:
443: }
444: }
|