001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.server.connection;
031:
032: import com.caucho.vfs.VfsStream;
033:
034: import java.io.InputStream;
035: import java.io.OutputStream;
036: import java.net.InetAddress;
037:
038: /**
039: * A Connection based on streams. Stream connection is primarily used
040: * for testing.
041: */
042: public class StreamConnection extends Connection {
043: private int _id = 1;
044: private InetAddress _localAddress;
045: private int _localPort;
046: private String _virtualHost;
047: private InetAddress _remoteAddress;
048: private int _remotePort;
049: private boolean _isSecure;
050:
051: public StreamConnection() {
052: }
053:
054: public StreamConnection(InputStream is, OutputStream os) {
055: setStream(is, os);
056: }
057:
058: public int getId() {
059: return _id;
060: }
061:
062: public InetAddress getLocalAddress() {
063: return _localAddress;
064: }
065:
066: public int getLocalPort() {
067: return _localPort;
068: }
069:
070: public InetAddress getRemoteAddress() {
071: return _remoteAddress;
072: }
073:
074: public int getRemotePort() {
075: return _remotePort;
076: }
077:
078: public void setRemotePort(int port) {
079: _remotePort = port;
080: }
081:
082: public String getVirtualHost() {
083: return _virtualHost;
084: }
085:
086: public void setVirtualHost(String virtualHost) {
087: _virtualHost = virtualHost;
088: }
089:
090: public void setStream(InputStream is, OutputStream os) {
091: VfsStream _vfsStream = new VfsStream(is, os);
092: getWriteStream().init(_vfsStream);
093: getReadStream().init(_vfsStream, getWriteStream());
094: }
095:
096: public void setSecure(boolean isSecure) {
097: _isSecure = isSecure;
098: }
099:
100: public boolean isSecure() {
101: return _isSecure;
102: }
103:
104: public void setLocalAddress(InetAddress addr) {
105: _localAddress = addr;
106: }
107:
108: public void setLocalPort(int port) {
109: _localPort = port;
110: }
111:
112: public void setRemoteAddress(InetAddress addr) {
113: _remoteAddress = addr;
114: }
115: }
|