annotate src/org/eclipse/jetty/io/nio/ChannelEndPoint.java @ 1050:5ef954fad97b

remove JBuffer.sliceFrom()
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 23:49:41 -0700
parents 4afdf0f0c5bc
children 4a50422596b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.io.nio;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.io.IOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.net.InetSocketAddress;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 import java.net.Socket;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import java.net.SocketException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import java.nio.ByteBuffer;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 import java.nio.channels.ByteChannel;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import java.nio.channels.GatheringByteChannel;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import java.nio.channels.SocketChannel;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
30 import org.eclipse.jetty.io.JBuffer;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 import org.eclipse.jetty.io.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.util.StringUtil;
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
33 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
34 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 * Channel End Point.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 * <p>Holds the channel and socket for an NIO endpoint.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 public class ChannelEndPoint implements EndPoint
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 {
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
43 private static final Logger LOG = LoggerFactory.getLogger(ChannelEndPoint.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
45 private final SocketChannel _channel;
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
46 private final ByteBuffer[] _gather2 = new ByteBuffer[2];
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
47 protected final Socket _socket;
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
48 private final InetSocketAddress _local;
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
49 private final InetSocketAddress _remote;
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
50 protected volatile int _maxIdleTime;
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
51 private volatile boolean _ishut = false;
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
52 private volatile boolean _oshut = false;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
54 protected ChannelEndPoint(SocketChannel channel, int maxIdleTime) throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
55 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
56 this._channel = channel;
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
57 _maxIdleTime = maxIdleTime;
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
58 _socket = channel.socket();
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
59 _local = (InetSocketAddress)_socket.getLocalSocketAddress();
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
60 _remote = (InetSocketAddress)_socket.getRemoteSocketAddress();
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
61 _socket.setSoTimeout(_maxIdleTime);
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
63
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
64 @Override
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
65 public final boolean isBlocking()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
66 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
67 return _channel.isBlocking();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
69
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
70 @Override
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
71 public boolean blockReadable(long millisecs) throws IOException
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
72 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 return true;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
75
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
76 @Override
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 public boolean blockWritable(long millisecs) throws IOException
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
78 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
79 return true;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
80 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
81
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
82 @Override
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
83 public final boolean isOpen()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
84 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
85 return _channel.isOpen();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
87
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
88 @Override
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
89 public final void shutdownInput() throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
91 LOG.debug("ishut {}", this);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
92 _ishut = true;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
93 if (_channel.isOpen())
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
95 try
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
97 if (!_socket.isInputShutdown())
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
98 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
99 _socket.shutdownInput();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 }
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
101 }
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
102 catch (SocketException e)
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
103 {
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
104 LOG.debug(e.toString());
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
105 LOG.trace("",e);
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
106 }
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
107 finally
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
108 {
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
109 if (_oshut)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
111 close();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
116
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
117 @Override
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
118 public final void shutdownOutput() throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 LOG.debug("oshut {}",this);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
121 _oshut = true;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 if (_channel.isOpen())
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
123 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
124 try
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
126 if (!_socket.isOutputShutdown())
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
128 _socket.shutdownOutput();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 }
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
130 }
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
131 catch (SocketException e)
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
132 {
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
133 LOG.debug(e.toString());
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
134 LOG.trace("",e);
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
135 }
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
136 finally
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
137 {
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
138 if (_ishut)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
140 close();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
144 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
145
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
146 @Override
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
147 public final boolean isOutputShutdown()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
148 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
149 return _oshut || !_channel.isOpen() || _socket.isOutputShutdown();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
151
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
152 @Override
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
153 public final boolean isInputShutdown()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
155 return _ishut || !_channel.isOpen() || _socket.isInputShutdown();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
157
960
3cd4c706a61f simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 958
diff changeset
158 @Override
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 public void close() throws IOException
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 {
1005
0e96ce3db20a remove HttpBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 986
diff changeset
161 //Thread.dumpStack();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
162 LOG.debug("close {}",this);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
163 _channel.close();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
164 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
165
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
166 @Override
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
167 public int fill(JBuffer buffer) throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
168 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 if (_ishut)
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 return -1;
1005
0e96ce3db20a remove HttpBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 986
diff changeset
171 int len = 0;
1049
4afdf0f0c5bc remove unused JBuffer methods
Franklin Schmidt <fschmidt@gmail.com>
parents: 1048
diff changeset
172 final ByteBuffer bbuf = buffer.getByteBuffer();
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
173
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
174 //noinspection SynchronizationOnLocalVariableOrMethodParameter
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
175 try
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
176 {
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
177 synchronized(bbuf)
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
178 {
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
179 try
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
180 {
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
181 bbuf.position(buffer.putIndex());
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
182 len = _channel.read(bbuf);
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
183 }
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
184 finally
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
185 {
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
186 buffer.setPutIndex(bbuf.position());
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
187 bbuf.position(0);
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
188 }
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
189 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
190
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
191 if (len<0 && isOpen())
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
192 {
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
193 if (!isInputShutdown())
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
194 shutdownInput();
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
195 if (isOutputShutdown())
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
196 _channel.close();
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
197 }
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
198 }
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
199 catch (IOException x)
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
200 {
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
201 LOG.debug("Exception while filling", x);
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 try
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 {
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
204 if (_channel.isOpen())
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
205 _channel.close();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
206 }
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
207 catch (Exception xx)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 {
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
209 LOG.trace("",xx);
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
210 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
211
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
212 if (len>0)
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
213 throw x;
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
214 len = -1;
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
215 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
216
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 return len;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
218 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
219
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
220 @Override
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
221 public int flush(JBuffer buffer) throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
222 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
223 int len=0;
1049
4afdf0f0c5bc remove unused JBuffer methods
Franklin Schmidt <fschmidt@gmail.com>
parents: 1048
diff changeset
224 final ByteBuffer bbuf = buffer.getByteBuffer().asReadOnlyBuffer();
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
225 try
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 {
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
227 bbuf.position(buffer.getIndex());
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
228 bbuf.limit(buffer.putIndex());
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
229 len=_channel.write(bbuf);
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 }
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
231 finally
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
232 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
233 if (len>0)
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
234 buffer.skip(len);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
235 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
236 return len;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
237 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
238
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
239 @Override
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
240 public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
241 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 int length=0;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
243
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 if (_channel instanceof GatheringByteChannel &&
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
245 header!=null && header.remaining()!=0 &&
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
246 buffer!=null && buffer.remaining()!=0)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 {
1049
4afdf0f0c5bc remove unused JBuffer methods
Franklin Schmidt <fschmidt@gmail.com>
parents: 1048
diff changeset
248 length = gatheringFlush(header,header.getByteBuffer(),buffer,buffer.getByteBuffer());
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
250 else
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
251 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 // flush header
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
253 if (header!=null && header.remaining()>0)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
254 length=flush(header);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
255
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
256 // flush buffer
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
257 if ((header==null || header.remaining()==0) &&
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
258 buffer!=null && buffer.remaining()>0)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
259 length+=flush(buffer);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
260
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
261 // flush trailer
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
262 if ((header==null || header.remaining()==0) &&
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
263 (buffer==null || buffer.remaining()==0) &&
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
264 trailer!=null && trailer.remaining()>0)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 length+=flush(trailer);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
266 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
267
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
268 return length;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
269 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
270
1048
2b769da7f67d remove Buffer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1046
diff changeset
271 private int gatheringFlush(JBuffer header, ByteBuffer bbuf0, JBuffer buffer, ByteBuffer bbuf1) throws IOException
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
272 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
273 int length;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
274
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
275 synchronized(this)
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
276 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
277 // Adjust position indexs of buf0 and buf1
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
278 bbuf0=bbuf0.asReadOnlyBuffer();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
279 bbuf0.position(header.getIndex());
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
280 bbuf0.limit(header.putIndex());
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
281 bbuf1=bbuf1.asReadOnlyBuffer();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
282 bbuf1.position(buffer.getIndex());
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
283 bbuf1.limit(buffer.putIndex());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
284
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
285 _gather2[0]=bbuf0;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
286 _gather2[1]=bbuf1;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
287
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
288 // do the gathering write.
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
289 length=(int)((GatheringByteChannel)_channel).write(_gather2);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
290
1038
b71ad168fe34 rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents: 1031
diff changeset
291 int hl=header.remaining();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
292 if (length>hl)
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
293 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
294 header.clear();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
295 buffer.skip(length-hl);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 else if (length>0)
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
298 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
299 header.skip(length);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
300 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
301 }
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
302 return length;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
303 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
304
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
305 public final SocketChannel getChannel()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
306 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
307 return _channel;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
308 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
309
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
310 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
311 public final String getLocalAddr()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
312 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
313 if (_local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
314 return StringUtil.ALL_INTERFACES;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
315 return _local.getAddress().getHostAddress();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
316 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
317
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
318 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
319 public final String getLocalHost()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
320 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
321 if (_local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
322 return StringUtil.ALL_INTERFACES;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
323 return _local.getAddress().getCanonicalHostName();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
324 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
325
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
326 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
327 public final int getLocalPort()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
328 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
329 return _local.getPort();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
330 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
331
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
332 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
333 public final String getRemoteAddr()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
334 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
335 return _remote.getAddress().getHostAddress();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
336 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
337
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
338 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
339 public final String getRemoteHost()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
340 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
341 return _remote.getAddress().getCanonicalHostName();
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
342 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
343
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
344 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
345 public final int getRemotePort()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
346 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
347 return _remote.getPort();
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
348 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
349
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
350 @Override
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
351 public void flush()
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
352 throws IOException
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
353 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
354 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
355
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
356 @Override
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
357 public final int getMaxIdleTime()
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
358 {
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
359 return _maxIdleTime;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
360 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
361
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
362 @Override
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
363 public void setMaxIdleTime(int timeMs) throws IOException
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
364 {
978
bdb6eb0fbf93 simplify ChannelEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 965
diff changeset
365 if (timeMs!=_maxIdleTime)
873
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
366 _socket.setSoTimeout(timeMs>0?timeMs:0);
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
367 _maxIdleTime=timeMs;
220ad4853cda remove StreamEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
368 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
369 }