001: /*
002: * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc.
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: *
018: */
019: package com.nabhinc.ws.server;
020:
021: import javax.servlet.http.HttpServletRequest;
022: import javax.servlet.http.HttpServletResponse;
023:
024: import com.nabhinc.core.WebServiceRequest;
025:
026: /**
027: * Object attached to every Web service request that supplies request-related
028: * information such as <code>WebServiceRequest</code> object, <code>HttpServletRequest</code>
029: * object and <code>HttpServletResponse</code> object.
030: *
031: * @author Padmanabh Dabke
032: * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
033: */
034: public class RequestContext {
035: /**
036: * Logger
037: */
038: //private Log logger = LogFactory.getLog(RequestContext.class);
039: /**
040: * Web service request
041: */
042: private WebServiceRequest webServiceRequest = null;
043:
044: /**
045: * HTTP request
046: */
047: private HttpServletRequest httpServletRequest = null;
048:
049: /**
050: * HTTP response
051: */
052: private HttpServletResponse httpServletResponse = null;
053:
054: /**
055: * Constructs a <code>RequestContext</code> object associated
056: * with supplied HTTP request and response. It also creates
057: * a <code>HTTPWebServiceRequest</code> instance associated
058: * with the HTTP request.
059: * @param req HTTP request
060: * @param resp HTTP response
061: */
062: public RequestContext(HttpServletRequest req,
063: HttpServletResponse resp) {
064: httpServletRequest = req;
065: httpServletResponse = resp;
066: webServiceRequest = new HTTPWebServiceRequest(req);
067: }
068:
069: /**
070: * Returns HTTP servlet request associated with this context.
071: * Developers should not call this method in their Web service implementations
072: * unless they want to limit the service to run inside a servlet container. For
073: * portability to non-HTTP servers, they should use equivalent methods
074: * on WebServiceRequest object.
075: * @return HTTP servlet request associated with this context.
076: */
077: public HttpServletRequest getHttpServletRequest() {
078: return httpServletRequest;
079: }
080:
081: public void setHttpServletRequest(
082: HttpServletRequest httpServletRequest) {
083: this .httpServletRequest = httpServletRequest;
084: }
085:
086: /**
087: * Returns HTTP servlet response associated with this context.
088: * Developers should not call this method in their Web service implementations
089: * unless they want to limit the service to run inside a servlet container.
090: *
091: * @return HTTP servlet response associated with this context.
092: */
093:
094: public HttpServletResponse getHttpServletResponse() {
095: return httpServletResponse;
096: }
097:
098: public void setHttpServletResponse(
099: HttpServletResponse httpServletResponse) {
100: this .httpServletResponse = httpServletResponse;
101: }
102:
103: /**
104: * Returns the <code>WebServiceRequest</code> object associated with this
105: * context. Web service developers should get this object to obtain
106: * protocol-independent access to request attribute, remote user information, etc.
107: * @return WebServiceRequest associated with this context
108: */
109: public WebServiceRequest getWebServiceRequest() {
110: return webServiceRequest;
111: }
112:
113: public void setWebServiceRequest(WebServiceRequest webServiceRequest) {
114: this.webServiceRequest = webServiceRequest;
115: }
116:
117: }
|