1    //
2    // SwitchRMI  Framework
3    // Copyright (c) 2002 by Michael J. Henderson & Associates.
4    //
5    // Michael Henderson
6    // http://switchrmi.sf.net
7    // mailto:mikehenderson@dunelm.org.uk
8    //
9    // This library is free software.
10   //
11   // You may redistribute it and/or modify it under the terms of the GNU
12   // Lesser General Public License as published by the Free Software Foundation.
13   //
14   // Version 2.1 of the license should be included with this distribution in
15   // the file LICENSE, as well as License.html. If the license is not
16   // included with this distribution, you may find a copy at the FSF web
17   // site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
18   // Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
19   //
20   // This library is distributed in the hope that it will be useful,
21   // but WITHOUT ANY WARRANTY; without even the implied waranty of
22   // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23   // Lesser General Public License for more details.
24   //
25   // $Id: HttpServletTransport.java,v 1.1 2002/11/11 22:19:48 mikehenderson Exp $
26   package com.mjh.switchrmi.transport.http;
27   
28   import com.mjh.switchrmi.*;
29   
30   import java.io.IOException;
31   import java.io.InputStream;
32   import java.io.OutputStream;
33   
34   import javax.servlet.http.HttpServletRequest;
35   import javax.servlet.http.HttpServletResponse;
36   
37   public class HttpServletTransport
38       extends RmiTransportBase
39   {
40       private HttpServletRequest request;
41       private HttpServletResponse response;
42   
43       public HttpServletTransport()
44       {
45           super.setType(RmiTransport.SYNCHRONOUS);
46           super.setName("http");
47       }
48   
49       public void setServletRequest(HttpServletRequest req)
50       {
51           request = req;
52       }
53   
54       public void setServletResponse(HttpServletResponse resp)
55       {
56           response = resp;
57       }
58   
59       public InputStream getInputStream(RmiContext context)
60           throws IOException
61       {
62           return request.getInputStream();
63       }
64   
65       public OutputStream getOutputStream(RmiContext context)
66           throws IOException
67       {
68           return response.getOutputStream();
69       }
70   
71       public void send(RmiContext context)
72       {
73           response.setHeader("Cache-Control", "no-cache");
74       }
75   }