Fix various checkstyle violations
Backported from master
This commit is contained in:
parent
53fede511c
commit
e2109b236b
@ -215,7 +215,7 @@ public class Bootstrap implements ExternalResourceReleasable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChannelPipeline pipeline = pipeline();
|
ChannelPipeline pipeline = pipeline();
|
||||||
for(Map.Entry<String, ChannelHandler> e: pipelineMap.entrySet()) {
|
for (Map.Entry<String, ChannelHandler> e: pipelineMap.entrySet()) {
|
||||||
pipeline.addLast(e.getKey(), e.getValue());
|
pipeline.addLast(e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ public class Bootstrap implements ExternalResourceReleasable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} This method simply delegates the call to
|
* This method simply delegates the call to
|
||||||
* {@link ChannelFactory#releaseExternalResources()}.
|
* {@link ChannelFactory#releaseExternalResources()}.
|
||||||
*/
|
*/
|
||||||
public void releaseExternalResources() {
|
public void releaseExternalResources() {
|
||||||
|
@ -56,60 +56,60 @@ public class BigEndianHeapChannelBuffer extends HeapChannelBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public short getShort(int index) {
|
public short getShort(int index) {
|
||||||
return (short) (array[index] << 8 | array[index+1] & 0xFF);
|
return (short) (array[index] << 8 | array[index + 1] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUnsignedMedium(int index) {
|
public int getUnsignedMedium(int index) {
|
||||||
return (array[index] & 0xff) << 16 |
|
return (array[index] & 0xff) << 16 |
|
||||||
(array[index+1] & 0xff) << 8 |
|
(array[index + 1] & 0xff) << 8 |
|
||||||
(array[index+2] & 0xff) << 0;
|
(array[index + 2] & 0xff) << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(int index) {
|
public int getInt(int index) {
|
||||||
return (array[index] & 0xff) << 24 |
|
return (array[index] & 0xff) << 24 |
|
||||||
(array[index+1] & 0xff) << 16 |
|
(array[index + 1] & 0xff) << 16 |
|
||||||
(array[index+2] & 0xff) << 8 |
|
(array[index + 2] & 0xff) << 8 |
|
||||||
(array[index+3] & 0xff) << 0;
|
(array[index + 3] & 0xff) << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLong(int index) {
|
public long getLong(int index) {
|
||||||
return ((long) array[index] & 0xff) << 56 |
|
return ((long) array[index] & 0xff) << 56 |
|
||||||
((long) array[index+1] & 0xff) << 48 |
|
((long) array[index + 1] & 0xff) << 48 |
|
||||||
((long) array[index+2] & 0xff) << 40 |
|
((long) array[index + 2] & 0xff) << 40 |
|
||||||
((long) array[index+3] & 0xff) << 32 |
|
((long) array[index + 3] & 0xff) << 32 |
|
||||||
((long) array[index+4] & 0xff) << 24 |
|
((long) array[index + 4] & 0xff) << 24 |
|
||||||
((long) array[index+5] & 0xff) << 16 |
|
((long) array[index + 5] & 0xff) << 16 |
|
||||||
((long) array[index+6] & 0xff) << 8 |
|
((long) array[index + 6] & 0xff) << 8 |
|
||||||
((long) array[index+7] & 0xff) << 0;
|
((long) array[index + 7] & 0xff) << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShort(int index, int value) {
|
public void setShort(int index, int value) {
|
||||||
array[index ] = (byte) (value >>> 8);
|
array[index] = (byte) (value >>> 8);
|
||||||
array[index+1] = (byte) (value >>> 0);
|
array[index + 1] = (byte) (value >>> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMedium(int index, int value) {
|
public void setMedium(int index, int value) {
|
||||||
array[index ] = (byte) (value >>> 16);
|
array[index] = (byte) (value >>> 16);
|
||||||
array[index+1] = (byte) (value >>> 8);
|
array[index + 1] = (byte) (value >>> 8);
|
||||||
array[index+2] = (byte) (value >>> 0);
|
array[index + 2] = (byte) (value >>> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInt(int index, int value) {
|
public void setInt(int index, int value) {
|
||||||
array[index ] = (byte) (value >>> 24);
|
array[index] = (byte) (value >>> 24);
|
||||||
array[index+1] = (byte) (value >>> 16);
|
array[index + 1] = (byte) (value >>> 16);
|
||||||
array[index+2] = (byte) (value >>> 8);
|
array[index + 2] = (byte) (value >>> 8);
|
||||||
array[index+3] = (byte) (value >>> 0);
|
array[index + 3] = (byte) (value >>> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLong(int index, long value) {
|
public void setLong(int index, long value) {
|
||||||
array[index ] = (byte) (value >>> 56);
|
array[index] = (byte) (value >>> 56);
|
||||||
array[index+1] = (byte) (value >>> 48);
|
array[index + 1] = (byte) (value >>> 48);
|
||||||
array[index+2] = (byte) (value >>> 40);
|
array[index + 2] = (byte) (value >>> 40);
|
||||||
array[index+3] = (byte) (value >>> 32);
|
array[index + 3] = (byte) (value >>> 32);
|
||||||
array[index+4] = (byte) (value >>> 24);
|
array[index + 4] = (byte) (value >>> 24);
|
||||||
array[index+5] = (byte) (value >>> 16);
|
array[index + 5] = (byte) (value >>> 16);
|
||||||
array[index+6] = (byte) (value >>> 8);
|
array[index + 6] = (byte) (value >>> 8);
|
||||||
array[index+7] = (byte) (value >>> 0);
|
array[index + 7] = (byte) (value >>> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelBuffer duplicate() {
|
public ChannelBuffer duplicate() {
|
||||||
|
@ -97,9 +97,9 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getUnsignedMedium(int index) {
|
public int getUnsignedMedium(int index) {
|
||||||
return (getByte(index) & 0xff) << 16 |
|
return (getByte(index) & 0xff) << 16 |
|
||||||
(getByte(index+1) & 0xff) << 8 |
|
(getByte(index + 1) & 0xff) << 8 |
|
||||||
(getByte(index+2) & 0xff) << 0;
|
(getByte(index + 2) & 0xff) << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(int index) {
|
public int getInt(int index) {
|
||||||
@ -154,9 +154,9 @@ public class ByteBufferBackedChannelBuffer extends AbstractChannelBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMedium(int index, int value) {
|
public void setMedium(int index, int value) {
|
||||||
setByte(index, (byte) (value >>> 16));
|
setByte(index, (byte) (value >>> 16));
|
||||||
setByte(index+1, (byte) (value >>> 8));
|
setByte(index + 1, (byte) (value >>> 8));
|
||||||
setByte(index+2, (byte) (value >>> 0));
|
setByte(index + 2, (byte) (value >>> 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInt(int index, int value) {
|
public void setInt(int index, int value) {
|
||||||
|
@ -47,7 +47,7 @@ import java.nio.charset.UnsupportedCharsetException;
|
|||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@link ChannelBuffer} buffer = ...;
|
* {@link ChannelBuffer} buffer = ...;
|
||||||
* for (int i = 0; i < buffer.capacity(); i ++</strong>) {
|
* for (int i = 0; i < buffer.capacity(); i ++) {
|
||||||
* byte b = buffer.getByte(i);
|
* byte b = buffer.getByte(i);
|
||||||
* System.out.println((char) b);
|
* System.out.println((char) b);
|
||||||
* }
|
* }
|
||||||
|
@ -42,7 +42,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a {@code NUL (0x00)} byte.
|
* Index finder which locates a {@code NUL (0x00)} byte.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder NUL = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder NUL = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
return buffer.getByte(guessedIndex) == 0;
|
return buffer.getByte(guessedIndex) == 0;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a non-{@code NUL (0x00)} byte.
|
* Index finder which locates a non-{@code NUL (0x00)} byte.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder NOT_NUL = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder NOT_NUL = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
return buffer.getByte(guessedIndex) != 0;
|
return buffer.getByte(guessedIndex) != 0;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a {@code CR ('\r')} byte.
|
* Index finder which locates a {@code CR ('\r')} byte.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder CR = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder CR = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
return buffer.getByte(guessedIndex) == '\r';
|
return buffer.getByte(guessedIndex) == '\r';
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a non-{@code CR ('\r')} byte.
|
* Index finder which locates a non-{@code CR ('\r')} byte.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder NOT_CR = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder NOT_CR = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
return buffer.getByte(guessedIndex) != '\r';
|
return buffer.getByte(guessedIndex) != '\r';
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a {@code LF ('\n')} byte.
|
* Index finder which locates a {@code LF ('\n')} byte.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder LF = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder LF = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
return buffer.getByte(guessedIndex) == '\n';
|
return buffer.getByte(guessedIndex) == '\n';
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a non-{@code LF ('\n')} byte.
|
* Index finder which locates a non-{@code LF ('\n')} byte.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder NOT_LF = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder NOT_LF = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
return buffer.getByte(guessedIndex) != '\n';
|
return buffer.getByte(guessedIndex) != '\n';
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
/**
|
/**
|
||||||
* Index finder which locates a {@code CR ('\r')} or {@code LF ('\n')}.
|
* Index finder which locates a {@code CR ('\r')} or {@code LF ('\n')}.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder CRLF = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder CRLF = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
byte b = buffer.getByte(guessedIndex);
|
byte b = buffer.getByte(guessedIndex);
|
||||||
return b == '\r' || b == '\n';
|
return b == '\r' || b == '\n';
|
||||||
@ -107,7 +107,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
* Index finder which locates a byte which is neither a {@code CR ('\r')}
|
* Index finder which locates a byte which is neither a {@code CR ('\r')}
|
||||||
* nor a {@code LF ('\n')}.
|
* nor a {@code LF ('\n')}.
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder NOT_CRLF = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder NOT_CRLF = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
byte b = buffer.getByte(guessedIndex);
|
byte b = buffer.getByte(guessedIndex);
|
||||||
return b != '\r' && b != '\n';
|
return b != '\r' && b != '\n';
|
||||||
@ -118,7 +118,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
* Index finder which locates a linear whitespace
|
* Index finder which locates a linear whitespace
|
||||||
* ({@code ' '} and {@code '\t'}).
|
* ({@code ' '} and {@code '\t'}).
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
byte b = buffer.getByte(guessedIndex);
|
byte b = buffer.getByte(guessedIndex);
|
||||||
return b == ' ' || b == '\t';
|
return b == ' ' || b == '\t';
|
||||||
@ -129,7 +129,7 @@ public interface ChannelBufferIndexFinder {
|
|||||||
* Index finder which locates a byte which is not a linear whitespace
|
* Index finder which locates a byte which is not a linear whitespace
|
||||||
* (neither {@code ' '} nor {@code '\t'}).
|
* (neither {@code ' '} nor {@code '\t'}).
|
||||||
*/
|
*/
|
||||||
static ChannelBufferIndexFinder NOT_LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
ChannelBufferIndexFinder NOT_LINEAR_WHITESPACE = new ChannelBufferIndexFinder() {
|
||||||
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
public boolean find(ChannelBuffer buffer, int guessedIndex) {
|
||||||
byte b = buffer.getByte(guessedIndex);
|
byte b = buffer.getByte(guessedIndex);
|
||||||
return b != ' ' && b != '\t';
|
return b != ' ' && b != '\t';
|
||||||
|
@ -85,7 +85,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||||||
* @apiviz.landmark
|
* @apiviz.landmark
|
||||||
* @apiviz.has org.jboss.netty.buffer.ChannelBuffer oneway - - creates
|
* @apiviz.has org.jboss.netty.buffer.ChannelBuffer oneway - - creates
|
||||||
*/
|
*/
|
||||||
public class ChannelBuffers {
|
public final class ChannelBuffers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Big endian byte order.
|
* Big endian byte order.
|
||||||
@ -308,7 +308,7 @@ public class ChannelBuffers {
|
|||||||
return EMPTY_BUFFER;
|
return EMPTY_BUFFER;
|
||||||
}
|
}
|
||||||
if (buffer.hasArray()) {
|
if (buffer.hasArray()) {
|
||||||
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(),buffer.remaining());
|
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
|
||||||
} else {
|
} else {
|
||||||
return new ByteBufferBackedChannelBuffer(buffer);
|
return new ByteBufferBackedChannelBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
@ -326,8 +326,8 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
|
|||||||
setShort(index, (short) (value >> 8));
|
setShort(index, (short) (value >> 8));
|
||||||
setByte(index + 2, (byte) value);
|
setByte(index + 2, (byte) value);
|
||||||
} else {
|
} else {
|
||||||
setShort(index , (short) value);
|
setShort(index , (short) value);
|
||||||
setByte (index + 2, (byte) (value >>> 16));
|
setByte(index + 2, (byte) (value >>> 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
|
|||||||
private final Object bigEndianLock = new Object();
|
private final Object bigEndianLock = new Object();
|
||||||
private final Object littleEndianLock = new Object();
|
private final Object littleEndianLock = new Object();
|
||||||
private final int preallocatedBufferCapacity;
|
private final int preallocatedBufferCapacity;
|
||||||
private ChannelBuffer preallocatedBigEndianBuffer = null;
|
private ChannelBuffer preallocatedBigEndianBuffer;
|
||||||
private int preallocatedBigEndianBufferPosition;
|
private int preallocatedBigEndianBufferPosition;
|
||||||
private ChannelBuffer preallocatedLittleEndianBuffer = null;
|
private ChannelBuffer preallocatedLittleEndianBuffer;
|
||||||
private int preallocatedLittleEndianBufferPosition;
|
private int preallocatedLittleEndianBufferPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,60 +56,60 @@ public class LittleEndianHeapChannelBuffer extends HeapChannelBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public short getShort(int index) {
|
public short getShort(int index) {
|
||||||
return (short) (array[index] & 0xFF | array[index+1] << 8);
|
return (short) (array[index] & 0xFF | array[index + 1] << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUnsignedMedium(int index) {
|
public int getUnsignedMedium(int index) {
|
||||||
return (array[index ] & 0xff) << 0 |
|
return (array[index] & 0xff) << 0 |
|
||||||
(array[index+1] & 0xff) << 8 |
|
(array[index + 1] & 0xff) << 8 |
|
||||||
(array[index+2] & 0xff) << 16;
|
(array[index + 2] & 0xff) << 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(int index) {
|
public int getInt(int index) {
|
||||||
return (array[index ] & 0xff) << 0 |
|
return (array[index] & 0xff) << 0 |
|
||||||
(array[index+1] & 0xff) << 8 |
|
(array[index + 1] & 0xff) << 8 |
|
||||||
(array[index+2] & 0xff) << 16 |
|
(array[index + 2] & 0xff) << 16 |
|
||||||
(array[index+3] & 0xff) << 24;
|
(array[index + 3] & 0xff) << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLong(int index) {
|
public long getLong(int index) {
|
||||||
return ((long) array[index] & 0xff) << 0 |
|
return ((long) array[index] & 0xff) << 0 |
|
||||||
((long) array[index+1] & 0xff) << 8 |
|
((long) array[index + 1] & 0xff) << 8 |
|
||||||
((long) array[index+2] & 0xff) << 16 |
|
((long) array[index + 2] & 0xff) << 16 |
|
||||||
((long) array[index+3] & 0xff) << 24 |
|
((long) array[index + 3] & 0xff) << 24 |
|
||||||
((long) array[index+4] & 0xff) << 32 |
|
((long) array[index + 4] & 0xff) << 32 |
|
||||||
((long) array[index+5] & 0xff) << 40 |
|
((long) array[index + 5] & 0xff) << 40 |
|
||||||
((long) array[index+6] & 0xff) << 48 |
|
((long) array[index + 6] & 0xff) << 48 |
|
||||||
((long) array[index+7] & 0xff) << 56;
|
((long) array[index + 7] & 0xff) << 56;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShort(int index, int value) {
|
public void setShort(int index, int value) {
|
||||||
array[index ] = (byte) (value >>> 0);
|
array[index] = (byte) (value >>> 0);
|
||||||
array[index+1] = (byte) (value >>> 8);
|
array[index + 1] = (byte) (value >>> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMedium(int index, int value) {
|
public void setMedium(int index, int value) {
|
||||||
array[index ] = (byte) (value >>> 0);
|
array[index] = (byte) (value >>> 0);
|
||||||
array[index+1] = (byte) (value >>> 8);
|
array[index + 1] = (byte) (value >>> 8);
|
||||||
array[index+2] = (byte) (value >>> 16);
|
array[index + 2] = (byte) (value >>> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInt(int index, int value) {
|
public void setInt(int index, int value) {
|
||||||
array[index ] = (byte) (value >>> 0);
|
array[index] = (byte) (value >>> 0);
|
||||||
array[index+1] = (byte) (value >>> 8);
|
array[index + 1] = (byte) (value >>> 8);
|
||||||
array[index+2] = (byte) (value >>> 16);
|
array[index + 2] = (byte) (value >>> 16);
|
||||||
array[index+3] = (byte) (value >>> 24);
|
array[index + 3] = (byte) (value >>> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLong(int index, long value) {
|
public void setLong(int index, long value) {
|
||||||
array[index ] = (byte) (value >>> 0);
|
array[index] = (byte) (value >>> 0);
|
||||||
array[index+1] = (byte) (value >>> 8);
|
array[index + 1] = (byte) (value >>> 8);
|
||||||
array[index+2] = (byte) (value >>> 16);
|
array[index + 2] = (byte) (value >>> 16);
|
||||||
array[index+3] = (byte) (value >>> 24);
|
array[index + 3] = (byte) (value >>> 24);
|
||||||
array[index+4] = (byte) (value >>> 32);
|
array[index + 4] = (byte) (value >>> 32);
|
||||||
array[index+5] = (byte) (value >>> 40);
|
array[index + 5] = (byte) (value >>> 40);
|
||||||
array[index+6] = (byte) (value >>> 48);
|
array[index + 6] = (byte) (value >>> 48);
|
||||||
array[index+7] = (byte) (value >>> 56);
|
array[index + 7] = (byte) (value >>> 56);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelBuffer duplicate() {
|
public ChannelBuffer duplicate() {
|
||||||
|
@ -112,25 +112,25 @@ public interface Channel extends Comparable<Channel> {
|
|||||||
* The {@link #getInterestOps() interestOps} value which tells that only
|
* The {@link #getInterestOps() interestOps} value which tells that only
|
||||||
* read operation has been suspended.
|
* read operation has been suspended.
|
||||||
*/
|
*/
|
||||||
static int OP_NONE = 0;
|
int OP_NONE = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link #getInterestOps() interestOps} value which tells that neither
|
* The {@link #getInterestOps() interestOps} value which tells that neither
|
||||||
* read nor write operation has been suspended.
|
* read nor write operation has been suspended.
|
||||||
*/
|
*/
|
||||||
static int OP_READ = 1;
|
int OP_READ = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link #getInterestOps() interestOps} value which tells that both
|
* The {@link #getInterestOps() interestOps} value which tells that both
|
||||||
* read and write operation has been suspended.
|
* read and write operation has been suspended.
|
||||||
*/
|
*/
|
||||||
static int OP_WRITE = 4;
|
int OP_WRITE = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link #getInterestOps() interestOps} value which tells that only
|
* The {@link #getInterestOps() interestOps} value which tells that only
|
||||||
* write operation has been suspended.
|
* write operation has been suspended.
|
||||||
*/
|
*/
|
||||||
static int OP_READ_WRITE = OP_READ | OP_WRITE;
|
int OP_READ_WRITE = OP_READ | OP_WRITE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unique integer ID of this channel.
|
* Returns the unique integer ID of this channel.
|
||||||
|
@ -55,7 +55,7 @@ import org.jboss.netty.channel.socket.ServerSocketChannel;
|
|||||||
*
|
*
|
||||||
* <table border="1" cellspacing="0" cellpadding="6">
|
* <table border="1" cellspacing="0" cellpadding="6">
|
||||||
* <tr>
|
* <tr>
|
||||||
* <th>Event name</th></th><th>Event type and condition</th><th>Meaning</th>
|
* <th>Event name</th><th>Event type and condition</th><th>Meaning</th>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td>{@code "messageReceived"}</td>
|
* <td>{@code "messageReceived"}</td>
|
||||||
|
@ -36,7 +36,7 @@ public interface ChannelFutureListener extends EventListener {
|
|||||||
* A {@link ChannelFutureListener} that closes the {@link Channel} which is
|
* A {@link ChannelFutureListener} that closes the {@link Channel} which is
|
||||||
* associated with the specified {@link ChannelFuture}.
|
* associated with the specified {@link ChannelFuture}.
|
||||||
*/
|
*/
|
||||||
static ChannelFutureListener CLOSE = new ChannelFutureListener() {
|
ChannelFutureListener CLOSE = new ChannelFutureListener() {
|
||||||
public void operationComplete(ChannelFuture future) {
|
public void operationComplete(ChannelFuture future) {
|
||||||
future.getChannel().close();
|
future.getChannel().close();
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public interface ChannelFutureListener extends EventListener {
|
|||||||
* A {@link ChannelFutureListener} that closes the {@link Channel} when the
|
* A {@link ChannelFutureListener} that closes the {@link Channel} when the
|
||||||
* operation ended up with a failure or cancellation rather than a success.
|
* operation ended up with a failure or cancellation rather than a success.
|
||||||
*/
|
*/
|
||||||
static ChannelFutureListener CLOSE_ON_FAILURE = new ChannelFutureListener() {
|
ChannelFutureListener CLOSE_ON_FAILURE = new ChannelFutureListener() {
|
||||||
public void operationComplete(ChannelFuture future) {
|
public void operationComplete(ChannelFuture future) {
|
||||||
if (!future.isSuccess()) {
|
if (!future.isSuccess()) {
|
||||||
future.getChannel().close();
|
future.getChannel().close();
|
||||||
|
@ -51,7 +51,7 @@ package org.jboss.netty.channel;
|
|||||||
* public void login(String username, password) {
|
* public void login(String username, password) {
|
||||||
* {@link Channels}.write(
|
* {@link Channels}.write(
|
||||||
* <b>this.ctx</b>,
|
* <b>this.ctx</b>,
|
||||||
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()</b>),
|
* {@link Channels}.succeededFuture(<b>this.ctx.getChannel()</b>),
|
||||||
* new LoginMessage(username, password));
|
* new LoginMessage(username, password));
|
||||||
* }
|
* }
|
||||||
* ...
|
* ...
|
||||||
|
@ -219,7 +219,7 @@ public interface ChannelPipeline {
|
|||||||
* @throws NullPointerException
|
* @throws NullPointerException
|
||||||
* if the specified name or handler is {@code null}
|
* if the specified name or handler is {@code null}
|
||||||
*/
|
*/
|
||||||
void addFirst (String name, ChannelHandler handler);
|
void addFirst(String name, ChannelHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a {@link ChannelHandler} at the last position of this pipeline.
|
* Appends a {@link ChannelHandler} at the last position of this pipeline.
|
||||||
@ -232,7 +232,7 @@ public interface ChannelPipeline {
|
|||||||
* @throws NullPointerException
|
* @throws NullPointerException
|
||||||
* if the specified name or handler is {@code null}
|
* if the specified name or handler is {@code null}
|
||||||
*/
|
*/
|
||||||
void addLast (String name, ChannelHandler handler);
|
void addLast(String name, ChannelHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a {@link ChannelHandler} before an existing handler of this
|
* Inserts a {@link ChannelHandler} before an existing handler of this
|
||||||
@ -266,7 +266,7 @@ public interface ChannelPipeline {
|
|||||||
* @throws NullPointerException
|
* @throws NullPointerException
|
||||||
* if the specified baseName, name, or handler is {@code null}
|
* if the specified baseName, name, or handler is {@code null}
|
||||||
*/
|
*/
|
||||||
void addAfter (String baseName, String name, ChannelHandler handler);
|
void addAfter(String baseName, String name, ChannelHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified {@link ChannelHandler} from this pipeline.
|
* Removes the specified {@link ChannelHandler} from this pipeline.
|
||||||
|
@ -39,12 +39,12 @@ public @interface ChannelPipelineCoverage {
|
|||||||
/**
|
/**
|
||||||
* {@code "all"}
|
* {@code "all"}
|
||||||
*/
|
*/
|
||||||
public static final String ALL = "all";
|
String ALL = "all";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code "one"}
|
* {@code "one"}
|
||||||
*/
|
*/
|
||||||
public static final String ONE = "one";
|
String ONE = "one";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value of this annotation
|
* The value of this annotation
|
||||||
|
@ -47,7 +47,7 @@ import org.jboss.netty.util.internal.ConversionUtil;
|
|||||||
* {@link ChannelHandlerContext#sendDownstream(ChannelEvent)} by yourself.
|
* {@link ChannelHandlerContext#sendDownstream(ChannelEvent)} by yourself.
|
||||||
* @apiviz.landmark
|
* @apiviz.landmark
|
||||||
*/
|
*/
|
||||||
public class Channels {
|
public final class Channels {
|
||||||
|
|
||||||
// pipeline factory methods
|
// pipeline factory methods
|
||||||
|
|
||||||
|
@ -80,4 +80,4 @@ public interface FileRegion extends ExternalResourceReleasable {
|
|||||||
* byte of the region transferred.
|
* byte of the region transferred.
|
||||||
*/
|
*/
|
||||||
long transferTo(WritableByteChannel target, long position) throws IOException;
|
long transferTo(WritableByteChannel target, long position) throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||||||
return state.get() == ST_CONNECTED;
|
return state.get() == ST_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setBound() throws ClosedChannelException {
|
void setBound() throws ClosedChannelException {
|
||||||
if (!state.compareAndSet(ST_OPEN, ST_BOUND)) {
|
if (!state.compareAndSet(ST_OPEN, ST_BOUND)) {
|
||||||
switch (state.get()) {
|
switch (state.get()) {
|
||||||
case ST_CLOSED:
|
case ST_CLOSED:
|
||||||
@ -99,7 +99,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setConnected() {
|
void setConnected() {
|
||||||
if (state.get() != ST_CLOSED) {
|
if (state.get() != ST_CLOSED) {
|
||||||
state.set(ST_CONNECTED);
|
state.set(ST_CONNECTED);
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||||||
void flushWriteBuffer() {
|
void flushWriteBuffer() {
|
||||||
DefaultLocalChannel pairedChannel = this.pairedChannel;
|
DefaultLocalChannel pairedChannel = this.pairedChannel;
|
||||||
if (pairedChannel != null) {
|
if (pairedChannel != null) {
|
||||||
if (pairedChannel.isConnected()){
|
if (pairedChannel.isConnected()) {
|
||||||
// Channel is open and connected and channelConnected event has
|
// Channel is open and connected and channelConnected event has
|
||||||
// been fired.
|
// been fired.
|
||||||
if (!delivering.get()) {
|
if (!delivering.get()) {
|
||||||
@ -165,7 +165,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||||||
try {
|
try {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
MessageEvent e = writeBuffer.poll();
|
MessageEvent e = writeBuffer.poll();
|
||||||
if(e == null) {
|
if (e == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
MessageEvent e = writeBuffer.poll();
|
MessageEvent e = writeBuffer.poll();
|
||||||
if(e == null) {
|
if (e == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public final class LocalAddress extends SocketAddress implements Comparable<Loca
|
|||||||
public int compareTo(LocalAddress o) {
|
public int compareTo(LocalAddress o) {
|
||||||
if (ephemeral) {
|
if (ephemeral) {
|
||||||
if (o.ephemeral) {
|
if (o.ephemeral) {
|
||||||
if (this == o){
|
if (this == o) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
|||||||
Channel channel = e.getChannel();
|
Channel channel = e.getChannel();
|
||||||
if (channel instanceof DefaultLocalServerChannel) {
|
if (channel instanceof DefaultLocalServerChannel) {
|
||||||
handleServerChannel(e);
|
handleServerChannel(e);
|
||||||
}
|
} else if (channel instanceof DefaultLocalChannel) {
|
||||||
else if (channel instanceof DefaultLocalChannel) {
|
|
||||||
handleAcceptedChannel(e);
|
handleAcceptedChannel(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,8 +125,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
|
|||||||
public ChannelFuture write(Object message, SocketAddress remoteAddress) {
|
public ChannelFuture write(Object message, SocketAddress remoteAddress) {
|
||||||
if (remoteAddress == null || remoteAddress.equals(getRemoteAddress())) {
|
if (remoteAddress == null || remoteAddress.equals(getRemoteAddress())) {
|
||||||
return super.write(message, null);
|
return super.write(message, null);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return getUnsupportedOperationFuture();
|
return getUnsupportedOperationFuture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ final class HttpTunnelingClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (e instanceof MessageEvent) {
|
} else if (e instanceof MessageEvent) {
|
||||||
channel.writeReal(((ChannelBuffer) ((MessageEvent) e).getMessage()), future);
|
channel.writeReal((ChannelBuffer) ((MessageEvent) e).getMessage(), future);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,17 +211,17 @@ public final class HttpTunnelingSocketChannelConfig implements SocketChannelConf
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.equals("serverName")){
|
if (key.equals("serverName")) {
|
||||||
setServerName(String.valueOf(value));
|
setServerName(String.valueOf(value));
|
||||||
} else if (key.equals("serverPath")){
|
} else if (key.equals("serverPath")) {
|
||||||
setServerPath(String.valueOf(value));
|
setServerPath(String.valueOf(value));
|
||||||
} else if (key.equals("sslContext")) {
|
} else if (key.equals("sslContext")) {
|
||||||
setSslContext((SSLContext) value);
|
setSslContext((SSLContext) value);
|
||||||
} else if (key.equals("enabledSslCipherSuites")){
|
} else if (key.equals("enabledSslCipherSuites")) {
|
||||||
setEnabledSslCipherSuites(ConversionUtil.toStringArray(value));
|
setEnabledSslCipherSuites(ConversionUtil.toStringArray(value));
|
||||||
} else if (key.equals("enabledSslProtocols")){
|
} else if (key.equals("enabledSslProtocols")) {
|
||||||
setEnabledSslProtocols(ConversionUtil.toStringArray(value));
|
setEnabledSslProtocols(ConversionUtil.toStringArray(value));
|
||||||
} else if (key.equals("enableSslSessionCreation")){
|
} else if (key.equals("enableSslSessionCreation")) {
|
||||||
setEnableSslSessionCreation(ConversionUtil.toBoolean(value));
|
setEnableSslSessionCreation(ConversionUtil.toBoolean(value));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,7 +29,7 @@ import org.jboss.netty.util.internal.QueueFactory;
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
abstract class AbstractWriteRequestQueue implements BlockingQueue<MessageEvent>{
|
abstract class AbstractWriteRequestQueue implements BlockingQueue<MessageEvent> {
|
||||||
|
|
||||||
protected final BlockingQueue<MessageEvent> queue;
|
protected final BlockingQueue<MessageEvent> queue;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ import org.jboss.netty.util.internal.SystemPropertyUtil;
|
|||||||
* Provides information which is specific to a NIO service provider
|
* Provides information which is specific to a NIO service provider
|
||||||
* implementation.
|
* implementation.
|
||||||
*/
|
*/
|
||||||
class NioProviderMetadata {
|
final class NioProviderMetadata {
|
||||||
static final InternalLogger logger =
|
static final InternalLogger logger =
|
||||||
InternalLoggerFactory.getInstance(NioProviderMetadata.class);
|
InternalLoggerFactory.getInstance(NioProviderMetadata.class);
|
||||||
|
|
||||||
|
@ -40,4 +40,8 @@ final class SelectorUtil {
|
|||||||
" raised by a Selector - JDK bug?", e);
|
" raised by a Selector - JDK bug?", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SelectorUtil() {
|
||||||
|
// Unused
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ final class SocketReceiveBufferPool {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ByteBuffer acquire(int size) {
|
ByteBuffer acquire(int size) {
|
||||||
final SoftReference<ByteBuffer>[] pool = this.pool;
|
final SoftReference<ByteBuffer>[] pool = this.pool;
|
||||||
for (int i = 0; i < POOL_SIZE; i ++) {
|
for (int i = 0; i < POOL_SIZE; i ++) {
|
||||||
SoftReference<ByteBuffer> ref = pool[i];
|
SoftReference<ByteBuffer> ref = pool[i];
|
||||||
@ -60,7 +60,7 @@ final class SocketReceiveBufferPool {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void release(ByteBuffer buffer) {
|
void release(ByteBuffer buffer) {
|
||||||
final SoftReference<ByteBuffer>[] pool = this.pool;
|
final SoftReference<ByteBuffer>[] pool = this.pool;
|
||||||
for (int i = 0; i < POOL_SIZE; i ++) {
|
for (int i = 0; i < POOL_SIZE; i ++) {
|
||||||
SoftReference<ByteBuffer> ref = pool[i];
|
SoftReference<ByteBuffer> ref = pool[i];
|
||||||
@ -72,7 +72,7 @@ final class SocketReceiveBufferPool {
|
|||||||
|
|
||||||
// pool is full - replace one
|
// pool is full - replace one
|
||||||
final int capacity = buffer.capacity();
|
final int capacity = buffer.capacity();
|
||||||
for (int i = 0; i< POOL_SIZE; i ++) {
|
for (int i = 0; i < POOL_SIZE; i ++) {
|
||||||
SoftReference<ByteBuffer> ref = pool[i];
|
SoftReference<ByteBuffer> ref = pool[i];
|
||||||
ByteBuffer pooled = ref.get();
|
ByteBuffer pooled = ref.get();
|
||||||
if (pooled == null) {
|
if (pooled == null) {
|
||||||
@ -87,7 +87,7 @@ final class SocketReceiveBufferPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int normalizeCapacity(int capacity) {
|
private static int normalizeCapacity(int capacity) {
|
||||||
// Normalize to multiple of 1024
|
// Normalize to multiple of 1024
|
||||||
int q = capacity >>> 10;
|
int q = capacity >>> 10;
|
||||||
int r = capacity & 1023;
|
int r = capacity & 1023;
|
||||||
@ -96,4 +96,4 @@ final class SocketReceiveBufferPool {
|
|||||||
}
|
}
|
||||||
return q << 10;
|
return q << 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,14 @@ final class SocketSendBufferPool {
|
|||||||
private static final int ALIGN_SHIFT = 4;
|
private static final int ALIGN_SHIFT = 4;
|
||||||
private static final int ALIGN_MASK = 15;
|
private static final int ALIGN_MASK = 15;
|
||||||
|
|
||||||
PreallocationRef poolHead = null;
|
PreallocationRef poolHead;
|
||||||
Preallocation current = new Preallocation(DEFAULT_PREALLOCATION_SIZE);
|
Preallocation current = new Preallocation(DEFAULT_PREALLOCATION_SIZE);
|
||||||
|
|
||||||
SocketSendBufferPool() {
|
SocketSendBufferPool() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
final SendBuffer acquire(Object message) {
|
SendBuffer acquire(Object message) {
|
||||||
if (message instanceof ChannelBuffer) {
|
if (message instanceof ChannelBuffer) {
|
||||||
return acquire((ChannelBuffer) message);
|
return acquire((ChannelBuffer) message);
|
||||||
} else if (message instanceof FileRegion) {
|
} else if (message instanceof FileRegion) {
|
||||||
@ -54,14 +54,14 @@ final class SocketSendBufferPool {
|
|||||||
"unsupported message type: " + message.getClass());
|
"unsupported message type: " + message.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final SendBuffer acquire(FileRegion src) {
|
private SendBuffer acquire(FileRegion src) {
|
||||||
if (src.getCount() == 0) {
|
if (src.getCount() == 0) {
|
||||||
return EMPTY_BUFFER;
|
return EMPTY_BUFFER;
|
||||||
}
|
}
|
||||||
return new FileSendBuffer(src);
|
return new FileSendBuffer(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final SendBuffer acquire(ChannelBuffer src) {
|
private SendBuffer acquire(ChannelBuffer src) {
|
||||||
final int size = src.readableBytes();
|
final int size = src.readableBytes();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return EMPTY_BUFFER;
|
return EMPTY_BUFFER;
|
||||||
@ -107,7 +107,7 @@ final class SocketSendBufferPool {
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Preallocation getPreallocation() {
|
private Preallocation getPreallocation() {
|
||||||
Preallocation current = this.current;
|
Preallocation current = this.current;
|
||||||
if (current.refCnt == 0) {
|
if (current.refCnt == 0) {
|
||||||
current.buffer.clear();
|
current.buffer.clear();
|
||||||
@ -117,7 +117,7 @@ final class SocketSendBufferPool {
|
|||||||
return getPreallocation0();
|
return getPreallocation0();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Preallocation getPreallocation0() {
|
private Preallocation getPreallocation0() {
|
||||||
PreallocationRef ref = poolHead;
|
PreallocationRef ref = poolHead;
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
do {
|
do {
|
||||||
@ -136,7 +136,7 @@ final class SocketSendBufferPool {
|
|||||||
return new Preallocation(DEFAULT_PREALLOCATION_SIZE);
|
return new Preallocation(DEFAULT_PREALLOCATION_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int align(int pos) {
|
private static int align(int pos) {
|
||||||
int q = pos >>> ALIGN_SHIFT;
|
int q = pos >>> ALIGN_SHIFT;
|
||||||
int r = pos & ALIGN_MASK;
|
int r = pos & ALIGN_MASK;
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
@ -287,7 +287,7 @@ final class SocketSendBufferPool {
|
|||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
if (file instanceof DefaultFileRegion) {
|
if (file instanceof DefaultFileRegion) {
|
||||||
if (((DefaultFileRegion)file).releaseAfterTransfer()) {
|
if (((DefaultFileRegion) file).releaseAfterTransfer()) {
|
||||||
// Make sure the FileRegion resource are released otherwise it may cause a FD leak or something similar
|
// Make sure the FileRegion resource are released otherwise it may cause a FD leak or something similar
|
||||||
file.releaseExternalResources();
|
file.releaseExternalResources();
|
||||||
}
|
}
|
||||||
@ -301,23 +301,23 @@ final class SocketSendBufferPool {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean finished() {
|
public boolean finished() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long writtenBytes() {
|
public long writtenBytes() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long totalBytes() {
|
public long totalBytes() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long transferTo(WritableByteChannel ch) throws IOException {
|
public long transferTo(WritableByteChannel ch) throws IOException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
public long transferTo(DatagramChannel ch, SocketAddress raddr) throws IOException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ class OioWorker implements Runnable {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (fr instanceof DefaultFileRegion) {
|
if (fr instanceof DefaultFileRegion) {
|
||||||
if (((DefaultFileRegion)fr).releaseAfterTransfer()) {
|
if (((DefaultFileRegion) fr).releaseAfterTransfer()) {
|
||||||
fr.releaseExternalResources();
|
fr.releaseExternalResources();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,23 @@ public class DiscardClient {
|
|||||||
} else {
|
} else {
|
||||||
firstMessageSize = 256;
|
firstMessageSize = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new DiscardClient(host, port, firstMessageSize).run();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String host;
|
||||||
|
private final int port;
|
||||||
|
private final int firstMessageSize;
|
||||||
|
|
||||||
|
public DiscardClient(String host, int port, int firstMessageSize) {
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.firstMessageSize = firstMessageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
// Configure the client.
|
// Configure the client.
|
||||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||||
new NioClientSocketChannelFactory(
|
new NioClientSocketChannelFactory(
|
||||||
|
@ -38,7 +38,7 @@ public class DiscardClientHandler extends SimpleChannelUpstreamHandler {
|
|||||||
private static final Logger logger = Logger.getLogger(
|
private static final Logger logger = Logger.getLogger(
|
||||||
DiscardClientHandler.class.getName());
|
DiscardClientHandler.class.getName());
|
||||||
|
|
||||||
private long transferredBytes = 0;
|
private long transferredBytes;
|
||||||
private final byte[] content;
|
private final byte[] content;
|
||||||
|
|
||||||
public DiscardClientHandler(int messageSize) {
|
public DiscardClientHandler(int messageSize) {
|
||||||
@ -84,7 +84,7 @@ public class DiscardClientHandler extends SimpleChannelUpstreamHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) {
|
public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) {
|
||||||
transferredBytes =+e.getWrittenAmount();
|
transferredBytes += e.getWrittenAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +30,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
|||||||
public class DiscardServer {
|
public class DiscardServer {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
new DiscardServer().run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
// Configure the server.
|
// Configure the server.
|
||||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||||
new NioServerSocketChannelFactory(
|
new NioServerSocketChannelFactory(
|
||||||
|
@ -34,7 +34,7 @@ public class DiscardServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
private static final Logger logger = Logger.getLogger(
|
private static final Logger logger = Logger.getLogger(
|
||||||
DiscardServerHandler.class.getName());
|
DiscardServerHandler.class.getName());
|
||||||
|
|
||||||
private long transferredBytes = 0;
|
private long transferredBytes;
|
||||||
|
|
||||||
public long getTransferredBytes() {
|
public long getTransferredBytes() {
|
||||||
return transferredBytes;
|
return transferredBytes;
|
||||||
@ -53,7 +53,7 @@ public class DiscardServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
|
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
|
||||||
// Discard received data silently by doing nothing.
|
// Discard received data silently by doing nothing.
|
||||||
transferredBytes += (((ChannelBuffer) e.getMessage()).readableBytes());
|
transferredBytes += ((ChannelBuffer) e.getMessage()).readableBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,21 @@ public class EchoClient {
|
|||||||
} else {
|
} else {
|
||||||
firstMessageSize = 256;
|
firstMessageSize = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new EchoClient(host, port, firstMessageSize).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String host;
|
||||||
|
private final int port;
|
||||||
|
private final int firstMessageSize;
|
||||||
|
|
||||||
|
public EchoClient(String host, int port, int firstMessageSize) {
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.firstMessageSize = firstMessageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(String host, int port, final int firstMessageSize) {
|
||||||
// Configure the client.
|
// Configure the client.
|
||||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||||
new NioClientSocketChannelFactory(
|
new NioClientSocketChannelFactory(
|
||||||
|
@ -30,6 +30,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
|||||||
public class EchoServer {
|
public class EchoServer {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
new EchoServer().run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
// Configure the server.
|
// Configure the server.
|
||||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||||
new NioServerSocketChannelFactory(
|
new NioServerSocketChannelFactory(
|
||||||
|
@ -45,7 +45,21 @@ public class FactorialClient {
|
|||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
throw new IllegalArgumentException("count must be a positive integer.");
|
throw new IllegalArgumentException("count must be a positive integer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new FactorialClient(host, port, count).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String host;
|
||||||
|
private final int port;
|
||||||
|
private final int count;
|
||||||
|
|
||||||
|
public FactorialClient(String host, int port, int count) {
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
// Configure the client.
|
// Configure the client.
|
||||||
ClientBootstrap bootstrap = new ClientBootstrap(
|
ClientBootstrap bootstrap = new ClientBootstrap(
|
||||||
new NioClientSocketChannelFactory(
|
new NioClientSocketChannelFactory(
|
||||||
|
@ -45,7 +45,7 @@ public class FactorialClientHandler extends SimpleChannelUpstreamHandler {
|
|||||||
|
|
||||||
// Stateful properties
|
// Stateful properties
|
||||||
private int i = 1;
|
private int i = 1;
|
||||||
private int receivedMessages = 0;
|
private int receivedMessages;
|
||||||
private final int count;
|
private final int count;
|
||||||
final BlockingQueue<BigInteger> answer = new LinkedBlockingQueue<BigInteger>();
|
final BlockingQueue<BigInteger> answer = new LinkedBlockingQueue<BigInteger>();
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
|||||||
public class FactorialServer {
|
public class FactorialServer {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
new FactorialServer().run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
// Configure the server.
|
// Configure the server.
|
||||||
ServerBootstrap bootstrap = new ServerBootstrap(
|
ServerBootstrap bootstrap = new ServerBootstrap(
|
||||||
new NioServerSocketChannelFactory(
|
new NioServerSocketChannelFactory(
|
||||||
|
@ -140,7 +140,7 @@ public class HttpRequestHandler extends SimpleChannelUpstreamHandler {
|
|||||||
if (cookieString != null) {
|
if (cookieString != null) {
|
||||||
CookieDecoder cookieDecoder = new CookieDecoder();
|
CookieDecoder cookieDecoder = new CookieDecoder();
|
||||||
Set<Cookie> cookies = cookieDecoder.decode(cookieString);
|
Set<Cookie> cookies = cookieDecoder.decode(cookieString);
|
||||||
if(!cookies.isEmpty()) {
|
if (!cookies.isEmpty()) {
|
||||||
// Reset the cookies if necessary.
|
// Reset the cookies if necessary.
|
||||||
CookieEncoder cookieEncoder = new CookieEncoder(true);
|
CookieEncoder cookieEncoder = new CookieEncoder(true);
|
||||||
for (Cookie cookie : cookies) {
|
for (Cookie cookie : cookies) {
|
||||||
|
@ -50,7 +50,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||||||
public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
||||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketServerHandler.class);
|
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketServerHandler.class);
|
||||||
|
|
||||||
private WebSocketServerHandshaker handshaker = null;
|
private WebSocketServerHandshaker handshaker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||||
@ -130,4 +130,4 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
private String getWebSocketLocation(HttpRequest req) {
|
private String getWebSocketLocation(HttpRequest req) {
|
||||||
return "ws://" + req.getHeader(HttpHeaders.Names.HOST);
|
return "ws://" + req.getHeader(HttpHeaders.Names.HOST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,7 @@ import org.jboss.netty.handler.codec.http.websocketx.WebSocketVersion;
|
|||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ConsoleHandler ch = new ConsoleHandler();
|
new App().runClient();
|
||||||
ch.setLevel(Level.FINE);
|
|
||||||
Logger.getLogger("").addHandler(ch);
|
|
||||||
Logger.getLogger("").setLevel(Level.FINE);
|
|
||||||
|
|
||||||
runClient();
|
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +45,7 @@ public class App {
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void runClient() throws Exception {
|
public void runClient() throws Exception {
|
||||||
|
|
||||||
MyCallbackHandler callbackHandler = new MyCallbackHandler();
|
MyCallbackHandler callbackHandler = new MyCallbackHandler();
|
||||||
WebSocketClientFactory factory = new WebSocketClientFactory();
|
WebSocketClientFactory factory = new WebSocketClientFactory();
|
||||||
@ -95,7 +89,7 @@ public class App {
|
|||||||
* Our web socket callback handler for this app
|
* Our web socket callback handler for this app
|
||||||
*/
|
*/
|
||||||
public static class MyCallbackHandler implements WebSocketCallback {
|
public static class MyCallbackHandler implements WebSocketCallback {
|
||||||
public boolean connected = false;
|
public boolean connected;
|
||||||
public ArrayList<String> messagesReceived = new ArrayList<String>();
|
public ArrayList<String> messagesReceived = new ArrayList<String>();
|
||||||
|
|
||||||
public MyCallbackHandler() {
|
public MyCallbackHandler() {
|
||||||
|
@ -53,9 +53,9 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler impleme
|
|||||||
private URI url;
|
private URI url;
|
||||||
private final WebSocketCallback callback;
|
private final WebSocketCallback callback;
|
||||||
private Channel channel;
|
private Channel channel;
|
||||||
private WebSocketClientHandshaker handshaker = null;
|
private WebSocketClientHandshaker handshaker;
|
||||||
private final WebSocketVersion version;
|
private final WebSocketVersion version;
|
||||||
private Map<String, String> customHeaders = null;
|
private Map<String, String> customHeaders;
|
||||||
|
|
||||||
public WebSocketClientHandler(ClientBootstrap bootstrap, URI url, WebSocketVersion version,
|
public WebSocketClientHandler(ClientBootstrap bootstrap, URI url, WebSocketVersion version,
|
||||||
WebSocketCallback callback, Map<String, String> customHeaders) {
|
WebSocketCallback callback, Map<String, String> customHeaders) {
|
||||||
@ -124,4 +124,4 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler impleme
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,12 @@ package org.jboss.netty.example.http.websocketx.client;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copied from https://github.com/cgbystrom/netty-tools
|
|
||||||
*
|
|
||||||
* A WebSocket related exception
|
* A WebSocket related exception
|
||||||
|
*
|
||||||
|
* Copied from https://github.com/cgbystrom/netty-tools
|
||||||
*/
|
*/
|
||||||
public class WebSocketException extends IOException {
|
public class WebSocketException extends IOException {
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public WebSocketException(String s) {
|
public WebSocketException(String s) {
|
||||||
@ -41,4 +39,4 @@ public class WebSocketException extends IOException {
|
|||||||
public WebSocketException(String s, Throwable throwable) {
|
public WebSocketException(String s, Throwable throwable) {
|
||||||
super(s, throwable);
|
super(s, throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
|
|
||||||
private static final String WEBSOCKET_PATH = "/websocket";
|
private static final String WEBSOCKET_PATH = "/websocket";
|
||||||
|
|
||||||
private WebSocketServerHandshaker handshaker = null;
|
private WebSocketServerHandshaker handshaker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||||
@ -143,4 +143,4 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
private String getWebSocketLocation(HttpRequest req) {
|
private String getWebSocketLocation(HttpRequest req) {
|
||||||
return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||||||
/**
|
/**
|
||||||
* Generates the demo HTML page which is served at http://localhost:8080/
|
* Generates the demo HTML page which is served at http://localhost:8080/
|
||||||
*/
|
*/
|
||||||
public class WebSocketServerIndexPage {
|
public final class WebSocketServerIndexPage {
|
||||||
|
|
||||||
private static final String NEWLINE = "\r\n";
|
private static final String NEWLINE = "\r\n";
|
||||||
|
|
||||||
@ -89,4 +89,8 @@ public class WebSocketServerIndexPage {
|
|||||||
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE,
|
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE,
|
||||||
CharsetUtil.US_ASCII);
|
CharsetUtil.US_ASCII);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WebSocketServerIndexPage() {
|
||||||
|
// Unused
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
|
|
||||||
private static final String WEBSOCKET_PATH = "/websocket";
|
private static final String WEBSOCKET_PATH = "/websocket";
|
||||||
|
|
||||||
private WebSocketServerHandshaker handshaker = null;
|
private WebSocketServerHandshaker handshaker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
||||||
@ -143,4 +143,4 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
private String getWebSocketLocation(HttpRequest req) {
|
private String getWebSocketLocation(HttpRequest req) {
|
||||||
return "wss://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
return "wss://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||||||
/**
|
/**
|
||||||
* Generates the demo HTML page which is served at http://localhost:8080/
|
* Generates the demo HTML page which is served at http://localhost:8080/
|
||||||
*/
|
*/
|
||||||
public class WebSocketSslServerIndexPage {
|
public final class WebSocketSslServerIndexPage {
|
||||||
|
|
||||||
private static final String NEWLINE = "\r\n";
|
private static final String NEWLINE = "\r\n";
|
||||||
|
|
||||||
@ -89,4 +89,8 @@ public class WebSocketSslServerIndexPage {
|
|||||||
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE,
|
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE,
|
||||||
CharsetUtil.US_ASCII);
|
CharsetUtil.US_ASCII);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WebSocketSslServerIndexPage() {
|
||||||
|
// Unused
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
|||||||
/**
|
/**
|
||||||
* Creates a {@link SSLContext} for just server certificates.
|
* Creates a {@link SSLContext} for just server certificates.
|
||||||
*/
|
*/
|
||||||
public class WebSocketSslServerSslContext {
|
public final class WebSocketSslServerSslContext {
|
||||||
|
|
||||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketSslServerSslContext.class);
|
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketSslServerSslContext.class);
|
||||||
private static final String PROTOCOL = "TLS";
|
private static final String PROTOCOL = "TLS";
|
||||||
@ -98,5 +98,4 @@ public class WebSocketSslServerSslContext {
|
|||||||
public SSLContext getServerContext() {
|
public SSLContext getServerContext() {
|
||||||
return _serverContext;
|
return _serverContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,19 +18,16 @@
|
|||||||
* <p>This package contains an example web socket web server with server SSL.
|
* <p>This package contains an example web socket web server with server SSL.
|
||||||
* <p>To run this example, follow the steps below:
|
* <p>To run this example, follow the steps below:
|
||||||
* <dl>
|
* <dl>
|
||||||
* <dt>Step 1. Generate Your Key</dt>
|
* <dt>Step 1. Generate Your Key
|
||||||
* <dd>
|
* <dd>
|
||||||
* <code>keytool -genkey -keystore mySrvKeystore -keyalg RSA</code>.
|
* <code>keytool -genkey -keystore mySrvKeystore -keyalg RSA</code>.
|
||||||
* Make sure that you set the key password to be the same the key file password.
|
* Make sure that you set the key password to be the same the key file password.
|
||||||
* </dd>
|
* <dt>Step 2. Specify your key store file and password as system properties
|
||||||
* <dt>Step 2. Specify your key store file and password as system properties</dt>
|
* <dd>
|
||||||
* <dd>
|
* <code>-Dkeystore.file.path=<path to mySrvKeystore> -Dkeystore.file.password=<password></code>
|
||||||
* <code>-Dkeystore.file.path=<path to mySrvKeystore> -Dkeystore.file.password=<password></code>
|
* <dt>Step 3. Run WebSocketSslServer as a Java application
|
||||||
* </dd>
|
* <dd>
|
||||||
* <dt>Step 3. Run WebSocketSslServer as a Java application</dt>
|
* Once started, you can test the web server against your browser by navigating to https://localhost:8081/
|
||||||
* <dd>
|
|
||||||
* Once started, you can test the web server against your browser by navigating to https://localhost:8081/
|
|
||||||
* </dd>
|
|
||||||
* </dl>
|
* </dl>
|
||||||
* <p>To find out more about setting up key stores, refer to this
|
* <p>To find out more about setting up key stores, refer to this
|
||||||
* <a href="http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html">giude</a>.
|
* <a href="http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html">giude</a>.
|
||||||
|
@ -65,7 +65,7 @@ public class LocalExampleMultthreaded {
|
|||||||
// Read commands from array
|
// Read commands from array
|
||||||
String[] commands = { "First", "Second", "Third", "quit" };
|
String[] commands = { "First", "Second", "Third", "quit" };
|
||||||
for (int j = 0; j < 5 ; j++) {
|
for (int j = 0; j < 5 ; j++) {
|
||||||
System.err.println("Start "+j);
|
System.err.println("Start " + j);
|
||||||
ChannelFuture channelFuture = cb.connect(socketAddress);
|
ChannelFuture channelFuture = cb.connect(socketAddress);
|
||||||
channelFuture.awaitUninterruptibly();
|
channelFuture.awaitUninterruptibly();
|
||||||
if (! channelFuture.isSuccess()) {
|
if (! channelFuture.isSuccess()) {
|
||||||
@ -86,7 +86,7 @@ public class LocalExampleMultthreaded {
|
|||||||
channelFuture.getChannel().close();
|
channelFuture.getChannel().close();
|
||||||
// Wait until the connection is closed or the connection attempt fails.
|
// Wait until the connection is closed or the connection attempt fails.
|
||||||
channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
|
channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
|
||||||
System.err.println("End "+j);
|
System.err.println("End " + j);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release all resources
|
// Release all resources
|
||||||
|
@ -70,7 +70,7 @@ public class LocalServerPipelineFactory implements ChannelPipelineFactory {
|
|||||||
Channels.close(e.getChannel());
|
Channels.close(e.getChannel());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.err.println("SERVER:"+msg);
|
System.err.println("SERVER:" + msg);
|
||||||
// Write back
|
// Write back
|
||||||
Channels.write(e.getChannel(), msg);
|
Channels.write(e.getChannel(), msg);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,20 @@ public class HexDumpProxy {
|
|||||||
String remoteHost = args[1];
|
String remoteHost = args[1];
|
||||||
int remotePort = Integer.parseInt(args[2]);
|
int remotePort = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
|
new HexDumpProxy(localPort, remoteHost, remotePort).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int localPort;
|
||||||
|
private final String remoteHost;
|
||||||
|
private final int remotePort;
|
||||||
|
|
||||||
|
public HexDumpProxy(int localPort, String remoteHost, int remotePort) {
|
||||||
|
this.localPort = localPort;
|
||||||
|
this.remoteHost = remoteHost;
|
||||||
|
this.remotePort = remotePort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
System.err.println(
|
System.err.println(
|
||||||
"Proxying *:" + localPort + " to " +
|
"Proxying *:" + localPort + " to " +
|
||||||
remoteHost + ':' + remotePort + " ...");
|
remoteHost + ':' + remotePort + " ...");
|
||||||
|
@ -30,7 +30,7 @@ import java.io.InputStream;
|
|||||||
* -keystore cert.jks
|
* -keystore cert.jks
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class SecureChatKeyStore {
|
public final class SecureChatKeyStore {
|
||||||
private static final short[] DATA = new short[] {
|
private static final short[] DATA = new short[] {
|
||||||
0xfe, 0xed, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x02,
|
0xfe, 0xed, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x02,
|
||||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
|
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
@ -49,7 +49,7 @@ import org.jboss.netty.handler.ssl.SslHandler;
|
|||||||
* to validate the client certificate.</li>
|
* to validate the client certificate.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public class SecureChatSslContextFactory {
|
public final class SecureChatSslContextFactory {
|
||||||
|
|
||||||
private static final String PROTOCOL = "TLS";
|
private static final String PROTOCOL = "TLS";
|
||||||
private static final SSLContext SERVER_CONTEXT;
|
private static final SSLContext SERVER_CONTEXT;
|
||||||
@ -99,4 +99,8 @@ public class SecureChatSslContextFactory {
|
|||||||
public static SSLContext getClientContext() {
|
public static SSLContext getClientContext() {
|
||||||
return CLIENT_CONTEXT;
|
return CLIENT_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SecureChatSslContextFactory() {
|
||||||
|
// Unused
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
|||||||
* @apiviz.landmark
|
* @apiviz.landmark
|
||||||
* @apiviz.uses org.jboss.netty.handler.codec.base64.Base64Dialect
|
* @apiviz.uses org.jboss.netty.handler.codec.base64.Base64Dialect
|
||||||
*/
|
*/
|
||||||
public class Base64 {
|
public final class Base64 {
|
||||||
|
|
||||||
/** Maximum line length (76) of Base64 output. */
|
/** Maximum line length (76) of Base64 output. */
|
||||||
private static final int MAX_LINE_LENGTH = 76;
|
private static final int MAX_LINE_LENGTH = 76;
|
||||||
@ -47,21 +47,21 @@ public class Base64 {
|
|||||||
|
|
||||||
private static final byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
private static final byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
||||||
|
|
||||||
private static final byte[] alphabet(Base64Dialect dialect) {
|
private static byte[] alphabet(Base64Dialect dialect) {
|
||||||
if (dialect == null) {
|
if (dialect == null) {
|
||||||
throw new NullPointerException("dialect");
|
throw new NullPointerException("dialect");
|
||||||
}
|
}
|
||||||
return dialect.alphabet;
|
return dialect.alphabet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final byte[] decodabet(Base64Dialect dialect) {
|
private static byte[] decodabet(Base64Dialect dialect) {
|
||||||
if (dialect == null) {
|
if (dialect == null) {
|
||||||
throw new NullPointerException("dialect");
|
throw new NullPointerException("dialect");
|
||||||
}
|
}
|
||||||
return dialect.decodabet;
|
return dialect.decodabet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean breakLines(Base64Dialect dialect) {
|
private static boolean breakLines(Base64Dialect dialect) {
|
||||||
if (dialect == null) {
|
if (dialect == null) {
|
||||||
throw new NullPointerException("dialect");
|
throw new NullPointerException("dialect");
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ public class Base64 {
|
|||||||
// We have to shift left 24 in order to flush out the 1's that appear
|
// We have to shift left 24 in order to flush out the 1's that appear
|
||||||
// when Java treats a value as negative that is cast from a byte to an int.
|
// when Java treats a value as negative that is cast from a byte to an int.
|
||||||
int inBuff =
|
int inBuff =
|
||||||
(numSigBytes > 0? src.getByte(srcOffset ) << 24 >>> 8 : 0) |
|
(numSigBytes > 0? src.getByte(srcOffset) << 24 >>> 8 : 0) |
|
||||||
(numSigBytes > 1? src.getByte(srcOffset + 1) << 24 >>> 16 : 0) |
|
(numSigBytes > 1? src.getByte(srcOffset + 1) << 24 >>> 16 : 0) |
|
||||||
(numSigBytes > 2? src.getByte(srcOffset + 2) << 24 >>> 24 : 0);
|
(numSigBytes > 2? src.getByte(srcOffset + 2) << 24 >>> 24 : 0);
|
||||||
|
|
||||||
@ -301,9 +301,9 @@ public class Base64 {
|
|||||||
sbiDecode = DECODABET[sbiCrop];
|
sbiDecode = DECODABET[sbiCrop];
|
||||||
|
|
||||||
if (sbiDecode >= WHITE_SPACE_ENC) { // White space, Equals sign or better
|
if (sbiDecode >= WHITE_SPACE_ENC) { // White space, Equals sign or better
|
||||||
if (sbiDecode >= EQUALS_SIGN_ENC) {
|
if (sbiDecode >= EQUALS_SIGN_ENC) { // Equals sign or better?
|
||||||
b4[b4Posn ++] = sbiCrop;
|
b4[b4Posn ++] = sbiCrop;
|
||||||
if (b4Posn > 3) {
|
if (b4Posn > 3) { // Quartet built?
|
||||||
outBuffPosn += decode4to3(
|
outBuffPosn += decode4to3(
|
||||||
b4, 0, dest, outBuffPosn, dialect);
|
b4, 0, dest, outBuffPosn, dialect);
|
||||||
b4Posn = 0;
|
b4Posn = 0;
|
||||||
@ -312,10 +312,9 @@ public class Base64 {
|
|||||||
if (sbiCrop == EQUALS_SIGN) {
|
if (sbiCrop == EQUALS_SIGN) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end if: quartet built
|
}
|
||||||
} // end if: equals sign or better
|
}
|
||||||
} // end if: white space, equals sign or better
|
} else {
|
||||||
else {
|
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"bad Base64 input character at " + i + ": " +
|
"bad Base64 input character at " + i + ": " +
|
||||||
src.getUnsignedByte(i) + " (decimal)");
|
src.getUnsignedByte(i) + " (decimal)");
|
||||||
@ -331,18 +330,16 @@ public class Base64 {
|
|||||||
|
|
||||||
byte[] DECODABET = decodabet(dialect);
|
byte[] DECODABET = decodabet(dialect);
|
||||||
|
|
||||||
// Example: Dk==
|
|
||||||
if (src[srcOffset + 2] == EQUALS_SIGN) {
|
if (src[srcOffset + 2] == EQUALS_SIGN) {
|
||||||
|
// Example: Dk==
|
||||||
int outBuff =
|
int outBuff =
|
||||||
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
|
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
|
||||||
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12;
|
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12;
|
||||||
|
|
||||||
dest.setByte(destOffset, (byte) (outBuff >>> 16));
|
dest.setByte(destOffset, (byte) (outBuff >>> 16));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else if (src[srcOffset + 3] == EQUALS_SIGN) {
|
||||||
|
// Example: DkL=
|
||||||
// Example: DkL=
|
|
||||||
else if (src[srcOffset + 3] == EQUALS_SIGN) {
|
|
||||||
int outBuff =
|
int outBuff =
|
||||||
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
|
(DECODABET[src[srcOffset ]] & 0xFF) << 18 |
|
||||||
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12 |
|
(DECODABET[src[srcOffset + 1]] & 0xFF) << 12 |
|
||||||
@ -351,10 +348,8 @@ public class Base64 {
|
|||||||
dest.setByte(destOffset , (byte) (outBuff >>> 16));
|
dest.setByte(destOffset , (byte) (outBuff >>> 16));
|
||||||
dest.setByte(destOffset + 1, (byte) (outBuff >>> 8));
|
dest.setByte(destOffset + 1, (byte) (outBuff >>> 8));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
} else {
|
||||||
|
// Example: DkLE
|
||||||
// Example: DkLE
|
|
||||||
else {
|
|
||||||
int outBuff;
|
int outBuff;
|
||||||
try {
|
try {
|
||||||
outBuff =
|
outBuff =
|
||||||
|
@ -157,7 +157,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne
|
|||||||
ZlibUtil.fail(z, "initialization failure", resultCode);
|
ZlibUtil.fail(z, "initialization failure", resultCode);
|
||||||
} else {
|
} else {
|
||||||
resultCode = z.deflateSetDictionary(dictionary, dictionary.length);
|
resultCode = z.deflateSetDictionary(dictionary, dictionary.length);
|
||||||
if (resultCode != JZlib.Z_OK){
|
if (resultCode != JZlib.Z_OK) {
|
||||||
ZlibUtil.fail(z, "failed to set the dictionary", resultCode);
|
ZlibUtil.fail(z, "failed to set the dictionary", resultCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import org.jboss.netty.channel.ChannelPipeline;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class EmbeddedChannelFactory implements ChannelFactory {
|
final class EmbeddedChannelFactory implements ChannelFactory {
|
||||||
|
|
||||||
static final ChannelFactory INSTANCE = new EmbeddedChannelFactory();
|
static final ChannelFactory INSTANCE = new EmbeddedChannelFactory();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
|
|||||||
/**
|
/**
|
||||||
* A set of commonly used delimiters for {@link DelimiterBasedFrameDecoder}.
|
* A set of commonly used delimiters for {@link DelimiterBasedFrameDecoder}.
|
||||||
*/
|
*/
|
||||||
public class Delimiters {
|
public final class Delimiters {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@code NUL (0x00)} delimiter, which could be used for
|
* Returns a {@code NUL (0x00)} delimiter, which could be used for
|
||||||
|
@ -145,8 +145,8 @@ import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
|
|||||||
* header from the frame. If you don't want to strip the prepended header, you
|
* header from the frame. If you don't want to strip the prepended header, you
|
||||||
* could specify <tt>0</tt> for <tt>initialBytesToSkip</tt>.
|
* could specify <tt>0</tt> for <tt>initialBytesToSkip</tt>.
|
||||||
* <pre>
|
* <pre>
|
||||||
* lengthFieldOffset</b> = 1 (= the length of HDR1)
|
* lengthFieldOffset = 1 (= the length of HDR1)
|
||||||
* lengthFieldLength</b> = 2
|
* lengthFieldLength = 2
|
||||||
* <b>lengthAdjustment</b> = <b>1</b> (= the length of HDR2)
|
* <b>lengthAdjustment</b> = <b>1</b> (= the length of HDR2)
|
||||||
* <b>initialBytesToStrip</b> = <b>3</b> (= the length of HDR1 + LEN)
|
* <b>initialBytesToStrip</b> = <b>3</b> (= the length of HDR1 + LEN)
|
||||||
*
|
*
|
||||||
@ -403,14 +403,12 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder {
|
|||||||
this.tooLongFrameLength = 0;
|
this.tooLongFrameLength = 0;
|
||||||
discardingTooLongFrame = false;
|
discardingTooLongFrame = false;
|
||||||
if ((!failFast) ||
|
if ((!failFast) ||
|
||||||
(failFast && firstDetectionOfTooLongFrame))
|
(failFast && firstDetectionOfTooLongFrame)) {
|
||||||
{
|
|
||||||
fail(ctx, tooLongFrameLength);
|
fail(ctx, tooLongFrameLength);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Keep discarding and notify handlers if necessary.
|
// Keep discarding and notify handlers if necessary.
|
||||||
if (failFast && firstDetectionOfTooLongFrame)
|
if (failFast && firstDetectionOfTooLongFrame) {
|
||||||
{
|
|
||||||
fail(ctx, this.tooLongFrameLength);
|
fail(ctx, this.tooLongFrameLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class CookieDecoder {
|
public class CookieDecoder {
|
||||||
|
|
||||||
private final static Pattern PATTERN =
|
private static final Pattern PATTERN =
|
||||||
Pattern.compile("(?:\\s|[;,])*\\$*([^;=]+)(?:=(?:[\"']((?:\\\\.|[^\"])*)[\"']|([^;,]*)))?(\\s*(?:[;,]+\\s*|$))");
|
Pattern.compile("(?:\\s|[;,])*\\$*([^;=]+)(?:=(?:[\"']((?:\\\\.|[^\"])*)[\"']|([^;,]*)))?(\\s*(?:[;,]+\\s*|$))");
|
||||||
|
|
||||||
private final static String COMMA = ",";
|
private static final String COMMA = ",";
|
||||||
|
|
||||||
private final boolean lenient;
|
private final boolean lenient;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public class CookieEncoder {
|
|||||||
addQuoted(sb, CookieHeaderNames.COMMENTURL, cookie.getCommentUrl());
|
addQuoted(sb, CookieHeaderNames.COMMENTURL, cookie.getCommentUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!cookie.getPorts().isEmpty()) {
|
if (!cookie.getPorts().isEmpty()) {
|
||||||
sb.append(CookieHeaderNames.PORT);
|
sb.append(CookieHeaderNames.PORT);
|
||||||
sb.append((char) HttpCodecUtil.EQUALS);
|
sb.append((char) HttpCodecUtil.EQUALS);
|
||||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||||
@ -189,7 +189,7 @@ public class CookieEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cookie.getVersion() >= 1) {
|
if (cookie.getVersion() >= 1) {
|
||||||
if(!cookie.getPorts().isEmpty()) {
|
if (!cookie.getPorts().isEmpty()) {
|
||||||
sb.append('$');
|
sb.append('$');
|
||||||
sb.append(CookieHeaderNames.PORT);
|
sb.append(CookieHeaderNames.PORT);
|
||||||
sb.append((char) HttpCodecUtil.EQUALS);
|
sb.append((char) HttpCodecUtil.EQUALS);
|
||||||
@ -204,8 +204,9 @@ public class CookieEncoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sb.length() > 0)
|
if (sb.length() > 0) {
|
||||||
sb.setLength(sb.length() - 1);
|
sb.setLength(sb.length() - 1);
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public interface HttpChunk {
|
|||||||
/**
|
/**
|
||||||
* The 'end of content' marker in chunked encoding.
|
* The 'end of content' marker in chunked encoding.
|
||||||
*/
|
*/
|
||||||
static HttpChunkTrailer LAST_CHUNK = new HttpChunkTrailer() {
|
HttpChunkTrailer LAST_CHUNK = new HttpChunkTrailer() {
|
||||||
public ChannelBuffer getContent() {
|
public ChannelBuffer getContent() {
|
||||||
return ChannelBuffers.EMPTY_BUFFER;
|
return ChannelBuffers.EMPTY_BUFFER;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class HttpCodecUtil {
|
final class HttpCodecUtil {
|
||||||
//space ' '
|
//space ' '
|
||||||
static final byte SP = 32;
|
static final byte SP = 32;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class HttpHeaders {
|
|||||||
/**
|
/**
|
||||||
* {@code "Accept-Encoding"}
|
* {@code "Accept-Encoding"}
|
||||||
*/
|
*/
|
||||||
public static final String ACCEPT_ENCODING= "Accept-Encoding";
|
public static final String ACCEPT_ENCODING = "Accept-Encoding";
|
||||||
/**
|
/**
|
||||||
* {@code "Accept-Language"}
|
* {@code "Accept-Language"}
|
||||||
*/
|
*/
|
||||||
@ -54,11 +54,11 @@ public class HttpHeaders {
|
|||||||
/**
|
/**
|
||||||
* {@code "Accept-Ranges"}
|
* {@code "Accept-Ranges"}
|
||||||
*/
|
*/
|
||||||
public static final String ACCEPT_RANGES= "Accept-Ranges";
|
public static final String ACCEPT_RANGES = "Accept-Ranges";
|
||||||
/**
|
/**
|
||||||
* {@code "Accept-Patch"}
|
* {@code "Accept-Patch"}
|
||||||
*/
|
*/
|
||||||
public static final String ACCEPT_PATCH= "Accept-Patch";
|
public static final String ACCEPT_PATCH = "Accept-Patch";
|
||||||
/**
|
/**
|
||||||
* {@code "Age"}
|
* {@code "Age"}
|
||||||
*/
|
*/
|
||||||
@ -90,7 +90,7 @@ public class HttpHeaders {
|
|||||||
/**
|
/**
|
||||||
* {@code "Content-Language"}
|
* {@code "Content-Language"}
|
||||||
*/
|
*/
|
||||||
public static final String CONTENT_LANGUAGE= "Content-Language";
|
public static final String CONTENT_LANGUAGE = "Content-Language";
|
||||||
/**
|
/**
|
||||||
* {@code "Content-Length"}
|
* {@code "Content-Length"}
|
||||||
*/
|
*/
|
||||||
@ -114,7 +114,7 @@ public class HttpHeaders {
|
|||||||
/**
|
/**
|
||||||
* {@code "Content-Type"}
|
* {@code "Content-Type"}
|
||||||
*/
|
*/
|
||||||
public static final String CONTENT_TYPE= "Content-Type";
|
public static final String CONTENT_TYPE = "Content-Type";
|
||||||
/**
|
/**
|
||||||
* {@code "Cookie"}
|
* {@code "Cookie"}
|
||||||
*/
|
*/
|
||||||
@ -158,7 +158,7 @@ public class HttpHeaders {
|
|||||||
/**
|
/**
|
||||||
* {@code "If-Range"}
|
* {@code "If-Range"}
|
||||||
*/
|
*/
|
||||||
public static final String IF_RANGE= "If-Range";
|
public static final String IF_RANGE = "If-Range";
|
||||||
/**
|
/**
|
||||||
* {@code "If-Unmodified-Since"}
|
* {@code "If-Unmodified-Since"}
|
||||||
*/
|
*/
|
||||||
@ -226,15 +226,15 @@ public class HttpHeaders {
|
|||||||
/**
|
/**
|
||||||
* {@code "Sec-WebSocket-Version"}
|
* {@code "Sec-WebSocket-Version"}
|
||||||
*/
|
*/
|
||||||
public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
|
public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
|
||||||
/**
|
/**
|
||||||
* {@code "Sec-WebSocket-Key"}
|
* {@code "Sec-WebSocket-Key"}
|
||||||
*/
|
*/
|
||||||
public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
|
public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
|
||||||
/**
|
/**
|
||||||
* {@code "Sec-WebSocket-Accept"}
|
* {@code "Sec-WebSocket-Accept"}
|
||||||
*/
|
*/
|
||||||
public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
|
public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
|
||||||
/**
|
/**
|
||||||
* {@code "Server"}
|
* {@code "Server"}
|
||||||
*/
|
*/
|
||||||
|
@ -568,11 +568,9 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
|||||||
if (nextByte == HttpCodecUtil.LF) {
|
if (nextByte == HttpCodecUtil.LF) {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
} else if (nextByte == HttpCodecUtil.LF) {
|
||||||
else if (nextByte == HttpCodecUtil.LF) {
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (lineLength >= maxLineLength) {
|
if (lineLength >= maxLineLength) {
|
||||||
// TODO: Respond with Bad Request and discard the traffic
|
// TODO: Respond with Bad Request and discard the traffic
|
||||||
// or close the connection.
|
// or close the connection.
|
||||||
|
@ -72,7 +72,7 @@ public class HttpRequestDecoder extends HttpMessageDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpMessage createMessage(String[] initialLine) throws Exception{
|
protected HttpMessage createMessage(String[] initialLine) throws Exception {
|
||||||
return new DefaultHttpRequest(
|
return new DefaultHttpRequest(
|
||||||
HttpVersion.valueOf(initialLine[2]), HttpMethod.valueOf(initialLine[0]), initialLine[1]);
|
HttpVersion.valueOf(initialLine[2]), HttpMethod.valueOf(initialLine[0]), initialLine[1]);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class QueryStringDecoder {
|
|||||||
* Creates a new decoder that decodes the specified URI encoded in the
|
* Creates a new decoder that decodes the specified URI encoded in the
|
||||||
* specified charset.
|
* specified charset.
|
||||||
*/
|
*/
|
||||||
public QueryStringDecoder(URI uri, Charset charset){
|
public QueryStringDecoder(URI uri, Charset charset) {
|
||||||
this(uri, charset, DEFAULT_MAX_PARAMS);
|
this(uri, charset, DEFAULT_MAX_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public class QueryStringDecoder {
|
|||||||
* @deprecated Use {@link #QueryStringDecoder(URI, Charset)} instead.
|
* @deprecated Use {@link #QueryStringDecoder(URI, Charset)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public QueryStringDecoder(URI uri, String charset){
|
public QueryStringDecoder(URI uri, String charset) {
|
||||||
this(uri, Charset.forName(charset));
|
this(uri, Charset.forName(charset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,8 +190,7 @@ public class QueryStringDecoder {
|
|||||||
int pathEndPos = uri.indexOf('?');
|
int pathEndPos = uri.indexOf('?');
|
||||||
if (pathEndPos < 0) {
|
if (pathEndPos < 0) {
|
||||||
path = uri;
|
path = uri;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return path = uri.substring(0, pathEndPos);
|
return path = uri.substring(0, pathEndPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class QueryStringEncoder {
|
|||||||
sb.append(encodeComponent(param.name, charset));
|
sb.append(encodeComponent(param.name, charset));
|
||||||
sb.append("=");
|
sb.append("=");
|
||||||
sb.append(encodeComponent(param.value, charset));
|
sb.append(encodeComponent(param.value, charset));
|
||||||
if(i != params.size() - 1) {
|
if (i != params.size() - 1) {
|
||||||
sb.append("&");
|
sb.append("&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import org.jboss.netty.util.CharsetUtil;
|
|||||||
*/
|
*/
|
||||||
public class ContinuationWebSocketFrame extends WebSocketFrame {
|
public class ContinuationWebSocketFrame extends WebSocketFrame {
|
||||||
|
|
||||||
private String aggregatedText = null;
|
private String aggregatedText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty continuation frame.
|
* Creates a new empty continuation frame.
|
||||||
|
@ -42,7 +42,7 @@ final class UTF8Output {
|
|||||||
12, 12, 12, 12, 12, 12, 12, 12 };
|
12, 12, 12, 12, 12, 12, 12, 12 };
|
||||||
|
|
||||||
private int state = UTF8_ACCEPT;
|
private int state = UTF8_ACCEPT;
|
||||||
private int codep = 0;
|
private int codep;
|
||||||
|
|
||||||
private final StringBuilder stringBuilder;
|
private final StringBuilder stringBuilder;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ final class UTF8Output {
|
|||||||
public void write(int b) {
|
public void write(int b) {
|
||||||
byte type = TYPES[b & 0xFF];
|
byte type = TYPES[b & 0xFF];
|
||||||
|
|
||||||
codep = (state != UTF8_ACCEPT) ? (b & 0x3f) | (codep << 6) : (0xff >> type) & (b);
|
codep = (state != UTF8_ACCEPT) ? (b & 0x3f) | (codep << 6) : (0xff >> type) & b;
|
||||||
|
|
||||||
state = STATES[state + type];
|
state = STATES[state + type];
|
||||||
|
|
||||||
|
@ -64,20 +64,20 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||||||
private static final byte OPCODE_PING = 0x9;
|
private static final byte OPCODE_PING = 0x9;
|
||||||
private static final byte OPCODE_PONG = 0xA;
|
private static final byte OPCODE_PONG = 0xA;
|
||||||
|
|
||||||
private UTF8Output fragmentedFramesText = null;
|
private UTF8Output fragmentedFramesText;
|
||||||
private int fragmentedFramesCount = 0;
|
private int fragmentedFramesCount;
|
||||||
|
|
||||||
private boolean frameFinalFlag;
|
private boolean frameFinalFlag;
|
||||||
private int frameRsv;
|
private int frameRsv;
|
||||||
private int frameOpcode;
|
private int frameOpcode;
|
||||||
private long framePayloadLength;
|
private long framePayloadLength;
|
||||||
private ChannelBuffer framePayload = null;
|
private ChannelBuffer framePayload;
|
||||||
private int framePayloadBytesRead = 0;
|
private int framePayloadBytesRead;
|
||||||
private ChannelBuffer maskingKey;
|
private ChannelBuffer maskingKey;
|
||||||
|
|
||||||
private boolean allowExtensions = false;
|
private boolean allowExtensions;
|
||||||
private boolean maskedPayload = false;
|
private boolean maskedPayload;
|
||||||
private boolean receivedClosingHandshake = false;
|
private boolean receivedClosingHandshake;
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
FRAME_START, MASKING_KEY, PAYLOAD, CORRUPT
|
FRAME_START, MASKING_KEY, PAYLOAD, CORRUPT
|
||||||
@ -118,7 +118,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||||||
byte b = buffer.readByte();
|
byte b = buffer.readByte();
|
||||||
frameFinalFlag = (b & 0x80) != 0;
|
frameFinalFlag = (b & 0x80) != 0;
|
||||||
frameRsv = (b & 0x70) >> 4;
|
frameRsv = (b & 0x70) >> 4;
|
||||||
frameOpcode = (b & 0x0F);
|
frameOpcode = b & 0x0F;
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Decoding WebSocket Frame opCode=" + frameOpcode);
|
logger.debug("Decoding WebSocket Frame opCode=" + frameOpcode);
|
||||||
@ -127,7 +127,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||||||
// MASK, PAYLOAD LEN 1
|
// MASK, PAYLOAD LEN 1
|
||||||
b = buffer.readByte();
|
b = buffer.readByte();
|
||||||
boolean frameMasked = (b & 0x80) != 0;
|
boolean frameMasked = (b & 0x80) != 0;
|
||||||
int framePayloadLen1 = (b & 0x7F);
|
int framePayloadLen1 = b & 0x7F;
|
||||||
|
|
||||||
if (frameRsv != 0 && !this.allowExtensions) {
|
if (frameRsv != 0 && !this.allowExtensions) {
|
||||||
protocolViolation(channel, "RSV != 0 and no extension negotiated, RSV:" + frameRsv);
|
protocolViolation(channel, "RSV != 0 and no extension negotiated, RSV:" + frameRsv);
|
||||||
|
@ -66,7 +66,7 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
|||||||
private static final byte OPCODE_PING = 0x9;
|
private static final byte OPCODE_PING = 0x9;
|
||||||
private static final byte OPCODE_PONG = 0xA;
|
private static final byte OPCODE_PONG = 0xA;
|
||||||
|
|
||||||
private boolean maskPayload = false;
|
private boolean maskPayload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -116,7 +116,7 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
|||||||
|
|
||||||
int b0 = 0;
|
int b0 = 0;
|
||||||
if (frame.isFinalFragment()) {
|
if (frame.isFinalFragment()) {
|
||||||
b0 |= (1 << 7);
|
b0 |= 1 << 7;
|
||||||
}
|
}
|
||||||
b0 |= (frame.getRsv() % 8) << 4;
|
b0 |= (frame.getRsv() % 8) << 4;
|
||||||
b0 |= opcode % 128;
|
b0 |= opcode % 128;
|
||||||
@ -138,13 +138,13 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
|||||||
} else if (length <= 0xFFFF) {
|
} else if (length <= 0xFFFF) {
|
||||||
header = ChannelBuffers.buffer(4 + maskLength);
|
header = ChannelBuffers.buffer(4 + maskLength);
|
||||||
header.writeByte(b0);
|
header.writeByte(b0);
|
||||||
header.writeByte(this.maskPayload ? (0xFE) : 126);
|
header.writeByte(this.maskPayload ? 0xFE : 126);
|
||||||
header.writeByte((length >>> 8) & 0xFF);
|
header.writeByte((length >>> 8) & 0xFF);
|
||||||
header.writeByte((length) & 0xFF);
|
header.writeByte(length & 0xFF);
|
||||||
} else {
|
} else {
|
||||||
header = ChannelBuffers.buffer(10 + maskLength);
|
header = ChannelBuffers.buffer(10 + maskLength);
|
||||||
header.writeByte(b0);
|
header.writeByte(b0);
|
||||||
header.writeByte(this.maskPayload ? (0xFF) : 127);
|
header.writeByte(this.maskPayload ? 0xFF : 127);
|
||||||
header.writeLong(length);
|
header.writeLong(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,4 +170,4 @@ public class WebSocket08FrameEncoder extends OneToOneEncoder {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ public abstract class WebSocketClientHandshaker {
|
|||||||
|
|
||||||
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
|
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
|
||||||
|
|
||||||
private boolean openingHandshakeCompleted = false;
|
private boolean openingHandshakeCompleted;
|
||||||
|
|
||||||
private String subProtocolRequest = null;
|
private String subProtocolRequest;
|
||||||
|
|
||||||
private String subProtocolResponse = null;
|
private String subProtocolResponse;
|
||||||
|
|
||||||
protected Map<String, String> customHeaders = null;
|
protected Map<String, String> customHeaders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base constructor
|
* Base constructor
|
||||||
@ -212,4 +212,4 @@ public abstract class WebSocketClientHandshaker {
|
|||||||
protected int createRandomNumber(int min, int max) {
|
protected int createRandomNumber(int min, int max) {
|
||||||
return (int) (Math.random() * max + min);
|
return (int) (Math.random() * max + min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ import org.jboss.netty.handler.codec.http.HttpVersion;
|
|||||||
*/
|
*/
|
||||||
public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||||
|
|
||||||
private byte[] expectedChallengeResponseBytes = null;
|
private byte[] expectedChallengeResponseBytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor specifying the destination web socket location and version to initiate
|
* Constructor specifying the destination web socket location and version to initiate
|
||||||
@ -243,4 +243,4 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
|||||||
|
|
||||||
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
|
|
||||||
private String expectedChallengeResponseString = null;
|
private String expectedChallengeResponseString;
|
||||||
|
|
||||||
private static final String protocol = null;
|
private static final String protocol = null;
|
||||||
|
|
||||||
private boolean allowExtensions = false;
|
private boolean allowExtensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor specifying the destination web socket location and version to initiate
|
* Constructor specifying the destination web socket location and version to initiate
|
||||||
|
@ -46,11 +46,11 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
|||||||
|
|
||||||
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
|
|
||||||
private String expectedChallengeResponseString = null;
|
private String expectedChallengeResponseString;
|
||||||
|
|
||||||
private static final String protocol = null;
|
private static final String protocol = null;
|
||||||
|
|
||||||
private boolean allowExtensions = false;
|
private boolean allowExtensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor specifying the destination web socket location and version to initiate
|
* Constructor specifying the destination web socket location and version to initiate
|
||||||
@ -188,4 +188,4 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
|||||||
this.setOpenningHandshakeCompleted(true);
|
this.setOpenningHandshakeCompleted(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public abstract class WebSocketFrame {
|
|||||||
/**
|
/**
|
||||||
* RSV1, RSV2, RSV3 used for extensions
|
* RSV1, RSV2, RSV3 used for extensions
|
||||||
*/
|
*/
|
||||||
private int rsv = 0;
|
private int rsv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contents of this frame
|
* Contents of this frame
|
||||||
|
@ -31,7 +31,7 @@ public abstract class WebSocketServerHandshaker {
|
|||||||
|
|
||||||
private String subProtocols;
|
private String subProtocols;
|
||||||
|
|
||||||
private String[] subProtocolsArray = null;
|
private String[] subProtocolsArray;
|
||||||
|
|
||||||
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
|
private WebSocketVersion version = WebSocketVersion.UNKNOWN;
|
||||||
|
|
||||||
@ -180,4 +180,4 @@ public abstract class WebSocketServerHandshaker {
|
|||||||
// No match found
|
// No match found
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,4 +195,4 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
|||||||
public void performClosingHandshake(Channel channel, CloseWebSocketFrame frame) {
|
public void performClosingHandshake(Channel channel, CloseWebSocketFrame frame) {
|
||||||
channel.write(frame);
|
channel.write(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
|||||||
|
|
||||||
public static final String WEBSOCKET_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
public static final String WEBSOCKET_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
|
|
||||||
private boolean allowExtensions = false;
|
private boolean allowExtensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor specifying the destination web socket location
|
* Constructor specifying the destination web socket location
|
||||||
@ -163,4 +163,4 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
|||||||
f.addListener(ChannelFutureListener.CLOSE);
|
f.addListener(ChannelFutureListener.CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
|||||||
|
|
||||||
public static final String WEBSOCKET_13_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
public static final String WEBSOCKET_13_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
|
|
||||||
private boolean allowExtensions = false;
|
private boolean allowExtensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor specifying the destination web socket location
|
* Constructor specifying the destination web socket location
|
||||||
@ -163,4 +163,4 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
|||||||
f.addListener(ChannelFutureListener.CLOSE);
|
f.addListener(ChannelFutureListener.CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class WebSocketServerHandshakerFactory {
|
|||||||
|
|
||||||
private final String subProtocols;
|
private final String subProtocols;
|
||||||
|
|
||||||
private boolean allowExtensions = false;
|
private boolean allowExtensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor specifying the destination web socket location
|
* Constructor specifying the destination web socket location
|
||||||
|
@ -95,7 +95,7 @@ public class ProtobufDecoder extends OneToOneDecoder {
|
|||||||
ChannelBuffer buf = (ChannelBuffer) msg;
|
ChannelBuffer buf = (ChannelBuffer) msg;
|
||||||
if (buf.hasArray()) {
|
if (buf.hasArray()) {
|
||||||
final int offset = buf.readerIndex();
|
final int offset = buf.readerIndex();
|
||||||
if(extensionRegistry == null) {
|
if (extensionRegistry == null) {
|
||||||
return prototype.newBuilderForType().mergeFrom(
|
return prototype.newBuilderForType().mergeFrom(
|
||||||
buf.array(), buf.arrayOffset() + offset, buf.readableBytes()).build();
|
buf.array(), buf.arrayOffset() + offset, buf.readableBytes()).build();
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,7 +19,7 @@ import java.lang.ref.Reference;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ClassResolvers {
|
public final class ClassResolvers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cache disabled
|
* cache disabled
|
||||||
@ -86,4 +86,8 @@ public class ClassResolvers {
|
|||||||
|
|
||||||
return ClassResolvers.class.getClassLoader();
|
return ClassResolvers.class.getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassResolvers() {
|
||||||
|
// Unused
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends
|
|||||||
tasks.add(command);
|
tasks.add(command);
|
||||||
|
|
||||||
|
|
||||||
if (isRunning.get() == false) {
|
if (!isRunning.get()) {
|
||||||
doUnorderedExecute(this);
|
doUnorderedExecute(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
private final Queue<MessageEvent> pendingEncryptedWrites = QueueFactory.createQueue(MessageEvent.class);
|
private final Queue<MessageEvent> pendingEncryptedWrites = QueueFactory.createQueue(MessageEvent.class);
|
||||||
private final NonReentrantLock pendingEncryptedWritesLock = new NonReentrantLock();
|
private final NonReentrantLock pendingEncryptedWritesLock = new NonReentrantLock();
|
||||||
|
|
||||||
private volatile boolean issueHandshake = false;
|
private volatile boolean issueHandshake;
|
||||||
|
|
||||||
private static final ChannelFutureListener HANDSHAKE_LISTENER = new ChannelFutureListener() {
|
private static final ChannelFutureListener HANDSHAKE_LISTENER = new ChannelFutureListener() {
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||||||
* A utility class that provides various common operations and constants
|
* A utility class that provides various common operations and constants
|
||||||
* related with {@link Charset} and its relevant classes.
|
* related with {@link Charset} and its relevant classes.
|
||||||
*/
|
*/
|
||||||
public class CharsetUtil {
|
public final class CharsetUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 16-bit UTF (UCS Transformation Format) whose byte order is identified by
|
* 16-bit UTF (UCS Transformation Format) whose byte order is identified by
|
||||||
@ -61,7 +61,7 @@ public class CharsetUtil {
|
|||||||
public static final Charset US_ASCII = Charset.forName("US-ASCII");
|
public static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||||
|
|
||||||
private static final ThreadLocal<Map<Charset, CharsetEncoder>> encoders =
|
private static final ThreadLocal<Map<Charset, CharsetEncoder>> encoders =
|
||||||
new ThreadLocal<Map<Charset,CharsetEncoder>>() {
|
new ThreadLocal<Map<Charset, CharsetEncoder>>() {
|
||||||
@Override
|
@Override
|
||||||
protected Map<Charset, CharsetEncoder> initialValue() {
|
protected Map<Charset, CharsetEncoder> initialValue() {
|
||||||
return new IdentityHashMap<Charset, CharsetEncoder>();
|
return new IdentityHashMap<Charset, CharsetEncoder>();
|
||||||
@ -69,7 +69,7 @@ public class CharsetUtil {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static final ThreadLocal<Map<Charset, CharsetDecoder>> decoders =
|
private static final ThreadLocal<Map<Charset, CharsetDecoder>> decoders =
|
||||||
new ThreadLocal<Map<Charset,CharsetDecoder>>() {
|
new ThreadLocal<Map<Charset, CharsetDecoder>>() {
|
||||||
@Override
|
@Override
|
||||||
protected Map<Charset, CharsetDecoder> initialValue() {
|
protected Map<Charset, CharsetDecoder> initialValue() {
|
||||||
return new IdentityHashMap<Charset, CharsetDecoder>();
|
return new IdentityHashMap<Charset, CharsetDecoder>();
|
||||||
|
@ -32,7 +32,7 @@ import org.jboss.netty.util.internal.SystemPropertyUtil;
|
|||||||
* {@link ChannelPipeline} or {@link ChannelSink} are retained as it is to help
|
* {@link ChannelPipeline} or {@link ChannelSink} are retained as it is to help
|
||||||
* debugging Netty.
|
* debugging Netty.
|
||||||
*/
|
*/
|
||||||
public class DebugUtil {
|
public final class DebugUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if and only if Netty debug mode is enabled.
|
* Returns {@code true} if and only if Netty debug mode is enabled.
|
||||||
|
@ -19,7 +19,7 @@ package org.jboss.netty.util;
|
|||||||
* A utility class that provides the convenient shutdown of
|
* A utility class that provides the convenient shutdown of
|
||||||
* {@link ExternalResourceReleasable}s.
|
* {@link ExternalResourceReleasable}s.
|
||||||
*/
|
*/
|
||||||
public class ExternalResourceUtil {
|
public final class ExternalResourceUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases the specified {@link ExternalResourceReleasable}s.
|
* Releases the specified {@link ExternalResourceReleasable}s.
|
||||||
|
@ -543,7 +543,7 @@ public class HashedWheelTimer implements Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
buf.append (", cancelled");
|
buf.append(", cancelled");
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.append(')').toString();
|
return buf.append(')').toString();
|
||||||
|
@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class UnsafeDetectUtil {
|
public final class UnsafeDetectUtil {
|
||||||
|
|
||||||
private static final String UNSAFE = "sun.misc.Unsafe";
|
private static final String UNSAFE = "sun.misc.Unsafe";
|
||||||
private static final boolean UNSAFE_FOUND = isUnsafeFound(AtomicInteger.class.getClassLoader());
|
private static final boolean UNSAFE_FOUND = isUnsafeFound(AtomicInteger.class.getClassLoader());
|
||||||
|
@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class AtomicFieldUpdaterUtil {
|
final class AtomicFieldUpdaterUtil {
|
||||||
|
|
||||||
private static final boolean AVAILABLE;
|
private static final boolean AVAILABLE;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class AtomicFieldUpdaterUtil {
|
|||||||
AVAILABLE = available;
|
AVAILABLE = available;
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T, V> AtomicReferenceFieldUpdater<T,V> newRefUpdater(Class<T> tclass, Class<V> vclass, String fieldName) {
|
static <T, V> AtomicReferenceFieldUpdater<T, V> newRefUpdater(Class<T> tclass, Class<V> vclass, String fieldName) {
|
||||||
if (AVAILABLE) {
|
if (AVAILABLE) {
|
||||||
return AtomicReferenceFieldUpdater.newUpdater(tclass, vclass, fieldName);
|
return AtomicReferenceFieldUpdater.newUpdater(tclass, vclass, fieldName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
* @param <V> the type of mapped values
|
* @param <V> the type of mapped values
|
||||||
*/
|
*/
|
||||||
public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
||||||
implements ConcurrentMap<K, V>{
|
implements ConcurrentMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default initial capacity for this table, used when not otherwise
|
* The default initial capacity for this table, used when not otherwise
|
||||||
@ -65,7 +65,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
/**
|
/**
|
||||||
* The maximum capacity, used if a higher value is implicitly specified by
|
* The maximum capacity, used if a higher value is implicitly specified by
|
||||||
* either of the constructors with arguments. MUST be a power of two
|
* either of the constructors with arguments. MUST be a power of two
|
||||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||||
*/
|
*/
|
||||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
* @param hash the hash code for the key
|
* @param hash the hash code for the key
|
||||||
* @return the segment
|
* @return the segment
|
||||||
*/
|
*/
|
||||||
final Segment<K, V> segmentFor(int hash) {
|
Segment<K, V> segmentFor(int hash) {
|
||||||
return segments[hash >>> segmentShift & segmentMask];
|
return segments[hash >>> segmentShift & segmentMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,21 +166,21 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final K key() {
|
K key() {
|
||||||
return (K) key;
|
return (K) key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final V value() {
|
V value() {
|
||||||
return (V) value;
|
return (V) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setValue(V value) {
|
void setValue(V value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||||
return new HashEntry[i];
|
return new HashEntry[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,11 +262,11 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
|
|
||||||
Segment(int initialCapacity, float lf) {
|
Segment(int initialCapacity, float lf) {
|
||||||
loadFactor = lf;
|
loadFactor = lf;
|
||||||
setTable(HashEntry.<K, V> newArray(initialCapacity));
|
setTable(HashEntry.<K, V>newArray(initialCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||||
return new Segment[i];
|
return new Segment[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,8 +916,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
@ -960,8 +958,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if the specified key is null
|
* @throws NullPointerException if the specified key is null
|
||||||
*/
|
*/
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
@ -973,8 +969,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if any of the arguments are null
|
* @throws NullPointerException if any of the arguments are null
|
||||||
*/
|
*/
|
||||||
public boolean replace(K key, V oldValue, V newValue) {
|
public boolean replace(K key, V oldValue, V newValue) {
|
||||||
@ -986,8 +980,6 @@ public final class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
* @param <V> the type of mapped values
|
* @param <V> the type of mapped values
|
||||||
*/
|
*/
|
||||||
public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
||||||
implements ConcurrentMap<K, V>{
|
implements ConcurrentMap<K, V> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default initial capacity for this table, used when not otherwise
|
* The default initial capacity for this table, used when not otherwise
|
||||||
@ -65,7 +65,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
/**
|
/**
|
||||||
* The maximum capacity, used if a higher value is implicitly specified by
|
* The maximum capacity, used if a higher value is implicitly specified by
|
||||||
* either of the constructors with arguments. MUST be a power of two
|
* either of the constructors with arguments. MUST be a power of two
|
||||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||||
*/
|
*/
|
||||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
* @param hash the hash code for the key
|
* @param hash the hash code for the key
|
||||||
* @return the segment
|
* @return the segment
|
||||||
*/
|
*/
|
||||||
final Segment<K, V> segmentFor(int hash) {
|
Segment<K, V> segmentFor(int hash) {
|
||||||
return segments[hash >>> segmentShift & segmentMask];
|
return segments[hash >>> segmentShift & segmentMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,21 +166,21 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final K key() {
|
K key() {
|
||||||
return (K) key;
|
return (K) key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final V value() {
|
V value() {
|
||||||
return (V) value;
|
return (V) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setValue(V value) {
|
void setValue(V value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||||
return new HashEntry[i];
|
return new HashEntry[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,11 +262,11 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
|
|
||||||
Segment(int initialCapacity, float lf) {
|
Segment(int initialCapacity, float lf) {
|
||||||
loadFactor = lf;
|
loadFactor = lf;
|
||||||
setTable(HashEntry.<K, V> newArray(initialCapacity));
|
setTable(HashEntry.<K, V>newArray(initialCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||||
return new Segment[i];
|
return new Segment[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,8 +916,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
@ -960,8 +958,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if the specified key is null
|
* @throws NullPointerException if the specified key is null
|
||||||
*/
|
*/
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
@ -973,8 +969,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if any of the arguments are null
|
* @throws NullPointerException if any of the arguments are null
|
||||||
*/
|
*/
|
||||||
public boolean replace(K key, V oldValue, V newValue) {
|
public boolean replace(K key, V oldValue, V newValue) {
|
||||||
@ -986,8 +980,6 @@ public final class ConcurrentIdentityHashMap<K, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
|
@ -72,7 +72,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
/**
|
/**
|
||||||
* The maximum capacity, used if a higher value is implicitly specified by
|
* The maximum capacity, used if a higher value is implicitly specified by
|
||||||
* either of the constructors with arguments. MUST be a power of two
|
* either of the constructors with arguments. MUST be a power of two
|
||||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||||
*/
|
*/
|
||||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
* @param hash the hash code for the key
|
* @param hash the hash code for the key
|
||||||
* @return the segment
|
* @return the segment
|
||||||
*/
|
*/
|
||||||
final Segment<K, V> segmentFor(int hash) {
|
Segment<K, V> segmentFor(int hash) {
|
||||||
return segments[hash >>> segmentShift & segmentMask];
|
return segments[hash >>> segmentShift & segmentMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +160,11 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int keyHash() {
|
public int keyHash() {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Object keyRef() {
|
public Object keyRef() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,16 +197,16 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final K key() {
|
K key() {
|
||||||
return ((WeakReference<K>) keyRef).get();
|
return ((WeakReference<K>) keyRef).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
final V value() {
|
V value() {
|
||||||
return dereferenceValue(valueRef);
|
return dereferenceValue(valueRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final V dereferenceValue(Object value) {
|
V dereferenceValue(Object value) {
|
||||||
if (value instanceof WeakKeyReference) {
|
if (value instanceof WeakKeyReference) {
|
||||||
return ((Reference<V>) value).get();
|
return ((Reference<V>) value).get();
|
||||||
}
|
}
|
||||||
@ -214,12 +214,12 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
return (V) value;
|
return (V) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setValue(V value) {
|
void setValue(V value) {
|
||||||
this.valueRef = value;
|
this.valueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||||
return new HashEntry[i];
|
return new HashEntry[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,11 +307,11 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
|
|
||||||
Segment(int initialCapacity, float lf) {
|
Segment(int initialCapacity, float lf) {
|
||||||
loadFactor = lf;
|
loadFactor = lf;
|
||||||
setTable(HashEntry.<K, V> newArray(initialCapacity));
|
setTable(HashEntry.<K, V>newArray(initialCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||||
return new Segment[i];
|
return new Segment[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
final void removeStale() {
|
void removeStale() {
|
||||||
WeakKeyReference ref;
|
WeakKeyReference ref;
|
||||||
while ((ref = (WeakKeyReference) refQueue.poll()) != null) {
|
while ((ref = (WeakKeyReference) refQueue.poll()) != null) {
|
||||||
remove(ref.keyRef(), ref.keyHash(), null, true);
|
remove(ref.keyRef(), ref.keyHash(), null, true);
|
||||||
@ -979,8 +979,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
@ -1023,8 +1021,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if the specified key is null
|
* @throws NullPointerException if the specified key is null
|
||||||
*/
|
*/
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
@ -1036,8 +1032,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if any of the arguments are null
|
* @throws NullPointerException if any of the arguments are null
|
||||||
*/
|
*/
|
||||||
public boolean replace(K key, V oldValue, V newValue) {
|
public boolean replace(K key, V oldValue, V newValue) {
|
||||||
@ -1049,8 +1043,6 @@ public final class ConcurrentIdentityWeakKeyHashMap<K, V> extends AbstractMap<K,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
|
@ -72,7 +72,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
/**
|
/**
|
||||||
* The maximum capacity, used if a higher value is implicitly specified by
|
* The maximum capacity, used if a higher value is implicitly specified by
|
||||||
* either of the constructors with arguments. MUST be a power of two
|
* either of the constructors with arguments. MUST be a power of two
|
||||||
* <= 1<<30 to ensure that entries are indexable using integers.
|
* <= 1<<30 to ensure that entries are indexable using integers.
|
||||||
*/
|
*/
|
||||||
static final int MAXIMUM_CAPACITY = 1 << 30;
|
static final int MAXIMUM_CAPACITY = 1 << 30;
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
* @param hash the hash code for the key
|
* @param hash the hash code for the key
|
||||||
* @return the segment
|
* @return the segment
|
||||||
*/
|
*/
|
||||||
final Segment<K, V> segmentFor(int hash) {
|
Segment<K, V> segmentFor(int hash) {
|
||||||
return segments[hash >>> segmentShift & segmentMask];
|
return segments[hash >>> segmentShift & segmentMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +160,11 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int keyHash() {
|
public int keyHash() {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Object keyRef() {
|
public Object keyRef() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,16 +197,16 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final K key() {
|
K key() {
|
||||||
return ((WeakReference<K>) keyRef).get();
|
return ((WeakReference<K>) keyRef).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
final V value() {
|
V value() {
|
||||||
return dereferenceValue(valueRef);
|
return dereferenceValue(valueRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final V dereferenceValue(Object value) {
|
V dereferenceValue(Object value) {
|
||||||
if (value instanceof WeakKeyReference) {
|
if (value instanceof WeakKeyReference) {
|
||||||
return ((Reference<V>) value).get();
|
return ((Reference<V>) value).get();
|
||||||
}
|
}
|
||||||
@ -214,12 +214,12 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
return (V) value;
|
return (V) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setValue(V value) {
|
void setValue(V value) {
|
||||||
this.valueRef = value;
|
this.valueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> HashEntry<K, V>[] newArray(int i) {
|
static <K, V> HashEntry<K, V>[] newArray(int i) {
|
||||||
return new HashEntry[i];
|
return new HashEntry[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,11 +307,11 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
|
|
||||||
Segment(int initialCapacity, float lf) {
|
Segment(int initialCapacity, float lf) {
|
||||||
loadFactor = lf;
|
loadFactor = lf;
|
||||||
setTable(HashEntry.<K, V> newArray(initialCapacity));
|
setTable(HashEntry.<K, V>newArray(initialCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static final <K, V> Segment<K, V>[] newArray(int i) {
|
static <K, V> Segment<K, V>[] newArray(int i) {
|
||||||
return new Segment[i];
|
return new Segment[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
final void removeStale() {
|
void removeStale() {
|
||||||
WeakKeyReference ref;
|
WeakKeyReference ref;
|
||||||
while ((ref = (WeakKeyReference) refQueue.poll()) != null) {
|
while ((ref = (WeakKeyReference) refQueue.poll()) != null) {
|
||||||
remove(ref.keyRef(), ref.keyHash(), null, true);
|
remove(ref.keyRef(), ref.keyHash(), null, true);
|
||||||
@ -979,8 +979,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
@ -1023,8 +1021,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if the specified key is null
|
* @throws NullPointerException if the specified key is null
|
||||||
*/
|
*/
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
@ -1036,8 +1032,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if any of the arguments are null
|
* @throws NullPointerException if any of the arguments are null
|
||||||
*/
|
*/
|
||||||
public boolean replace(K key, V oldValue, V newValue) {
|
public boolean replace(K key, V oldValue, V newValue) {
|
||||||
@ -1049,8 +1043,6 @@ public final class ConcurrentWeakKeyHashMap<K, V> extends AbstractMap<K, V> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return the previous value associated with the specified key, or
|
* @return the previous value associated with the specified key, or
|
||||||
* <tt>null</tt> if there was no mapping for the key
|
* <tt>null</tt> if there was no mapping for the key
|
||||||
* @throws NullPointerException if the specified key or value is null
|
* @throws NullPointerException if the specified key or value is null
|
||||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
* Conversion utility class to parse a property represented as a string or
|
* Conversion utility class to parse a property represented as a string or
|
||||||
* an object.
|
* an object.
|
||||||
*/
|
*/
|
||||||
public class ConversionUtil {
|
public final class ConversionUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the specified object into an integer.
|
* Converts the specified object into an integer.
|
||||||
@ -88,8 +88,8 @@ public class ConversionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] INTEGERS = {
|
private static final String[] INTEGERS = {
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
"10","11","12","13","14","15",
|
"10", "11", "12", "13", "14", "15",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static String toString(int value) {
|
public static String toString(int value) {
|
||||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* their termination. An {@link Executor} which is not an {@link ExecutorService}
|
* their termination. An {@link Executor} which is not an {@link ExecutorService}
|
||||||
* will be ignored silently.
|
* will be ignored silently.
|
||||||
*/
|
*/
|
||||||
public class ExecutorUtil {
|
public final class ExecutorUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if and only if the specified {@code executor}
|
* Returns {@code true} if and only if the specified {@code executor}
|
||||||
|
@ -59,7 +59,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final boolean tryAcquire(int acquires) {
|
protected boolean tryAcquire(int acquires) {
|
||||||
if (compareAndSetState(0, 1)) {
|
if (compareAndSetState(0, 1)) {
|
||||||
owner = Thread.currentThread();
|
owner = Thread.currentThread();
|
||||||
return true;
|
return true;
|
||||||
@ -68,7 +68,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final boolean tryRelease(int releases) {
|
protected boolean tryRelease(int releases) {
|
||||||
if (Thread.currentThread() != owner) {
|
if (Thread.currentThread() != owner) {
|
||||||
throw new IllegalMonitorStateException();
|
throw new IllegalMonitorStateException();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public final class NonReentrantLock extends AbstractQueuedSynchronizer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final boolean isHeldExclusively() {
|
protected boolean isHeldExclusively() {
|
||||||
return getState() != 0 && owner == Thread.currentThread();
|
return getState() != 0 && owner == Thread.currentThread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import org.jboss.netty.util.UnsafeDetectUtil;
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class QueueFactory {
|
public final class QueueFactory {
|
||||||
|
|
||||||
private static final boolean useUnsafe = UnsafeDetectUtil.isUnsafeFound(QueueFactory.class.getClassLoader());
|
private static final boolean useUnsafe = UnsafeDetectUtil.isUnsafeFound(QueueFactory.class.getClassLoader());
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user