Remove deprecated methods and classes
This commit is contained in:
parent
c44c5a0453
commit
0a217c328b
|
@ -310,30 +310,12 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
|||
return buf;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelBuffer readBytes(ChannelBufferIndexFinder endIndexFinder) {
|
||||
int endIndex = indexOf(readerIndex, writerIndex, endIndexFinder);
|
||||
if (endIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return readBytes(endIndex - readerIndex);
|
||||
}
|
||||
|
||||
public ChannelBuffer readSlice(int length) {
|
||||
ChannelBuffer slice = slice(readerIndex, length);
|
||||
readerIndex += length;
|
||||
return slice;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelBuffer readSlice(ChannelBufferIndexFinder endIndexFinder) {
|
||||
int endIndex = indexOf(readerIndex, writerIndex, endIndexFinder);
|
||||
if (endIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return readSlice(endIndex - readerIndex);
|
||||
}
|
||||
|
||||
public void readBytes(byte[] dst, int dstIndex, int length) {
|
||||
checkReadableBytes(length);
|
||||
getBytes(readerIndex, dst, dstIndex, length);
|
||||
|
@ -393,17 +375,6 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
|||
readerIndex = newReaderIndex;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int skipBytes(ChannelBufferIndexFinder firstIndexFinder) {
|
||||
int oldReaderIndex = readerIndex;
|
||||
int newReaderIndex = indexOf(oldReaderIndex, writerIndex, firstIndexFinder);
|
||||
if (newReaderIndex < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
readerIndex(newReaderIndex);
|
||||
return newReaderIndex - oldReaderIndex;
|
||||
}
|
||||
|
||||
public void writeByte(int value) {
|
||||
setByte(writerIndex, value);
|
||||
writerIndex++;
|
||||
|
@ -552,37 +523,6 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
|||
toByteBuffer(index, length), charset);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(int index, int length, String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder) {
|
||||
if (terminatorFinder == null) {
|
||||
return toString(index, length, charsetName);
|
||||
}
|
||||
|
||||
int terminatorIndex = indexOf(index, index + length, terminatorFinder);
|
||||
if (terminatorIndex < 0) {
|
||||
return toString(index, length, charsetName);
|
||||
}
|
||||
|
||||
return toString(index, terminatorIndex - index, charsetName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(int index, int length, String charsetName) {
|
||||
return toString(index, length, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder) {
|
||||
return toString(readerIndex, readableBytes(), charsetName, terminatorFinder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(String charsetName) {
|
||||
return toString(Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
public int indexOf(int fromIndex, int toIndex, byte value) {
|
||||
return ChannelBuffers.indexOf(this, fromIndex, toIndex, value);
|
||||
}
|
||||
|
|
|
@ -1088,12 +1088,6 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
ChannelBuffer readBytes(int length);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #readBytes(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
ChannelBuffer readBytes(ChannelBufferIndexFinder indexFinder);
|
||||
|
||||
/**
|
||||
* Returns a new slice of this buffer's sub-region starting at the current
|
||||
* {@code readerIndex} and increases the {@code readerIndex} by the size
|
||||
|
@ -1108,12 +1102,6 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
ChannelBuffer readSlice(int length);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #readSlice(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
ChannelBuffer readSlice(ChannelBufferIndexFinder indexFinder);
|
||||
|
||||
/**
|
||||
* Transfers this buffer's data to the specified destination starting at
|
||||
* the current {@code readerIndex} until the destination becomes
|
||||
|
@ -1235,12 +1223,6 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
void skipBytes(int length);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #skipBytes(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
int skipBytes(ChannelBufferIndexFinder indexFinder);
|
||||
|
||||
/**
|
||||
* Sets the specified byte at the current {@code writerIndex}
|
||||
* and increases the {@code writerIndex} by {@code 1} in this buffer.
|
||||
|
@ -1709,35 +1691,6 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
|
|||
*/
|
||||
String toString(int index, int length, Charset charset);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #toString(Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(String charsetName);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(
|
||||
String charsetName, ChannelBufferIndexFinder terminatorFinder);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and
|
||||
* {@link #toString(int, int, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(int index, int length, String charsetName);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and
|
||||
* {@link #toString(int, int, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String toString(
|
||||
int index, int length, String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder);
|
||||
|
||||
/**
|
||||
* Returns a hash code which was calculated from the content of this
|
||||
* buffer. If there's a byte array which is
|
||||
|
|
|
@ -837,22 +837,6 @@ public final class ChannelBuffers {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #copiedBuffer(CharSequence, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ChannelBuffer copiedBuffer(String string, String charsetName) {
|
||||
return copiedBuffer(string, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #copiedBuffer(ByteOrder, CharSequence, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ChannelBuffer copiedBuffer(ByteOrder endianness, String string, String charsetName) {
|
||||
return copiedBuffer(endianness, string, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a read-only buffer which disallows any modification operations
|
||||
* on the specified {@code buffer}. The new buffer has the same
|
||||
|
|
|
@ -261,12 +261,6 @@ public interface ChannelFuture {
|
|||
*/
|
||||
void removeListener(ChannelFutureListener listener);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #sync()} or {@link #syncUninterruptibly()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
ChannelFuture rethrowIfFailed() throws Exception;
|
||||
|
||||
/**
|
||||
* Waits for this future until it is done, and rethrows the cause of the failure if this future
|
||||
* failed. If the cause of the failure is a checked exception, it is wrapped with a new
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
|
||||
/**
|
||||
* @deprecated Use the {@link Sharable} annotation instead.
|
||||
|
||||
* @apiviz.exclude
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Deprecated
|
||||
public @interface ChannelPipelineCoverage {
|
||||
|
||||
/**
|
||||
* {@code "all"}
|
||||
*/
|
||||
String ALL = "all";
|
||||
|
||||
/**
|
||||
* {@code "one"}
|
||||
*/
|
||||
String ONE = "one";
|
||||
|
||||
/**
|
||||
* The value of this annotation
|
||||
*/
|
||||
String value();
|
||||
}
|
|
@ -170,28 +170,6 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelFuture rethrowIfFailed() throws Exception {
|
||||
if (!isDone()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
Throwable cause = getCause();
|
||||
if (cause == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (cause instanceof Exception) {
|
||||
throw (Exception) cause;
|
||||
}
|
||||
|
||||
if (cause instanceof Error) {
|
||||
throw (Error) cause;
|
||||
}
|
||||
|
||||
throw new RuntimeException(cause);
|
||||
}
|
||||
|
||||
public ChannelFuture sync() throws InterruptedException {
|
||||
await();
|
||||
rethrowIfFailed0();
|
||||
|
|
|
@ -46,19 +46,6 @@ public class FailedChannelFuture extends CompleteChannelFuture {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelFuture rethrowIfFailed() throws Exception {
|
||||
if (cause instanceof Exception) {
|
||||
throw (Exception) cause;
|
||||
}
|
||||
|
||||
if (cause instanceof Error) {
|
||||
throw (Error) cause;
|
||||
}
|
||||
|
||||
throw new RuntimeException(cause);
|
||||
}
|
||||
|
||||
public ChannelFuture sync() throws InterruptedException {
|
||||
rethrow();
|
||||
return this;
|
||||
|
|
|
@ -1,539 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.ConversionUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link ChannelPipeline} that might perform better at the cost of
|
||||
* disabled dynamic insertion and removal of {@link ChannelHandler}s.
|
||||
* An attempt to insert, remove, or replace a handler in this pipeline will
|
||||
* trigger an {@link UnsupportedOperationException}.
|
||||
*
|
||||
* @deprecated use {@link DefaultChannelPipeline}
|
||||
*/
|
||||
@Deprecated
|
||||
public class StaticChannelPipeline implements ChannelPipeline {
|
||||
|
||||
// FIXME Code duplication with DefaultChannelPipeline
|
||||
static final InternalLogger logger = InternalLoggerFactory.getInstance(StaticChannelPipeline.class);
|
||||
|
||||
private volatile Channel channel;
|
||||
private volatile ChannelSink sink;
|
||||
private final StaticChannelHandlerContext[] contexts;
|
||||
private final int lastIndex;
|
||||
private final Map<String, StaticChannelHandlerContext> name2ctx =
|
||||
new HashMap<String, StaticChannelHandlerContext>(4);
|
||||
|
||||
/**
|
||||
* Creates a new pipeline from the specified handlers.
|
||||
* The names of the specified handlers are generated automatically;
|
||||
* the first handler's name is {@code "0"}, the second handler's name is
|
||||
* {@code "1"}, the third handler's name is {@code "2"}, and so on.
|
||||
*/
|
||||
public StaticChannelPipeline(ChannelHandler... handlers) {
|
||||
if (handlers == null) {
|
||||
throw new NullPointerException("handlers");
|
||||
}
|
||||
if (handlers.length == 0) {
|
||||
throw new IllegalArgumentException("no handlers specified");
|
||||
}
|
||||
|
||||
// Get the number of first non-null handlers.
|
||||
StaticChannelHandlerContext[] contexts =
|
||||
new StaticChannelHandlerContext[handlers.length];
|
||||
int nContexts;
|
||||
for (nContexts = 0; nContexts < contexts.length; nContexts ++) {
|
||||
ChannelHandler h = handlers[nContexts];
|
||||
if (h == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nContexts == contexts.length) {
|
||||
this.contexts = contexts;
|
||||
lastIndex = contexts.length - 1;
|
||||
} else {
|
||||
this.contexts = contexts =
|
||||
new StaticChannelHandlerContext[nContexts];
|
||||
lastIndex = nContexts - 1;
|
||||
}
|
||||
|
||||
// Initialize the first non-null handlers only.
|
||||
for (int i = 0; i < nContexts; i ++) {
|
||||
ChannelHandler h = handlers[i];
|
||||
String name = ConversionUtil.toString(i);
|
||||
StaticChannelHandlerContext ctx =
|
||||
new StaticChannelHandlerContext(i, name, h);
|
||||
contexts[i] = ctx;
|
||||
name2ctx.put(name, ctx);
|
||||
}
|
||||
|
||||
for (ChannelHandlerContext ctx: contexts) {
|
||||
callBeforeAdd(ctx);
|
||||
callAfterAdd(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public ChannelFuture execute(Runnable task) {
|
||||
return getSink().execute(this, task);
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public ChannelSink getSink() {
|
||||
ChannelSink sink = this.sink;
|
||||
if (sink == null) {
|
||||
return DefaultChannelPipeline.discardingSink;
|
||||
}
|
||||
return sink;
|
||||
}
|
||||
|
||||
public void attach(Channel channel, ChannelSink sink) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
if (sink == null) {
|
||||
throw new NullPointerException("sink");
|
||||
}
|
||||
if (this.channel != null || this.sink != null) {
|
||||
throw new IllegalStateException("attached already");
|
||||
}
|
||||
this.channel = channel;
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
public boolean isAttached() {
|
||||
return sink != null;
|
||||
}
|
||||
|
||||
public void addFirst(String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addLast(String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addBefore(String baseName, String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addAfter(String baseName, String name, ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void remove(ChannelHandler handler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ChannelHandler remove(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public <T extends ChannelHandler> T remove(Class<T> handlerType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ChannelHandler removeFirst() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ChannelHandler removeLast() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public <T extends ChannelHandler> T replace(
|
||||
Class<T> oldHandlerType, String newName, ChannelHandler newHandler) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static void callBeforeAdd(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LifeCycleAwareChannelHandler h =
|
||||
(LifeCycleAwareChannelHandler) ctx.getHandler();
|
||||
|
||||
try {
|
||||
h.beforeAdd(ctx);
|
||||
} catch (Throwable t) {
|
||||
throw new ChannelHandlerLifeCycleException(
|
||||
h.getClass().getName() +
|
||||
".beforeAdd() has thrown an exception; not adding.", t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void callAfterAdd(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LifeCycleAwareChannelHandler h =
|
||||
(LifeCycleAwareChannelHandler) ctx.getHandler();
|
||||
|
||||
try {
|
||||
h.afterAdd(ctx);
|
||||
} catch (Throwable t) {
|
||||
boolean removed = false;
|
||||
try {
|
||||
callBeforeRemove(ctx);
|
||||
callAfterRemove(ctx);
|
||||
removed = true;
|
||||
} catch (Throwable t2) {
|
||||
logger.warn("Failed to remove a handler: " + ctx.getName(), t2);
|
||||
}
|
||||
|
||||
if (removed) {
|
||||
throw new ChannelHandlerLifeCycleException(
|
||||
h.getClass().getName() +
|
||||
".afterAdd() has thrown an exception; removed.", t);
|
||||
} else {
|
||||
throw new ChannelHandlerLifeCycleException(
|
||||
h.getClass().getName() +
|
||||
".afterAdd() has thrown an exception; also failed to remove.", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void callBeforeRemove(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LifeCycleAwareChannelHandler h =
|
||||
(LifeCycleAwareChannelHandler) ctx.getHandler();
|
||||
|
||||
try {
|
||||
h.beforeRemove(ctx);
|
||||
} catch (Throwable t) {
|
||||
throw new ChannelHandlerLifeCycleException(
|
||||
h.getClass().getName() +
|
||||
".beforeRemove() has thrown an exception; not removing.", t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void callAfterRemove(ChannelHandlerContext ctx) {
|
||||
if (!(ctx.getHandler() instanceof LifeCycleAwareChannelHandler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LifeCycleAwareChannelHandler h =
|
||||
(LifeCycleAwareChannelHandler) ctx.getHandler();
|
||||
|
||||
try {
|
||||
h.afterRemove(ctx);
|
||||
} catch (Throwable t) {
|
||||
throw new ChannelHandlerLifeCycleException(
|
||||
h.getClass().getName() +
|
||||
".afterRemove() has thrown an exception.", t);
|
||||
}
|
||||
}
|
||||
|
||||
public ChannelHandler getFirst() {
|
||||
return contexts[0].getHandler();
|
||||
}
|
||||
|
||||
public ChannelHandler getLast() {
|
||||
return contexts[contexts.length - 1].getHandler();
|
||||
}
|
||||
|
||||
public ChannelHandler get(String name) {
|
||||
StaticChannelHandlerContext ctx = name2ctx.get(name);
|
||||
if (ctx == null) {
|
||||
return null;
|
||||
} else {
|
||||
return ctx.getHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends ChannelHandler> T get(Class<T> handlerType) {
|
||||
ChannelHandlerContext ctx = getContext(handlerType);
|
||||
if (ctx == null) {
|
||||
return null;
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
T handler = (T) ctx.getHandler();
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
|
||||
public ChannelHandlerContext getContext(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
return name2ctx.get(name);
|
||||
}
|
||||
|
||||
public ChannelHandlerContext getContext(ChannelHandler handler) {
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
}
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
if (ctx.getHandler() == handler) {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ChannelHandlerContext getContext(Class<? extends ChannelHandler> handlerType) {
|
||||
if (handlerType == null) {
|
||||
throw new NullPointerException("handlerType");
|
||||
}
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
if (handlerType.isAssignableFrom(ctx.getHandler().getClass())) {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getNames() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
list.add(ctx.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
map.put(ctx.getName(), ctx.getHandler());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link String} representation of this pipeline.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(getClass().getSimpleName());
|
||||
buf.append('{');
|
||||
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
buf.append('(');
|
||||
buf.append(ctx.getName());
|
||||
buf.append(" = ");
|
||||
buf.append(ctx.getHandler().getClass().getName());
|
||||
buf.append(')');
|
||||
buf.append(", ");
|
||||
}
|
||||
buf.replace(buf.length() - 2, buf.length(), "}");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public void sendUpstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext head = getActualUpstreamContext(0);
|
||||
if (head == null) {
|
||||
logger.warn(
|
||||
"The pipeline contains no upstream handlers; discarding: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
sendUpstream(head, e);
|
||||
}
|
||||
|
||||
void sendUpstream(StaticChannelHandlerContext ctx, ChannelEvent e) {
|
||||
try {
|
||||
((ChannelUpstreamHandler) ctx.getHandler()).handleUpstream(ctx, e);
|
||||
} catch (Throwable t) {
|
||||
notifyHandlerException(e, t);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendDownstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext tail = getActualDownstreamContext(lastIndex);
|
||||
if (tail == null) {
|
||||
try {
|
||||
getSink().eventSunk(this, e);
|
||||
return;
|
||||
} catch (Throwable t) {
|
||||
notifyHandlerException(e, t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sendDownstream(tail, e);
|
||||
}
|
||||
|
||||
void sendDownstream(StaticChannelHandlerContext ctx, ChannelEvent e) {
|
||||
if (e instanceof UpstreamMessageEvent) {
|
||||
throw new IllegalArgumentException("cannot send an upstream event to downstream");
|
||||
}
|
||||
|
||||
try {
|
||||
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
|
||||
} catch (Throwable t) {
|
||||
// Unlike an upstream event, a downstream event usually has an
|
||||
// incomplete future which is supposed to be updated by ChannelSink.
|
||||
// However, if an exception is raised before the event reaches at
|
||||
// ChannelSink, the future is not going to be updated, so we update
|
||||
// here.
|
||||
e.getFuture().setFailure(t);
|
||||
notifyHandlerException(e, t);
|
||||
}
|
||||
}
|
||||
|
||||
private StaticChannelHandlerContext getActualUpstreamContext(int index) {
|
||||
for (int i = index; i < contexts.length; i ++) {
|
||||
StaticChannelHandlerContext ctx = contexts[i];
|
||||
if (ctx.canHandleUpstream()) {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private StaticChannelHandlerContext getActualDownstreamContext(int index) {
|
||||
for (int i = index; i >= 0; i --) {
|
||||
StaticChannelHandlerContext ctx = contexts[i];
|
||||
if (ctx.canHandleDownstream()) {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void notifyHandlerException(ChannelEvent e, Throwable t) {
|
||||
if (e instanceof ExceptionEvent) {
|
||||
logger.warn(
|
||||
"An exception was thrown by a user handler " +
|
||||
"while handling an exception event (" + e + ')', t);
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelPipelineException pe;
|
||||
if (t instanceof ChannelPipelineException) {
|
||||
pe = (ChannelPipelineException) t;
|
||||
} else {
|
||||
pe = new ChannelPipelineException(t);
|
||||
}
|
||||
|
||||
try {
|
||||
sink.exceptionCaught(this, e, pe);
|
||||
} catch (Exception e1) {
|
||||
logger.warn("An exception was thrown by an exception handler.", e1);
|
||||
}
|
||||
}
|
||||
|
||||
private final class StaticChannelHandlerContext implements ChannelHandlerContext {
|
||||
private final int index;
|
||||
private final String name;
|
||||
private final ChannelHandler handler;
|
||||
private final boolean canHandleUpstream;
|
||||
private final boolean canHandleDownstream;
|
||||
private volatile Object attachment;
|
||||
|
||||
StaticChannelHandlerContext(
|
||||
int index, String name, ChannelHandler handler) {
|
||||
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
}
|
||||
canHandleUpstream = handler instanceof ChannelUpstreamHandler;
|
||||
canHandleDownstream = handler instanceof ChannelDownstreamHandler;
|
||||
|
||||
if (!canHandleUpstream && !canHandleDownstream) {
|
||||
throw new IllegalArgumentException(
|
||||
"handler must be either " +
|
||||
ChannelUpstreamHandler.class.getName() + " or " +
|
||||
ChannelDownstreamHandler.class.getName() + '.');
|
||||
}
|
||||
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
return getPipeline().getChannel();
|
||||
}
|
||||
|
||||
public ChannelPipeline getPipeline() {
|
||||
return StaticChannelPipeline.this;
|
||||
}
|
||||
|
||||
public boolean canHandleDownstream() {
|
||||
return canHandleDownstream;
|
||||
}
|
||||
|
||||
public boolean canHandleUpstream() {
|
||||
return canHandleUpstream;
|
||||
}
|
||||
|
||||
public ChannelHandler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object getAttachment() {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
public void setAttachment(Object attachment) {
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
public void sendDownstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext prev = getActualDownstreamContext(index - 1);
|
||||
if (prev == null) {
|
||||
try {
|
||||
getSink().eventSunk(StaticChannelPipeline.this, e);
|
||||
} catch (Throwable t) {
|
||||
notifyHandlerException(e, t);
|
||||
}
|
||||
} else {
|
||||
StaticChannelPipeline.this.sendDownstream(prev, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendUpstream(ChannelEvent e) {
|
||||
StaticChannelHandlerContext next = getActualUpstreamContext(index + 1);
|
||||
if (next != null) {
|
||||
StaticChannelPipeline.this.sendUpstream(next, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,11 +39,6 @@ public class SucceededChannelFuture extends CompleteChannelFuture {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelFuture rethrowIfFailed() throws Exception {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChannelFuture sync() throws InterruptedException {
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -113,34 +113,13 @@ public abstract class AbstractNioWorkerPool<E extends AbstractNioWorker>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only here for backward compability and will be removed in later releases. Please use
|
||||
* {@link #newWorker(Executor)}
|
||||
*
|
||||
*
|
||||
* @param executor the {@link Executor} to use
|
||||
* @return worker the new {@link Worker}
|
||||
* @deprecated use {@link #newWorker(Executor)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected E createWorker(Executor executor) {
|
||||
throw new IllegalStateException("This will be removed. Override this and the newWorker(..) method!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Worker} which uses the given {@link Executor} to service IO.
|
||||
*
|
||||
* This method will be made abstract in further releases (once {@link #createWorker(Executor)}
|
||||
* was removed).
|
||||
*
|
||||
*
|
||||
* @param executor the {@link Executor} to use
|
||||
* @return worker the new {@link Worker}
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
protected E newWorker(Executor executor) {
|
||||
return createWorker(executor);
|
||||
}
|
||||
protected abstract E newWorker(Executor executor);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E nextWorker() {
|
||||
|
|
|
@ -30,8 +30,7 @@ public class NioDatagramWorkerPool extends AbstractNioWorkerPool<NioDatagramWork
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
protected NioDatagramWorker createWorker(Executor executor) {
|
||||
protected NioDatagramWorker newWorker(Executor executor) {
|
||||
return new NioDatagramWorker(executor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ public class NioWorkerPool extends AbstractNioWorkerPool<NioWorker> {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
protected NioWorker createWorker(Executor executor) {
|
||||
protected NioWorker newWorker(Executor executor) {
|
||||
return new NioWorker(executor, determiner);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.jboss.netty.handler.codec.http.multipart.HttpDataFactory;
|
|||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData;
|
||||
import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType;
|
||||
|
@ -150,13 +149,6 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
|
|||
writeResponse(e.getChannel());
|
||||
Channels.close(e.getChannel());
|
||||
return;
|
||||
} catch (IncompatibleDataDecoderException e1) {
|
||||
// GET Method: should not try to create a HttpPostRequestDecoder
|
||||
// So OK but stop here
|
||||
responseContent.append(e1.getMessage());
|
||||
responseContent.append("\r\n\r\nEND OF GET CONTENT\r\n");
|
||||
writeResponse(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
responseContent.append("Is Chunked: " + request.isChunked() + "\r\n");
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link HttpHeaderDateFormat}
|
||||
*/
|
||||
@Deprecated
|
||||
final class CookieDateFormat extends SimpleDateFormat {
|
||||
|
||||
private static final long serialVersionUID = 1789486337887402640L;
|
||||
|
||||
CookieDateFormat() {
|
||||
super("E, d-MMM-y HH:mm:ss z", Locale.ENGLISH);
|
||||
setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
}
|
|
@ -49,13 +49,6 @@ public class CookieDecoder {
|
|||
public CookieDecoder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #CookieDecoder()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public CookieDecoder(@SuppressWarnings("unused") boolean lenient) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the specified HTTP header value into {@link Cookie}s.
|
||||
*
|
||||
|
|
|
@ -34,56 +34,6 @@ public class DefaultHttpChunkTrailer implements HttpChunkTrailer {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addHeader(final String name, final Object value) {
|
||||
trailingHeaders.add(name, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(final String name, final Object value) {
|
||||
trailingHeaders.set(name, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(final String name, final Iterable<?> values) {
|
||||
trailingHeaders.set(name, values);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void removeHeader(final String name) {
|
||||
trailingHeaders.remove(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void clearHeaders() {
|
||||
trailingHeaders.clear();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getHeader(final String name) {
|
||||
return trailingHeaders.get(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getHeaders(final String name) {
|
||||
return trailingHeaders.getAll(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Map.Entry<String, String>> getHeaders() {
|
||||
return trailingHeaders.entries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean containsHeader(final String name) {
|
||||
return trailingHeaders.contains(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Set<String> getHeaderNames() {
|
||||
return trailingHeaders.names();
|
||||
}
|
||||
|
||||
public ChannelBuffer getContent() {
|
||||
return ChannelBuffers.EMPTY_BUFFER;
|
||||
}
|
||||
|
|
|
@ -44,26 +44,6 @@ public class DefaultHttpMessage implements HttpMessage {
|
|||
return headers;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addHeader(final String name, final Object value) {
|
||||
headers.add(name, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(final String name, final Object value) {
|
||||
headers.set(name, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(final String name, final Iterable<?> values) {
|
||||
headers.set(name, values);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void removeHeader(final String name) {
|
||||
headers.remove(name);
|
||||
}
|
||||
|
||||
public boolean isChunked() {
|
||||
if (chunked) {
|
||||
return true;
|
||||
|
@ -79,11 +59,6 @@ public class DefaultHttpMessage implements HttpMessage {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void clearHeaders() {
|
||||
headers.clear();
|
||||
}
|
||||
|
||||
public void setContent(ChannelBuffer content) {
|
||||
if (content == null) {
|
||||
content = ChannelBuffers.EMPTY_BUFFER;
|
||||
|
@ -95,31 +70,6 @@ public class DefaultHttpMessage implements HttpMessage {
|
|||
this.content = content;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getHeader(final String name) {
|
||||
return headers.get(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getHeaders(final String name) {
|
||||
return headers.getAll(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Map.Entry<String, String>> getHeaders() {
|
||||
return headers.entries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean containsHeader(final String name) {
|
||||
return headers.contains(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Set<String> getHeaderNames() {
|
||||
return headers.names();
|
||||
}
|
||||
|
||||
public HttpVersion getProtocolVersion() {
|
||||
return version;
|
||||
}
|
||||
|
|
|
@ -51,56 +51,6 @@ public interface HttpChunk {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addHeader(String name, Object value) {
|
||||
throw new IllegalStateException("read-only");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void clearHeaders() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean containsHeader(String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getHeader(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Set<String> getHeaderNames() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getHeaders(String name) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Map.Entry<String, String>> getHeaders() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void removeHeader(String name) {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(String name, Object value) {
|
||||
throw new IllegalStateException("read-only");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(String name, Iterable<?> values) {
|
||||
throw new IllegalStateException("read-only");
|
||||
}
|
||||
|
||||
public HttpHeaders trailingHeaders() {
|
||||
return HttpHeaders.EMPTY_HEADERS;
|
||||
}
|
||||
|
|
|
@ -29,66 +29,6 @@ public interface HttpChunkTrailer extends HttpChunk {
|
|||
*/
|
||||
boolean isLast();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<String> getHeaders(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<Map.Entry<String, String>> getHeaders();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean containsHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Set<String> getHeaderNames();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void addHeader(String name, Object value);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeader(String name, Object value);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeader(String name, Iterable<?> values);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void removeHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpChunkTrailer#trailingHeaders()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void clearHeaders();
|
||||
|
||||
/**
|
||||
* Returns the trialing headers of this trailer.
|
||||
*/
|
||||
|
|
|
@ -32,36 +32,6 @@ import org.jboss.netty.buffer.ChannelBuffers;
|
|||
*/
|
||||
public interface HttpMessage {
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<String> getHeaders(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<Map.Entry<String, String>> getHeaders();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean containsHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns the {@link Set} of all header names that this message contains.
|
||||
*/
|
||||
@Deprecated
|
||||
Set<String> getHeaderNames();
|
||||
|
||||
/**
|
||||
* Returns the protocol version of this message.
|
||||
*/
|
||||
|
@ -90,36 +60,6 @@ public interface HttpMessage {
|
|||
*/
|
||||
void setContent(ChannelBuffer content);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void addHeader(String name, Object value);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeader(String name, Object value);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeader(String name, Iterable<?> values);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void removeHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link HttpMessage#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void clearHeaders();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if this message does not have any
|
||||
* content but the {@link HttpChunk}s, which is generated by
|
||||
|
|
|
@ -68,14 +68,6 @@ public class HttpVersion implements Comparable<HttpVersion> {
|
|||
private final String text;
|
||||
private final boolean keepAliveDefault;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #HttpVersion(String, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpVersion(String text) {
|
||||
this(text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HTTP version with the specified version string. You will
|
||||
* not need to create a new instance unless you are implementing a protocol
|
||||
|
@ -109,15 +101,6 @@ public class HttpVersion implements Comparable<HttpVersion> {
|
|||
this.keepAliveDefault = keepAliveDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #HttpVersion(String, int, int, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpVersion(
|
||||
String protocolName, int majorVersion, int minorVersion) {
|
||||
this(protocolName, majorVersion, minorVersion, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HTTP version with the specified protocol name and version
|
||||
* numbers. You will not need to create a new instance unless you are
|
||||
|
|
|
@ -123,14 +123,6 @@ public class QueryStringDecoder {
|
|||
this.hasPath = hasPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #QueryStringDecoder(String, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public QueryStringDecoder(String uri, String charset) {
|
||||
this(uri, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new decoder that decodes the specified URI. The decoder will
|
||||
* assume that the query string is encoded in UTF-8.
|
||||
|
@ -176,14 +168,6 @@ public class QueryStringDecoder {
|
|||
this.maxParams = maxParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #QueryStringDecoder(URI, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public QueryStringDecoder(URI uri, String charset) {
|
||||
this(uri, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the decoded path string of the URI.
|
||||
*/
|
||||
|
|
|
@ -68,14 +68,6 @@ public class QueryStringEncoder {
|
|||
this.charset = charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #QueryStringEncoder(String, Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public QueryStringEncoder(String uri, String charset) {
|
||||
this(uri, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter with the specified name and value to this encoder.
|
||||
*/
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadOp
|
|||
import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.TransferEncodingMechanism;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.MultiPartStatus;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import org.jboss.netty.util.internal.CaseIgnoringComparator;
|
||||
|
@ -42,7 +41,6 @@ import java.util.TreeMap;
|
|||
/**
|
||||
* This decoder will decode Body and can handle POST BODY in multipart form.
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "RedundantThrowsDeclaration" })
|
||||
public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
||||
/**
|
||||
* Factory used to create InterfaceHttpData
|
||||
|
@ -120,11 +118,9 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
|||
*
|
||||
* @param request the request to decode
|
||||
* @throws NullPointerException for request
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostMultipartRequestDecoder(HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
public HttpPostMultipartRequestDecoder(HttpRequest request) throws ErrorDataDecoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
@ -134,11 +130,10 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
|||
* @param factory the factory used to create InterfaceHttpData
|
||||
* @param request the request to decode
|
||||
* @throws NullPointerException for request or factory
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
throws ErrorDataDecoderException {
|
||||
this(factory, request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
|
@ -148,12 +143,10 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
|||
* @param request the request to decode
|
||||
* @param charset the charset to use as default
|
||||
* @throws NullPointerException for request or charset or factory
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request,
|
||||
Charset charset) throws ErrorDataDecoderException,
|
||||
IncompatibleDataDecoderException {
|
||||
Charset charset) throws ErrorDataDecoderException {
|
||||
if (factory == null) {
|
||||
throw new NullPointerException("factory");
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
|||
/**
|
||||
* This decoder will decode Body and can handle POST BODY (both multipart and standard).
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
||||
/**
|
||||
* Does this request is a Multipart request
|
||||
|
@ -38,11 +37,9 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
|||
*
|
||||
* @param request the request to decode
|
||||
* @throws NullPointerException for request
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostRequestDecoder(HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
public HttpPostRequestDecoder(HttpRequest request) throws ErrorDataDecoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
@ -52,11 +49,10 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
|||
* @param factory the factory used to create InterfaceHttpData
|
||||
* @param request the request to decode
|
||||
* @throws NullPointerException for request or factory
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
throws ErrorDataDecoderException {
|
||||
this(factory, request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
|
@ -66,12 +62,10 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
|||
* @param request the request to decode
|
||||
* @param charset the charset to use as default
|
||||
* @throws NullPointerException for request or charset or factory
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request,
|
||||
Charset charset) throws ErrorDataDecoderException,
|
||||
IncompatibleDataDecoderException {
|
||||
Charset charset) throws ErrorDataDecoderException {
|
||||
if (factory == null) {
|
||||
throw new NullPointerException("factory");
|
||||
}
|
||||
|
@ -383,27 +377,4 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
|||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception when an unappropriated method was called on a request
|
||||
*/
|
||||
@Deprecated
|
||||
public static class IncompatibleDataDecoderException extends Exception {
|
||||
private static final long serialVersionUID = -953268047926250267L;
|
||||
|
||||
public IncompatibleDataDecoderException() {
|
||||
}
|
||||
|
||||
public IncompatibleDataDecoderException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public IncompatibleDataDecoderException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public IncompatibleDataDecoderException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadNo
|
|||
import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadOptimize;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.MultiPartStatus;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import org.jboss.netty.util.internal.CaseIgnoringComparator;
|
||||
|
@ -41,7 +40,6 @@ import java.util.TreeMap;
|
|||
/**
|
||||
* This decoder will decode Body and can handle standard (non multipart) POST BODY.
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "RedundantThrowsDeclaration" })
|
||||
public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestDecoder {
|
||||
/**
|
||||
* Factory used to create InterfaceHttpData
|
||||
|
@ -98,11 +96,9 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
|||
*
|
||||
* @param request the request to decode
|
||||
* @throws NullPointerException for request
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostStandardRequestDecoder(HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
public HttpPostStandardRequestDecoder(HttpRequest request) throws ErrorDataDecoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
@ -112,11 +108,10 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
|||
* @param factory the factory used to create InterfaceHttpData
|
||||
* @param request the request to decode
|
||||
* @throws NullPointerException for request or factory
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
throws ErrorDataDecoderException {
|
||||
this(factory, request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
|
@ -126,12 +121,10 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
|||
* @param request the request to decode
|
||||
* @param charset the charset to use as default
|
||||
* @throws NullPointerException for request or charset or factory
|
||||
* @throws IncompatibleDataDecoderException if the request has no body to decode
|
||||
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
|
||||
*/
|
||||
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request,
|
||||
Charset charset) throws ErrorDataDecoderException,
|
||||
IncompatibleDataDecoderException {
|
||||
Charset charset) throws ErrorDataDecoderException {
|
||||
if (factory == null) {
|
||||
throw new NullPointerException("factory");
|
||||
}
|
||||
|
|
|
@ -32,11 +32,6 @@ public class InternalAttribute implements InterfaceHttpData {
|
|||
protected final List<String> value = new ArrayList<String>();
|
||||
private final Charset charset;
|
||||
|
||||
@Deprecated
|
||||
public InternalAttribute() {
|
||||
this(CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
public InternalAttribute(Charset charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
@ -45,11 +40,6 @@ public class InternalAttribute implements InterfaceHttpData {
|
|||
return HttpDataType.InternalAttribute;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void addValue(String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.websocket;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
/**
|
||||
* @deprecated Use <tt>org.jboss.netty.handler.codec.http.websocketx</tt> instead.
|
||||
*
|
||||
* The default {@link WebSocketFrame} implementation.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultWebSocketFrame implements WebSocketFrame {
|
||||
|
||||
private int type;
|
||||
private ChannelBuffer binaryData;
|
||||
|
||||
/**
|
||||
* Creates a new empty text frame.
|
||||
*/
|
||||
public DefaultWebSocketFrame() {
|
||||
this(0, ChannelBuffers.EMPTY_BUFFER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new text frame from with the specified string.
|
||||
*/
|
||||
public DefaultWebSocketFrame(String textData) {
|
||||
this(0, ChannelBuffers.copiedBuffer(textData, CharsetUtil.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new frame with the specified frame type and the specified data.
|
||||
*
|
||||
* @param type
|
||||
* the type of the frame. {@code 0} is the only allowed type currently.
|
||||
* @param binaryData
|
||||
* the content of the frame. If <tt>(type & 0x80 == 0)</tt>,
|
||||
* it must be encoded in UTF-8.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if If <tt>(type & 0x80 == 0)</tt> and the data is not encoded
|
||||
* in UTF-8
|
||||
*/
|
||||
public DefaultWebSocketFrame(int type, ChannelBuffer binaryData) {
|
||||
setData(type, binaryData);
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isText() {
|
||||
return (getType() & 0x80) == 0;
|
||||
}
|
||||
|
||||
public boolean isBinary() {
|
||||
return !isText();
|
||||
}
|
||||
|
||||
public ChannelBuffer getBinaryData() {
|
||||
return binaryData;
|
||||
}
|
||||
|
||||
public String getTextData() {
|
||||
return getBinaryData().toString(CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
public void setData(int type, ChannelBuffer binaryData) {
|
||||
if (binaryData == null) {
|
||||
throw new NullPointerException("binaryData");
|
||||
}
|
||||
|
||||
if ((type & 0x80) == 0) {
|
||||
// If text, data should not contain 0xFF.
|
||||
int delimPos = binaryData.indexOf(
|
||||
binaryData.readerIndex(), binaryData.writerIndex(), (byte) 0xFF);
|
||||
if (delimPos >= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"a text frame should not contain 0xFF.");
|
||||
}
|
||||
}
|
||||
|
||||
this.type = type & 0xFF;
|
||||
this.binaryData = binaryData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() +
|
||||
"(type: " + getType() + ", " + "data: " + getBinaryData() + ')';
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.websocket;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
|
||||
/**
|
||||
* @deprecated Use <tt>org.jboss.netty.handler.codec.http.websocketx</tt> instead.
|
||||
*
|
||||
* A Web Socket frame that represents either text or binary data.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface WebSocketFrame {
|
||||
|
||||
/**
|
||||
* Closing handshake message (<tt>0xFF, 0x00</tt>)
|
||||
*/
|
||||
WebSocketFrame CLOSING_HANDSHAKE = new DefaultWebSocketFrame(0xFF, ChannelBuffers.EMPTY_BUFFER);
|
||||
|
||||
/**
|
||||
* Returns the type of this frame.
|
||||
* <tt>0x00-0x7F</tt> means a text frame encoded in UTF-8, and
|
||||
* <tt>0x80-0xFF</tt> means a binary frame. Currently, {@code 0} is the
|
||||
* only allowed type according to the specification.
|
||||
*/
|
||||
int getType();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if the content of this frame is a string
|
||||
* encoded in UTF-8.
|
||||
*/
|
||||
boolean isText();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if the content of this frame is an
|
||||
* arbitrary binary data.
|
||||
*/
|
||||
boolean isBinary();
|
||||
|
||||
/**
|
||||
* Returns the content of this frame as-is, with no UTF-8 decoding.
|
||||
*/
|
||||
ChannelBuffer getBinaryData();
|
||||
|
||||
/**
|
||||
* Converts the content of this frame into a UTF-8 string and returns the
|
||||
* converted string.
|
||||
*/
|
||||
String getTextData();
|
||||
|
||||
/**
|
||||
* Sets the type and the content of this frame.
|
||||
*
|
||||
* @param type
|
||||
* the type of the frame. {@code 0} is the only allowed type currently.
|
||||
* @param binaryData
|
||||
* the content of the frame. If <tt>(type & 0x80 == 0)</tt>,
|
||||
* it must be encoded in UTF-8.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if If <tt>(type & 0x80 == 0)</tt> and the data is not encoded
|
||||
* in UTF-8
|
||||
*/
|
||||
void setData(int type, ChannelBuffer binaryData);
|
||||
|
||||
/**
|
||||
* Returns the string representation of this frame. Please note that this
|
||||
* method is not identical to {@link #getTextData()}.
|
||||
*/
|
||||
String toString();
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.websocket;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
|
||||
import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
||||
import org.jboss.netty.handler.codec.replay.VoidEnum;
|
||||
|
||||
/**
|
||||
* @deprecated Use <tt>org.jboss.netty.handler.codec.http.websocketx</tt> instead.
|
||||
*
|
||||
* Decodes {@link ChannelBuffer}s into {@link WebSocketFrame}s.
|
||||
* <p>
|
||||
* For the detailed instruction on adding add Web Socket support to your HTTP
|
||||
* server, take a look into the <tt>WebSocketServer</tt> example located in the
|
||||
* {@code org.jboss.netty.example.http.websocket} package.
|
||||
* @apiviz.landmark
|
||||
* @apiviz.uses org.jboss.netty.handler.codec.http.websocket.WebSocketFrame
|
||||
*/
|
||||
@Deprecated
|
||||
public class WebSocketFrameDecoder extends ReplayingDecoder<VoidEnum> {
|
||||
|
||||
public static final int DEFAULT_MAX_FRAME_SIZE = 16384;
|
||||
|
||||
private final int maxFrameSize;
|
||||
private boolean receivedClosingHandshake;
|
||||
|
||||
public WebSocketFrameDecoder() {
|
||||
this(DEFAULT_MAX_FRAME_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client
|
||||
* sends a frame size larger than {@code maxFrameSize}, the channel will be closed.
|
||||
*
|
||||
* @param maxFrameSize the maximum frame size to decode
|
||||
*/
|
||||
public WebSocketFrameDecoder(int maxFrameSize) {
|
||||
this.maxFrameSize = maxFrameSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object decode(ChannelHandlerContext ctx, Channel channel,
|
||||
ChannelBuffer buffer, VoidEnum state) throws Exception {
|
||||
|
||||
// Discard all data received if closing handshake was received before.
|
||||
if (receivedClosingHandshake) {
|
||||
buffer.skipBytes(actualReadableBytes());
|
||||
return null;
|
||||
}
|
||||
|
||||
// Decode a frame otherwise.
|
||||
byte type = buffer.readByte();
|
||||
if ((type & 0x80) == 0x80) {
|
||||
// If the MSB on type is set, decode the frame length
|
||||
return decodeBinaryFrame(type, buffer);
|
||||
} else {
|
||||
// Decode a 0xff terminated UTF-8 string
|
||||
return decodeTextFrame(type, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
private WebSocketFrame decodeBinaryFrame(int type, ChannelBuffer buffer) throws TooLongFrameException {
|
||||
long frameSize = 0;
|
||||
int lengthFieldSize = 0;
|
||||
byte b;
|
||||
do {
|
||||
b = buffer.readByte();
|
||||
frameSize <<= 7;
|
||||
frameSize |= b & 0x7f;
|
||||
if (frameSize > maxFrameSize) {
|
||||
throw new TooLongFrameException();
|
||||
}
|
||||
lengthFieldSize ++;
|
||||
if (lengthFieldSize > 8) {
|
||||
// Perhaps a malicious peer?
|
||||
throw new TooLongFrameException();
|
||||
}
|
||||
} while ((b & 0x80) == 0x80);
|
||||
|
||||
if (type == 0xFF && frameSize == 0) {
|
||||
receivedClosingHandshake = true;
|
||||
}
|
||||
|
||||
return new DefaultWebSocketFrame(
|
||||
type, buffer.readBytes((int) frameSize));
|
||||
}
|
||||
|
||||
private WebSocketFrame decodeTextFrame(int type, ChannelBuffer buffer) throws TooLongFrameException {
|
||||
int ridx = buffer.readerIndex();
|
||||
int rbytes = actualReadableBytes();
|
||||
int delimPos = buffer.indexOf(ridx, ridx + rbytes, (byte) 0xFF);
|
||||
if (delimPos == -1) {
|
||||
// Frame delimiter (0xFF) not found
|
||||
if (rbytes > maxFrameSize) {
|
||||
// Frame length exceeded the maximum
|
||||
throw new TooLongFrameException();
|
||||
} else {
|
||||
// Wait until more data is received
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
int frameSize = delimPos - ridx;
|
||||
if (frameSize > maxFrameSize) {
|
||||
throw new TooLongFrameException();
|
||||
}
|
||||
|
||||
ChannelBuffer binaryData = buffer.readBytes(frameSize);
|
||||
buffer.skipBytes(1);
|
||||
return new DefaultWebSocketFrame(type, binaryData);
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.websocket;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
/**
|
||||
* @deprecated Use <tt>org.jboss.netty.handler.codec.http.websocketx</tt> instead.
|
||||
*
|
||||
* Encodes a {@link WebSocketFrame} into a {@link ChannelBuffer}.
|
||||
* <p>
|
||||
* For the detailed instruction on adding add Web Socket support to your HTTP
|
||||
* server, take a look into the <tt>WebSocketServer</tt> example located in the
|
||||
* {@code org.jboss.netty.example.http.websocket} package.
|
||||
* @apiviz.landmark
|
||||
* @apiviz.uses org.jboss.netty.handler.codec.http.websocket.WebSocketFrame
|
||||
*/
|
||||
@Deprecated
|
||||
@Sharable
|
||||
public class WebSocketFrameEncoder extends OneToOneEncoder {
|
||||
|
||||
@Override
|
||||
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
|
||||
if (msg instanceof WebSocketFrame) {
|
||||
WebSocketFrame frame = (WebSocketFrame) msg;
|
||||
int type = frame.getType();
|
||||
if (frame.isText()) {
|
||||
// Text frame
|
||||
ChannelBuffer data = frame.getBinaryData();
|
||||
ChannelBuffer encoded =
|
||||
channel.getConfig().getBufferFactory().getBuffer(
|
||||
data.order(), data.readableBytes() + 2);
|
||||
encoded.writeByte((byte) type);
|
||||
encoded.writeBytes(data, data.readerIndex(), data.readableBytes());
|
||||
encoded.writeByte((byte) 0xFF);
|
||||
return encoded;
|
||||
} else {
|
||||
// Binary frame
|
||||
ChannelBuffer data = frame.getBinaryData();
|
||||
int dataLen = data.readableBytes();
|
||||
ChannelBuffer encoded =
|
||||
channel.getConfig().getBufferFactory().getBuffer(
|
||||
data.order(), dataLen + 5);
|
||||
|
||||
// Encode type.
|
||||
encoded.writeByte((byte) type);
|
||||
|
||||
// Encode length.
|
||||
int b1 = dataLen >>> 28 & 0x7F;
|
||||
int b2 = dataLen >>> 14 & 0x7F;
|
||||
int b3 = dataLen >>> 7 & 0x7F;
|
||||
int b4 = dataLen & 0x7F;
|
||||
if (b1 == 0) {
|
||||
if (b2 == 0) {
|
||||
if (b3 == 0) {
|
||||
encoded.writeByte(b4);
|
||||
} else {
|
||||
encoded.writeByte(b3 | 0x80);
|
||||
encoded.writeByte(b4);
|
||||
}
|
||||
} else {
|
||||
encoded.writeByte(b2 | 0x80);
|
||||
encoded.writeByte(b3 | 0x80);
|
||||
encoded.writeByte(b4);
|
||||
}
|
||||
} else {
|
||||
encoded.writeByte(b1 | 0x80);
|
||||
encoded.writeByte(b2 | 0x80);
|
||||
encoded.writeByte(b3 | 0x80);
|
||||
encoded.writeByte(b4);
|
||||
}
|
||||
|
||||
// Encode binary data.
|
||||
encoded.writeBytes(data, data.readerIndex(), dataLen);
|
||||
return encoded;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Use <tt>org.jboss.netty.handler.codec.http.websocketx</tt> instead.
|
||||
*
|
||||
* Encoder, decoder and their related message types for
|
||||
* <a href="http://en.wikipedia.org/wiki/Web_Sockets">Web Socket</a> data frames.
|
||||
* <p>
|
||||
* For the detailed instruction on adding add Web Socket support to your HTTP
|
||||
* server, take a look into the <tt>WebSocketServer</tt> example located in the
|
||||
* {@code org.jboss.netty.example.http.websocket} package.
|
||||
* *
|
||||
* @apiviz.exclude OneToOne(Encoder|Decoder)$
|
||||
* @apiviz.exclude \.codec\.replay\.
|
||||
* @apiviz.exclude \.Default
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.websocket;
|
|
@ -42,19 +42,6 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder<VoidEnum> {
|
|||
this(DEFAULT_MAX_FRAME_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client
|
||||
* sends a frame size larger than {@code maxFrameSize}, the channel will be closed.
|
||||
*
|
||||
* @param maxFrameSize
|
||||
* the maximum frame size to decode
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public WebSocket00FrameDecoder(int maxFrameSize) {
|
||||
this.maxFrameSize = maxFrameSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@code WebSocketFrameDecoder} with the specified {@code maxFrameSize}. If the client
|
||||
* sends a frame size larger than {@code maxFrameSize}, the channel will be closed.
|
||||
|
|
|
@ -28,19 +28,6 @@ import org.jboss.netty.util.CharsetUtil;
|
|||
*/
|
||||
final class WebSocketUtil {
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #md5(ChannelBuffer)}
|
||||
*/
|
||||
@Deprecated
|
||||
static byte[] md5(byte[] bytes) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
return md.digest(bytes);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new InternalError("MD5 not supported on this platform");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an MD5 hash
|
||||
*
|
||||
|
@ -64,19 +51,6 @@ final class WebSocketUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #sha1(ChannelBuffer)}
|
||||
*/
|
||||
@Deprecated
|
||||
static byte[] sha1(byte[] bytes) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA1");
|
||||
return md.digest(bytes);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new InternalError("SHA-1 not supported on this platform");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an SHA-1 hash
|
||||
*
|
||||
|
@ -100,15 +74,6 @@ final class WebSocketUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #base64(ChannelBuffer)}
|
||||
*/
|
||||
@Deprecated
|
||||
static String base64(byte[] bytes) {
|
||||
ChannelBuffer hashed = ChannelBuffers.wrappedBuffer(bytes);
|
||||
return Base64.encode(hashed).toString(CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base 64 encoding
|
||||
*
|
||||
|
|
|
@ -340,15 +340,6 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
|||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelBuffer readBytes(ChannelBufferIndexFinder endIndexFinder) {
|
||||
int endIndex = buf().indexOf(buf().readerIndex(), buf().writerIndex(), endIndexFinder);
|
||||
if (endIndex < 0) {
|
||||
throw REPLAY;
|
||||
}
|
||||
return buf().readBytes(endIndex - buf().readerIndex());
|
||||
}
|
||||
|
||||
public int readBytes(GatheringByteChannel out, int length)
|
||||
throws IOException {
|
||||
throw new UnreplayableOperationException();
|
||||
|
@ -359,16 +350,6 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
|||
return buf().readBytes(length);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelBuffer readSlice(
|
||||
ChannelBufferIndexFinder endIndexFinder) {
|
||||
int endIndex = buf().indexOf(buf().readerIndex(), buf().writerIndex(), endIndexFinder);
|
||||
if (endIndex < 0) {
|
||||
throw REPLAY;
|
||||
}
|
||||
return buf().readSlice(endIndex - buf().readerIndex());
|
||||
}
|
||||
|
||||
public ChannelBuffer readSlice(int length) {
|
||||
checkReadableBytes(length);
|
||||
return buf().readSlice(length);
|
||||
|
@ -518,17 +499,6 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
|||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int skipBytes(ChannelBufferIndexFinder firstIndexFinder) {
|
||||
int oldReaderIndex = buf().readerIndex();
|
||||
int newReaderIndex = buf().indexOf(oldReaderIndex, buf().writerIndex(), firstIndexFinder);
|
||||
if (newReaderIndex < 0) {
|
||||
throw REPLAY;
|
||||
}
|
||||
buf().readerIndex(newReaderIndex);
|
||||
return newReaderIndex - oldReaderIndex;
|
||||
}
|
||||
|
||||
public void skipBytes(int length) {
|
||||
checkReadableBytes(length);
|
||||
buf().skipBytes(length);
|
||||
|
@ -570,31 +540,6 @@ class ReplayingDecoderBuffer implements ChannelBuffer {
|
|||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(int index, int length, String charsetName) {
|
||||
checkIndex(index, length);
|
||||
return buf().toString(index, length, charsetName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(
|
||||
int index, int length, String charsetName,
|
||||
ChannelBufferIndexFinder terminatorFinder) {
|
||||
checkIndex(index, length);
|
||||
return buf().toString(index, length, charsetName, terminatorFinder);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(String charsetName) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String toString(
|
||||
String charsetName, ChannelBufferIndexFinder terminatorFinder) {
|
||||
throw new UnreplayableOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + '(' +
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.replay;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.buffer.DynamicChannelBuffer;
|
||||
|
||||
/**
|
||||
* This class is not used by {@link ReplayingDecoder} anymore but is still here to not break API.
|
||||
*
|
||||
* This class will get removed in the future.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
class UnsafeDynamicChannelBuffer extends DynamicChannelBuffer {
|
||||
|
||||
UnsafeDynamicChannelBuffer(ChannelBufferFactory factory, int minimumCapacity) {
|
||||
super(factory.getDefaultOrder(), minimumCapacity, factory);
|
||||
}
|
||||
|
||||
UnsafeDynamicChannelBuffer(ChannelBufferFactory factory) {
|
||||
this(factory, 256);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkReadableBytes(int minReaderRemaining) {
|
||||
// Do not check here - ReplayingDecoderBuffer will check.
|
||||
}
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamConstants;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferInputStream;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
||||
|
||||
/**
|
||||
* A decoder which deserializes the received {@link ChannelBuffer}s into Java
|
||||
* objects (interoperability version).
|
||||
* <p>
|
||||
* This decoder is interoperable with the standard Java object
|
||||
* streams such as {@link ObjectInputStream} and {@link ObjectOutputStream}.
|
||||
* <p>
|
||||
* However, this decoder might perform worse than {@link ObjectDecoder} if
|
||||
* the serialized object is big and complex. Also, it does not limit the
|
||||
* maximum size of the object, and consequently your application might face
|
||||
* the risk of <a href="http://en.wikipedia.org/wiki/DoS">DoS attack</a>.
|
||||
* Please use {@link ObjectEncoder} and {@link ObjectDecoder} if you are not
|
||||
* required to keep the interoperability with the standard object streams.
|
||||
*
|
||||
* @deprecated This decoder has a known critical bug which fails to decode and
|
||||
* raises a random exception in some circumstances. Avoid to use
|
||||
* it whenever you can. The only workaround is to replace
|
||||
* {@link CompatibleObjectEncoder}, {@link CompatibleObjectDecoder},
|
||||
* {@link ObjectInputStream}, and {@link ObjectOutputStream} with
|
||||
* {@link ObjectEncoder}, {@link ObjectDecoder},
|
||||
* {@link ObjectEncoderOutputStream}, and
|
||||
* {@link ObjectDecoderInputStream} respectively. This workaround
|
||||
* requires both a client and a server to be modified.
|
||||
*/
|
||||
@Deprecated
|
||||
public class CompatibleObjectDecoder extends ReplayingDecoder<CompatibleObjectDecoderState> {
|
||||
|
||||
private final SwitchableInputStream bin = new SwitchableInputStream();
|
||||
private ObjectInputStream oin;
|
||||
|
||||
/**
|
||||
* Creates a new decoder.
|
||||
*/
|
||||
public CompatibleObjectDecoder() {
|
||||
super(CompatibleObjectDecoderState.READ_HEADER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ObjectInputStream} which wraps the specified
|
||||
* {@link InputStream}. Override this method to use a subclass of the
|
||||
* {@link ObjectInputStream}.
|
||||
*/
|
||||
protected ObjectInputStream newObjectInputStream(InputStream in) throws Exception {
|
||||
return new ObjectInputStream(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object decode(
|
||||
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer,
|
||||
CompatibleObjectDecoderState state) throws Exception {
|
||||
bin.switchStream(new ChannelBufferInputStream(buffer));
|
||||
switch (state) {
|
||||
case READ_HEADER:
|
||||
oin = newObjectInputStream(bin);
|
||||
checkpoint(CompatibleObjectDecoderState.READ_OBJECT);
|
||||
case READ_OBJECT:
|
||||
return oin.readObject();
|
||||
default:
|
||||
throw new IllegalStateException("Unknown state: " + state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object decodeLast(ChannelHandlerContext ctx, Channel channel,
|
||||
ChannelBuffer buffer, CompatibleObjectDecoderState state)
|
||||
throws Exception {
|
||||
switch (buffer.readableBytes()) {
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
// Ignore the last TC_RESET
|
||||
if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
|
||||
buffer.skipBytes(1);
|
||||
oin.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Object decoded = decode(ctx, channel, buffer, state);
|
||||
oin.close();
|
||||
return decoded;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
enum CompatibleObjectDecoderState {
|
||||
READ_HEADER,
|
||||
READ_OBJECT,
|
||||
}
|
|
@ -40,19 +40,6 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
|
|||
|
||||
private final ClassResolver classResolver;
|
||||
|
||||
/**
|
||||
* Creates a new decoder whose maximum object size is {@code 1048576}
|
||||
* bytes. If the size of the received object is greater than
|
||||
* {@code 1048576} bytes, a {@link StreamCorruptedException} will be
|
||||
* raised.
|
||||
*
|
||||
* @deprecated use {@link #ObjectDecoder(ClassResolver)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectDecoder() {
|
||||
this(1048576);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new decoder whose maximum object size is {@code 1048576}
|
||||
* bytes. If the size of the received object is greater than
|
||||
|
@ -65,20 +52,6 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
|
|||
this(1048576, classResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new decoder with the specified maximum object size.
|
||||
*
|
||||
* @param maxObjectSize the maximum byte length of the serialized object.
|
||||
* if the length of the received object is greater
|
||||
* than this value, {@link StreamCorruptedException}
|
||||
* will be raised.
|
||||
* @deprecated use {@link #ObjectDecoder(int, ClassResolver)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectDecoder(int maxObjectSize) {
|
||||
this(maxObjectSize, ClassResolvers.weakCachingResolver(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new decoder with the specified maximum object size.
|
||||
*
|
||||
|
@ -97,22 +70,6 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
|
|||
this.classResolver = classResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new decoder with the specified maximum object size and the {@link ClassLoader}
|
||||
* wrapped in {@link ClassResolvers#weakCachingResolver(ClassLoader)}.
|
||||
*
|
||||
* @param maxObjectSize the maximum byte length of the serialized object.
|
||||
* if the length of the received object is greater
|
||||
* than this value, {@link StreamCorruptedException}
|
||||
* will be raised.
|
||||
* @param classLoader the the classloader to use
|
||||
* @deprecated use {@link #ObjectDecoder(int, ClassResolver)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectDecoder(int maxObjectSize, ClassLoader classLoader) {
|
||||
this(maxObjectSize, ClassResolvers.weakCachingResolver(classLoader));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object decode(
|
||||
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
|
||||
|
|
|
@ -26,15 +26,6 @@ import org.jboss.netty.util.CharsetUtil;
|
|||
* Before returning SocksRequest decoder removes itself from pipeline.
|
||||
*/
|
||||
public class SocksAuthRequestDecoder extends ReplayingDecoder<SocksAuthRequestDecoder.State> {
|
||||
private static final String name = "SOCKS_AUTH_REQUEST_DECODER";
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private SocksMessage.SubnegotiationVersion version;
|
||||
private int fieldLength;
|
||||
|
|
|
@ -25,15 +25,6 @@ import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
|||
* Before returning SocksResponse decoder removes itself from pipeline.
|
||||
*/
|
||||
public class SocksAuthResponseDecoder extends ReplayingDecoder<SocksAuthResponseDecoder.State> {
|
||||
private static final String name = "SOCKS_AUTH_RESPONSE_DECODER";
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private SocksMessage.SubnegotiationVersion version;
|
||||
private SocksMessage.AuthStatus authStatus;
|
||||
|
|
|
@ -26,15 +26,6 @@ import org.jboss.netty.util.CharsetUtil;
|
|||
* Before returning SocksRequest decoder removes itself from pipeline.
|
||||
*/
|
||||
public class SocksCmdRequestDecoder extends ReplayingDecoder<SocksCmdRequestDecoder.State> {
|
||||
private static final String name = "SOCKS_CMD_REQUEST_DECODER";
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private SocksMessage.ProtocolVersion version;
|
||||
private int fieldLength;
|
||||
|
|
|
@ -26,15 +26,6 @@ import org.jboss.netty.util.CharsetUtil;
|
|||
* Before returning SocksResponse decoder removes itself from pipeline.
|
||||
*/
|
||||
public class SocksCmdResponseDecoder extends ReplayingDecoder<SocksCmdResponseDecoder.State> {
|
||||
private static final String name = "SOCKS_CMD_RESPONSE_DECODER";
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private SocksMessage.ProtocolVersion version;
|
||||
private int fieldLength;
|
||||
|
|
|
@ -28,15 +28,6 @@ import java.util.List;
|
|||
* Before returning SocksRequest decoder removes itself from pipeline.
|
||||
*/
|
||||
public class SocksInitRequestDecoder extends ReplayingDecoder<SocksInitRequestDecoder.State> {
|
||||
private static final String name = "SOCKS_INIT_REQUEST_DECODER";
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private final List<SocksMessage.AuthScheme> authSchemes = new ArrayList<SocksMessage.AuthScheme>();
|
||||
private SocksMessage.ProtocolVersion version;
|
||||
|
|
|
@ -25,15 +25,6 @@ import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
|||
* Before returning SocksResponse decoder removes itself from pipeline.
|
||||
*/
|
||||
public class SocksInitResponseDecoder extends ReplayingDecoder<SocksInitResponseDecoder.State> {
|
||||
private static final String name = "SOCKS_INIT_RESPONSE_DECODER";
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private SocksMessage.ProtocolVersion version;
|
||||
private SocksMessage.AuthScheme authScheme;
|
||||
|
|
|
@ -30,17 +30,8 @@ import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
|||
*/
|
||||
@ChannelHandler.Sharable
|
||||
public class SocksMessageEncoder extends OneToOneEncoder {
|
||||
private static final String name = "SOCKS_MESSAGE_ENCODER";
|
||||
private static final int DEFAULT_ENCODER_BUFFER_SIZE = 1024;
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed at the next minor version bump.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
|
||||
ChannelBuffer buffer = null;
|
||||
|
|
|
@ -60,56 +60,6 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyStreamFrame
|
|||
return headers;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addHeader(final String name, final Object value) {
|
||||
headers.add(name, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(final String name, final Object value) {
|
||||
headers.set(name, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHeader(final String name, final Iterable<?> values) {
|
||||
headers.set(name, values);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void removeHeader(final String name) {
|
||||
headers.remove(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void clearHeaders() {
|
||||
headers.clear();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getHeader(final String name) {
|
||||
return headers.get(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getHeaders(final String name) {
|
||||
return headers.getAll(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Map.Entry<String, String>> getHeaders() {
|
||||
return headers.entries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean containsHeader(final String name) {
|
||||
return headers.contains(name);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Set<String> getHeaderNames() {
|
||||
return headers.names();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -50,64 +50,4 @@ public interface SpdyHeadersFrame extends SpdyStreamFrame {
|
|||
* Returns the {@link SpdyHeaders}.
|
||||
*/
|
||||
SpdyHeaders headers();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<String> getHeaders(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<Map.Entry<String, String>> getHeaders();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean containsHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Set<String> getHeaderNames();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void addHeader(String name, Object value);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeader(String name, Object value);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeader(String name, Iterable<?> values);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void removeHeader(String name);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link SpdyHeaders#headers()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void clearHeaders();
|
||||
}
|
||||
|
|
|
@ -78,14 +78,6 @@ public class StringDecoder extends OneToOneDecoder {
|
|||
this.charset = charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #StringDecoder(Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public StringDecoder(String charsetName) {
|
||||
this(Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object decode(
|
||||
ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
|
||||
|
|
|
@ -76,14 +76,6 @@ public class StringEncoder extends OneToOneEncoder {
|
|||
this.charset = charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #StringEncoder(Charset)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public StringEncoder(String charsetName) {
|
||||
this(Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object encode(
|
||||
ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
|
||||
|
|
|
@ -120,16 +120,6 @@ public class ExecutionHandler implements ChannelUpstreamHandler, ChannelDownstre
|
|||
this(executor, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link #ExecutionHandler(Executor, boolean, boolean)}
|
||||
*
|
||||
* {@link Deprecated}
|
||||
*/
|
||||
@Deprecated
|
||||
public ExecutionHandler(Executor executor, boolean handleDownstream) {
|
||||
this(executor, handleDownstream, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified {@link Executor}.
|
||||
* Specify an {@link OrderedMemoryAwareThreadPoolExecutor} if unsure.
|
||||
|
|
|
@ -385,22 +385,6 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
|
|||
return totalLimiter.limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated <tt>maxTotalMemorySize</tt> is not modifiable anymore.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMaxTotalMemorySize(long maxTotalMemorySize) {
|
||||
if (maxTotalMemorySize < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"maxTotalMemorySize: " + maxTotalMemorySize);
|
||||
}
|
||||
|
||||
if (getTaskCount() > 0) {
|
||||
throw new IllegalStateException(
|
||||
"can't be changed after a task is executed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If set to {@code false} no queued {@link ChannelEventRunnable}'s {@link ChannelFuture}
|
||||
* will get notified once {@link #shutdownNow()} is called. If set to {@code true} every
|
||||
|
|
|
@ -115,16 +115,6 @@ public final class OrderedDownstreamThreadPoolExecutor extends OrderedMemoryAwar
|
|||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws {@link UnsupportedOperationException} as there is not support for limit the memory
|
||||
* size in this implementation
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setMaxTotalMemorySize(long maxTotalMemorySize) {
|
||||
throw new UnsupportedOperationException("Not supported by this implementation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code false} as we not need to cound the memory in this implementation
|
||||
*/
|
||||
|
|
|
@ -55,7 +55,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
||||
|
@ -207,7 +206,6 @@ public class SslHandler extends FrameDecoder
|
|||
private volatile ChannelHandlerContext ctx;
|
||||
private final SSLEngine engine;
|
||||
private final SslBufferPool bufferPool;
|
||||
private final Executor delegatedTaskExecutor;
|
||||
private final boolean startTls;
|
||||
|
||||
private volatile boolean enableRenegotiation = true;
|
||||
|
@ -312,67 +310,20 @@ public class SslHandler extends FrameDecoder
|
|||
* @param handshakeTimeoutInMillis
|
||||
* the time in milliseconds after whic the {@link #handshake()} will be failed, and so the future notified
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public SslHandler(SSLEngine engine, SslBufferPool bufferPool, boolean startTls,
|
||||
Timer timer, long handshakeTimeoutInMillis) {
|
||||
this(engine, bufferPool, startTls, ImmediateExecutor.INSTANCE, timer, handshakeTimeoutInMillis);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #SslHandler(SSLEngine)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SslHandler(SSLEngine engine, Executor delegatedTaskExecutor) {
|
||||
this(engine, getDefaultBufferPool(), delegatedTaskExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #SslHandler(SSLEngine, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SslHandler(SSLEngine engine, SslBufferPool bufferPool, Executor delegatedTaskExecutor) {
|
||||
this(engine, bufferPool, false, delegatedTaskExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #SslHandler(SSLEngine, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SslHandler(SSLEngine engine, boolean startTls, Executor delegatedTaskExecutor) {
|
||||
this(engine, getDefaultBufferPool(), startTls, delegatedTaskExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #SslHandler(SSLEngine, SslBufferPool, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SslHandler(SSLEngine engine, SslBufferPool bufferPool, boolean startTls, Executor delegatedTaskExecutor) {
|
||||
this(engine, bufferPool, startTls, delegatedTaskExecutor, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #SslHandler(SSLEngine engine, SslBufferPool bufferPool, boolean startTls, Timer timer,
|
||||
* long handshakeTimeoutInMillis)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public SslHandler(SSLEngine engine, SslBufferPool bufferPool, boolean startTls, Executor delegatedTaskExecutor,
|
||||
Timer timer, long handshakeTimeoutInMillis) {
|
||||
public SslHandler(SSLEngine engine, SslBufferPool bufferPool, boolean startTls, Timer timer,
|
||||
long handshakeTimeoutInMillis) {
|
||||
if (engine == null) {
|
||||
throw new NullPointerException("engine");
|
||||
}
|
||||
if (bufferPool == null) {
|
||||
throw new NullPointerException("bufferPool");
|
||||
}
|
||||
if (delegatedTaskExecutor == null) {
|
||||
throw new NullPointerException("delegatedTaskExecutor");
|
||||
}
|
||||
if (timer == null && handshakeTimeoutInMillis > 0) {
|
||||
throw new IllegalArgumentException("No Timer was given but a handshakeTimeoutInMillis, need both or none");
|
||||
}
|
||||
|
||||
this.engine = engine;
|
||||
this.bufferPool = bufferPool;
|
||||
this.delegatedTaskExecutor = delegatedTaskExecutor;
|
||||
this.startTls = startTls;
|
||||
this.timer = timer;
|
||||
this.handshakeTimeoutInMillis = handshakeTimeoutInMillis;
|
||||
|
@ -463,14 +414,6 @@ public class SslHandler extends FrameDecoder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #handshake()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ChannelFuture handshake(@SuppressWarnings("unused") Channel channel) {
|
||||
return handshake();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an SSL {@code close_notify} message to the specified channel and
|
||||
* destroys the underlying {@link SSLEngine}.
|
||||
|
@ -490,14 +433,6 @@ public class SslHandler extends FrameDecoder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #close()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ChannelFuture close(@SuppressWarnings("unused") Channel channel) {
|
||||
return close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if and only if TLS renegotiation is enabled.
|
||||
*/
|
||||
|
@ -1433,72 +1368,20 @@ public class SslHandler extends FrameDecoder
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetches all delegated tasks from the {@link SSLEngine} and runs them via the {@link #delegatedTaskExecutor}.
|
||||
* If the {@link #delegatedTaskExecutor} is {@link ImmediateExecutor}, just call {@link Runnable#run()} directly
|
||||
* instead of using {@link Executor#execute(Runnable)}. Otherwise, run the tasks via
|
||||
* the {@link #delegatedTaskExecutor} and wait until the tasks are finished.
|
||||
* Fetches all delegated tasks from the {@link SSLEngine} and runs them immediately.
|
||||
*/
|
||||
private void runDelegatedTasks() {
|
||||
if (delegatedTaskExecutor == ImmediateExecutor.INSTANCE) {
|
||||
for (;;) {
|
||||
final Runnable task;
|
||||
synchronized (handshakeLock) {
|
||||
task = engine.getDelegatedTask();
|
||||
}
|
||||
|
||||
if (task == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
delegatedTaskExecutor.execute(task);
|
||||
}
|
||||
} else {
|
||||
final List<Runnable> tasks = new ArrayList<Runnable>(2);
|
||||
for (;;) {
|
||||
final Runnable task;
|
||||
synchronized (handshakeLock) {
|
||||
task = engine.getDelegatedTask();
|
||||
}
|
||||
|
||||
if (task == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
tasks.add(task);
|
||||
for (;;) {
|
||||
final Runnable task;
|
||||
synchronized (handshakeLock) {
|
||||
task = engine.getDelegatedTask();
|
||||
}
|
||||
|
||||
if (tasks.isEmpty()) {
|
||||
return;
|
||||
if (task == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
delegatedTaskExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
for (Runnable task: tasks) {
|
||||
task.run();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
fireExceptionCaught(ctx, e);
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
boolean interrupted = false;
|
||||
while (latch.getCount() != 0) {
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
// Interrupt later.
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupted) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1194,31 +1194,6 @@ public abstract class AbstractChannelBufferTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSequentialCopiedBufferTransfer2() {
|
||||
buffer.clear();
|
||||
buffer.writeZero(buffer.capacity());
|
||||
try {
|
||||
buffer.readBytes(ChannelBufferIndexFinder.CR);
|
||||
fail();
|
||||
} catch (NoSuchElementException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
assertSame(EMPTY_BUFFER, buffer.readBytes(ChannelBufferIndexFinder.NUL));
|
||||
|
||||
buffer.clear();
|
||||
buffer.writeBytes(new byte[] { 1, 2, 3, 4, 0 });
|
||||
|
||||
ChannelBuffer copy = buffer.readBytes(ChannelBufferIndexFinder.NUL);
|
||||
assertEquals(wrappedBuffer(new byte[] { 1, 2, 3, 4 }), copy);
|
||||
|
||||
// Make sure if it is a copied buffer.
|
||||
copy.setByte(0, (byte) (copy.getByte(0) + 1));
|
||||
assertFalse(buffer.getByte(0) == copy.getByte(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSequentialSlice1() {
|
||||
buffer.writerIndex(0);
|
||||
|
@ -1245,31 +1220,6 @@ public abstract class AbstractChannelBufferTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSequentialSlice2() {
|
||||
buffer.clear();
|
||||
buffer.writeZero(buffer.capacity());
|
||||
try {
|
||||
buffer.readSlice(ChannelBufferIndexFinder.CR);
|
||||
fail();
|
||||
} catch (NoSuchElementException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
assertSame(EMPTY_BUFFER, buffer.readSlice(ChannelBufferIndexFinder.NUL));
|
||||
|
||||
buffer.clear();
|
||||
buffer.writeBytes(new byte[] { 1, 2, 3, 4, 0 });
|
||||
|
||||
ChannelBuffer slice = buffer.readSlice(ChannelBufferIndexFinder.NUL);
|
||||
assertEquals(wrappedBuffer(new byte[] { 1, 2, 3, 4 }), slice);
|
||||
|
||||
// Make sure if it is a sliced buffer.
|
||||
slice.setByte(0, (byte) (slice.getByte(0) + 1));
|
||||
assertEquals(buffer.getByte(0), slice.getByte(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteZero() {
|
||||
try {
|
||||
|
@ -1654,28 +1604,6 @@ public abstract class AbstractChannelBufferTest {
|
|||
assertEquals(CAPACITY / 4 * 2, buffer.readerIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSkipBytes2() {
|
||||
buffer.clear();
|
||||
buffer.writeZero(buffer.capacity());
|
||||
|
||||
try {
|
||||
buffer.skipBytes(ChannelBufferIndexFinder.LF);
|
||||
fail();
|
||||
} catch (NoSuchElementException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
buffer.skipBytes(ChannelBufferIndexFinder.NUL);
|
||||
assertEquals(0, buffer.readerIndex());
|
||||
|
||||
buffer.clear();
|
||||
buffer.writeBytes(new byte[] { 1, 2, 3, 4, 0 });
|
||||
buffer.skipBytes(ChannelBufferIndexFinder.NUL);
|
||||
assertEquals(4, buffer.readerIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
ChannelBuffer elemA = buffer(15);
|
||||
|
|
|
@ -97,11 +97,6 @@ public class CompleteChannelFutureTest {
|
|||
throw new Error();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ChannelFuture rethrowIfFailed() throws Exception {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
public ChannelFuture sync() throws InterruptedException {
|
||||
throw new Error();
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StaticChannelPipelineTest {
|
||||
|
||||
@Test
|
||||
public void testConstructionWithoutNull() {
|
||||
StaticChannelPipeline p = new StaticChannelPipeline(new A(), new B());
|
||||
Map<String, ChannelHandler> m = p.toMap();
|
||||
Assert.assertEquals(2, m.size());
|
||||
Assert.assertTrue(m.get("0") instanceof A);
|
||||
Assert.assertTrue(m.get("1") instanceof B);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructionWithNull1() {
|
||||
StaticChannelPipeline p = new StaticChannelPipeline(null, new A(), new B());
|
||||
Map<String, ChannelHandler> m = p.toMap();
|
||||
Assert.assertEquals(0, m.size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructionWithNull2() {
|
||||
StaticChannelPipeline p = new StaticChannelPipeline(new A(), null, new B());
|
||||
Map<String, ChannelHandler> m = p.toMap();
|
||||
Assert.assertEquals(1, m.size());
|
||||
Assert.assertTrue(m.get("0") instanceof A);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructionWithNull() {
|
||||
StaticChannelPipeline p = new StaticChannelPipeline(new A(), new B(), null);
|
||||
Map<String, ChannelHandler> m = p.toMap();
|
||||
Assert.assertEquals(2, m.size());
|
||||
Assert.assertTrue(m.get("0") instanceof A);
|
||||
Assert.assertTrue(m.get("1") instanceof B);
|
||||
}
|
||||
|
||||
static final class A extends SimpleChannelHandler {
|
||||
// Dummy
|
||||
}
|
||||
|
||||
static final class B extends SimpleChannelHandler {
|
||||
// Dummy
|
||||
}
|
||||
}
|
|
@ -1,178 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.jboss.netty.bootstrap.ClientBootstrap;
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.util.TestUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class AbstractSocketCompatibleObjectStreamEchoTest {
|
||||
|
||||
static final Random random = new Random();
|
||||
static final String[] data = new String[1024];
|
||||
|
||||
|
||||
static {
|
||||
for (int i = 0; i < data.length; i ++) {
|
||||
int eLen = random.nextInt(512);
|
||||
char[] e = new char[eLen];
|
||||
for (int j = 0; j < eLen; j ++) {
|
||||
e[j] = (char) ('a' + random.nextInt(26));
|
||||
}
|
||||
|
||||
data[i] = new String(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected abstract ChannelFactory newServerSocketChannelFactory(Executor executor);
|
||||
protected abstract ChannelFactory newClientSocketChannelFactory(Executor executor);
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testCompatibleObjectEcho() throws Throwable {
|
||||
ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(Executors.newCachedThreadPool()));
|
||||
ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(Executors.newCachedThreadPool()));
|
||||
|
||||
EchoHandler sh = new EchoHandler();
|
||||
EchoHandler ch = new EchoHandler();
|
||||
|
||||
sb.getPipeline().addLast("decoder", new CompatibleObjectDecoder());
|
||||
sb.getPipeline().addLast("encoder", new CompatibleObjectEncoder());
|
||||
sb.getPipeline().addLast("handler", sh);
|
||||
|
||||
cb.getPipeline().addLast("decoder", new CompatibleObjectDecoder());
|
||||
cb.getPipeline().addLast("encoder", new CompatibleObjectEncoder());
|
||||
cb.getPipeline().addLast("handler", ch);
|
||||
|
||||
Channel sc = sb.bind(new InetSocketAddress(0));
|
||||
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
|
||||
|
||||
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
|
||||
assertTrue(ccf.awaitUninterruptibly().isSuccess());
|
||||
|
||||
Channel cc = ccf.getChannel();
|
||||
for (String element : data) {
|
||||
cc.write(element);
|
||||
}
|
||||
|
||||
while (ch.counter < data.length) {
|
||||
if (sh.exception.get() != null) {
|
||||
break;
|
||||
}
|
||||
if (ch.exception.get() != null) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
||||
while (sh.counter < data.length) {
|
||||
if (sh.exception.get() != null) {
|
||||
break;
|
||||
}
|
||||
if (ch.exception.get() != null) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
||||
sh.channel.close().awaitUninterruptibly();
|
||||
ch.channel.close().awaitUninterruptibly();
|
||||
sc.close().awaitUninterruptibly();
|
||||
cb.shutdown();
|
||||
sb.shutdown();
|
||||
cb.releaseExternalResources();
|
||||
sb.releaseExternalResources();
|
||||
|
||||
if (sh.exception.get() != null && !(sh.exception.get() instanceof IOException)) {
|
||||
throw sh.exception.get();
|
||||
}
|
||||
if (ch.exception.get() != null && !(ch.exception.get() instanceof IOException)) {
|
||||
throw ch.exception.get();
|
||||
}
|
||||
if (sh.exception.get() != null) {
|
||||
throw sh.exception.get();
|
||||
}
|
||||
if (ch.exception.get() != null) {
|
||||
throw ch.exception.get();
|
||||
}
|
||||
}
|
||||
|
||||
private static class EchoHandler extends SimpleChannelUpstreamHandler {
|
||||
volatile Channel channel;
|
||||
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
|
||||
volatile int counter;
|
||||
|
||||
EchoHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
|
||||
throws Exception {
|
||||
channel = e.getChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
|
||||
throws Exception {
|
||||
|
||||
String m = (String) e.getMessage();
|
||||
assertEquals(data[counter], m);
|
||||
|
||||
if (channel.getParent() != null) {
|
||||
channel.write(m);
|
||||
}
|
||||
|
||||
counter ++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
|
||||
throws Exception {
|
||||
if (exception.compareAndSet(null, e.getCause())) {
|
||||
e.getChannel().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
|
||||
public class NioNioSocketCompatibleObjectStreamEchoTest extends AbstractSocketCompatibleObjectStreamEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientSocketChannelFactory(Executor executor) {
|
||||
return new NioClientSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerSocketChannelFactory(Executor executor) {
|
||||
return new NioServerSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
|
||||
|
||||
public class NioOioSocketCompatibleObjectStreamEchoTest extends AbstractSocketCompatibleObjectStreamEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientSocketChannelFactory(Executor executor) {
|
||||
return new NioClientSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerSocketChannelFactory(Executor executor) {
|
||||
return new OioServerSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
|
||||
|
||||
public class OioNioSocketCompatibleObjectStreamEchoTest extends AbstractSocketCompatibleObjectStreamEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientSocketChannelFactory(Executor executor) {
|
||||
return new OioClientSocketChannelFactory(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerSocketChannelFactory(Executor executor) {
|
||||
return new NioServerSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.serialization;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
|
||||
|
||||
public class OioOioSocketCompatibleObjectStreamEchoTest extends AbstractSocketCompatibleObjectStreamEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientSocketChannelFactory(Executor executor) {
|
||||
return new OioClientSocketChannelFactory(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerSocketChannelFactory(Executor executor) {
|
||||
return new OioServerSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
}
|
|
@ -59,29 +59,7 @@ public class SocketSslEchoTest extends SslTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSslEcho1() throws Throwable {
|
||||
testSslEcho(false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSslEcho2() throws Throwable {
|
||||
testSslEcho(false, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSslEcho3() throws Throwable {
|
||||
testSslEcho(true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSslEcho4() throws Throwable {
|
||||
testSslEcho(true, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void testSslEcho(
|
||||
boolean serverUsesDelegatedTaskExecutor, boolean clientUsesDelegatedTaskExecutor) throws Throwable {
|
||||
ExecutorService delegatedTaskExecutor = Executors.newCachedThreadPool();
|
||||
public void testSslEcho() throws Throwable {
|
||||
ServerBootstrap sb = new ServerBootstrap(serverChannelFactory);
|
||||
ClientBootstrap cb = new ClientBootstrap(clientChannelFactory);
|
||||
|
||||
|
@ -93,21 +71,11 @@ public class SocketSslEchoTest extends SslTest {
|
|||
sb.setOption("receiveBufferSize", 1048576);
|
||||
|
||||
// Configure the server pipeline.
|
||||
if (serverUsesDelegatedTaskExecutor) {
|
||||
sb.getPipeline().addFirst(
|
||||
"ssl", new SslHandler(serverCtx.newEngine(), serverCtx.bufferPool(), delegatedTaskExecutor));
|
||||
} else {
|
||||
sb.getPipeline().addFirst("ssl", serverCtx.newHandler());
|
||||
}
|
||||
sb.getPipeline().addFirst("ssl", serverCtx.newHandler());
|
||||
sb.getPipeline().addLast("handler", sh);
|
||||
|
||||
// Configure the client pipeline.
|
||||
if (clientUsesDelegatedTaskExecutor) {
|
||||
cb.getPipeline().addFirst(
|
||||
"ssl", new SslHandler(clientCtx.newEngine(), clientCtx.bufferPool(), delegatedTaskExecutor));
|
||||
} else {
|
||||
cb.getPipeline().addFirst("ssl", clientCtx.newHandler());
|
||||
}
|
||||
cb.getPipeline().addFirst("ssl", clientCtx.newHandler());
|
||||
cb.getPipeline().addLast("handler", ch);
|
||||
|
||||
Channel sc = sb.bind(new InetSocketAddress(0));
|
||||
|
@ -172,7 +140,6 @@ public class SocketSslEchoTest extends SslTest {
|
|||
sh.channel.close().awaitUninterruptibly();
|
||||
ch.channel.close().awaitUninterruptibly();
|
||||
sc.close().awaitUninterruptibly();
|
||||
delegatedTaskExecutor.shutdown();
|
||||
|
||||
if (sh.exception.get() != null && !(sh.exception.get() instanceof IOException)) {
|
||||
throw sh.exception.get();
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package org.jboss.netty.util;
|
||||
|
||||
import static junit.framework.Assert.*;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
|
Loading…
Reference in New Issue
Block a user