KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > connection > StreamConnection


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.server.connection;
31
32 import com.caucho.vfs.VfsStream;
33
34 import java.io.InputStream JavaDoc;
35 import java.io.OutputStream JavaDoc;
36 import java.net.InetAddress JavaDoc;
37
38 /**
39  * A Connection based on streams. Stream connection is primarily used
40  * for testing.
41  */

42 public class StreamConnection extends Connection {
43   private int _id = 1;
44   private InetAddress JavaDoc _localAddress;
45   private int _localPort;
46   private String JavaDoc _virtualHost;
47   private InetAddress JavaDoc _remoteAddress;
48   private int _remotePort;
49   private boolean _isSecure;
50
51   public StreamConnection()
52   {
53   }
54
55   public StreamConnection(InputStream JavaDoc is, OutputStream JavaDoc os)
56   {
57     setStream(is, os);
58   }
59
60   public int getId()
61   {
62     return _id;
63   }
64
65   public InetAddress JavaDoc getLocalAddress()
66   {
67     return _localAddress;
68   }
69
70   public int getLocalPort()
71   {
72     return _localPort;
73   }
74
75   public InetAddress JavaDoc getRemoteAddress()
76   {
77     return _remoteAddress;
78   }
79
80   public int getRemotePort()
81   {
82     return _remotePort;
83   }
84
85   public void setRemotePort(int port)
86   {
87     _remotePort = port;
88   }
89
90   public String JavaDoc getVirtualHost()
91   {
92     return _virtualHost;
93   }
94
95   public void setVirtualHost(String JavaDoc virtualHost)
96   {
97     _virtualHost = virtualHost;
98   }
99
100   public void setStream(InputStream JavaDoc is, OutputStream JavaDoc os)
101   {
102     VfsStream _vfsStream = new VfsStream(is, os);
103     getWriteStream().init(_vfsStream);
104     getReadStream().init(_vfsStream, getWriteStream());
105   }
106
107   public void setSecure(boolean isSecure)
108   {
109     _isSecure = isSecure;
110   }
111
112   public boolean isSecure()
113   {
114     return _isSecure;
115   }
116
117   public void setLocalAddress(InetAddress JavaDoc addr)
118   {
119     _localAddress = addr;
120   }
121
122   public void setLocalPort(int port)
123   {
124     _localPort = port;
125   }
126
127   public void setRemoteAddress(InetAddress JavaDoc addr)
128   {
129     _remoteAddress = addr;
130   }
131 }
132
Popular Tags