* Extracted common code from various ChannelConfig implementations to DefaultChannelConfig and DefaultServerChannelConfig
This commit is contained in:
parent
fdd74f252b
commit
cd6fce50bc
|
@ -20,67 +20,92 @@
|
|||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.embedder;
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelConfig;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.socket.SocketChannelConfig;
|
||||
|
||||
/**
|
||||
* The default {@link SocketChannelConfig} implementation.
|
||||
*
|
||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||
* @author Trustin Lee (tlee@redhat.com)
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
*
|
||||
*/
|
||||
class EmbeddedChannelConfig implements ChannelConfig {
|
||||
public class DefaultChannelConfig implements ChannelConfig {
|
||||
|
||||
static final ChannelConfig DEFAULT_INSTANCE =
|
||||
new EmbeddedChannelConfig(HeapChannelBufferFactory.getInstance());
|
||||
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
||||
private volatile int connectTimeoutMillis = 10000; // 10 seconds
|
||||
|
||||
private final ChannelBufferFactory bufferFactory;
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public DefaultChannelConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
EmbeddedChannelConfig(ChannelBufferFactory bufferFactory) {
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e: options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an individual option. You can override this method to support
|
||||
* additional configuration parameters.
|
||||
*/
|
||||
protected boolean setOption(String key, Object value) {
|
||||
if (key.equals("pipelineFactory")) {
|
||||
setPipelineFactory((ChannelPipelineFactory) value);
|
||||
} else if (key.equals("bufferFactory")) {
|
||||
setBufferFactory((ChannelBufferFactory) value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMillis() {
|
||||
return connectTimeoutMillis;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
}
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getWriteTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
// Unused
|
||||
if (connectTimeoutMillis < 0) {
|
||||
throw new IllegalArgumentException("connectTimeoutMillis: " + connectTimeoutMillis);
|
||||
}
|
||||
this.connectTimeoutMillis = connectTimeoutMillis;
|
||||
}
|
||||
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setWriteTimeoutMillis(int writeTimeoutMillis) {
|
||||
// Unused
|
|
@ -1,7 +1,8 @@
|
|||
/*
|
||||
* JBoss, Home of Professional Open Source
|
||||
* Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
|
||||
* by the @authors tag. See the copyright.txt in the distribution for a
|
||||
*
|
||||
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
|
||||
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
|
||||
* full listing of individual contributors.
|
||||
*
|
||||
* This is free software; you can redistribute it and/or modify it
|
||||
|
@ -19,28 +20,32 @@
|
|||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.channel.local;
|
||||
package org.jboss.netty.channel;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelConfig;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.socket.ServerSocketChannelConfig;
|
||||
|
||||
/**
|
||||
* The default {@link ServerSocketChannelConfig} implementation.
|
||||
*
|
||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @author Trustin Lee (tlee@redhat.com)
|
||||
*
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
class LocalChannelConfig implements ChannelConfig {
|
||||
public class DefaultServerChannelConfig implements ChannelConfig {
|
||||
|
||||
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
||||
private volatile ChannelPipelineFactory pipelineFactory;
|
||||
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
||||
|
||||
LocalChannelConfig() {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public DefaultServerChannelConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -65,22 +70,29 @@ class LocalChannelConfig implements ChannelConfig {
|
|||
return true;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return pipelineFactory;
|
||||
}
|
||||
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
if (pipelineFactory == null) {
|
||||
throw new NullPointerException("pipelineFactory");
|
||||
}
|
||||
this.pipelineFactory = pipelineFactory;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
}
|
||||
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
|
@ -34,6 +34,7 @@ import org.jboss.netty.channel.ChannelFactory;
|
|||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.DefaultChannelConfig;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.util.LinkedTransferQueue;
|
||||
|
||||
|
@ -51,17 +52,18 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
|
|||
}
|
||||
};
|
||||
|
||||
private final ChannelConfig config;
|
||||
final AtomicBoolean bound = new AtomicBoolean();
|
||||
final Queue<MessageEvent> writeBuffer = new LinkedTransferQueue<MessageEvent>();
|
||||
|
||||
volatile DefaultLocalChannel pairedChannel;
|
||||
volatile LocalAddress localAddress;
|
||||
volatile LocalAddress remoteAddress;
|
||||
final AtomicBoolean bound = new AtomicBoolean();
|
||||
private final LocalChannelConfig config;
|
||||
final Queue<MessageEvent> writeBuffer = new LinkedTransferQueue<MessageEvent>();
|
||||
|
||||
DefaultLocalChannel(LocalServerChannel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, DefaultLocalChannel pairedChannel) {
|
||||
super(parent, factory, pipeline, sink);
|
||||
this.pairedChannel = pairedChannel;
|
||||
config = new LocalChannelConfig();
|
||||
config = new DefaultChannelConfig();
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jboss.netty.channel.ChannelConfig;
|
|||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.DefaultServerChannelConfig;
|
||||
|
||||
/**
|
||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||
|
@ -38,14 +39,14 @@ import org.jboss.netty.channel.ChannelSink;
|
|||
* @version $Rev$, $Date$
|
||||
*/
|
||||
final class LocalServerChannel extends AbstractServerChannel {
|
||||
final ChannelConfig channelConfig;
|
||||
|
||||
volatile LocalAddress localAddress;
|
||||
final ChannelConfig channelConfig;
|
||||
final AtomicBoolean bound = new AtomicBoolean();
|
||||
volatile LocalAddress localAddress;
|
||||
|
||||
LocalServerChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink) {
|
||||
super(factory, pipeline, sink);
|
||||
channelConfig = new LocalChannelConfig();
|
||||
channelConfig = new DefaultServerChannelConfig();
|
||||
fireChannelOpen(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,13 +24,9 @@ package org.jboss.netty.channel.socket;
|
|||
|
||||
import java.net.ServerSocket;
|
||||
import java.net.SocketException;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.DefaultServerChannelConfig;
|
||||
import org.jboss.netty.util.ConversionUtil;
|
||||
|
||||
/**
|
||||
|
@ -41,12 +37,11 @@ import org.jboss.netty.util.ConversionUtil;
|
|||
*
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public class DefaultServerSocketChannelConfig implements ServerSocketChannelConfig {
|
||||
public class DefaultServerSocketChannelConfig extends DefaultServerChannelConfig
|
||||
implements ServerSocketChannelConfig {
|
||||
|
||||
private final ServerSocket socket;
|
||||
private volatile int backlog;
|
||||
private volatile ChannelPipelineFactory pipelineFactory;
|
||||
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
|
@ -58,27 +53,18 @@ public class DefaultServerSocketChannelConfig implements ServerSocketChannelConf
|
|||
this.socket = socket;
|
||||
}
|
||||
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e: options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an individual option. You can override this method to support
|
||||
* additional configuration parameters.
|
||||
*/
|
||||
@Override
|
||||
protected boolean setOption(String key, Object value) {
|
||||
if (super.setOption(key, value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key.equals("receiveBufferSize")) {
|
||||
setReceiveBufferSize(ConversionUtil.toInt(value));
|
||||
} else if (key.equals("reuseAddress")) {
|
||||
setReuseAddress(ConversionUtil.toBoolean(value));
|
||||
} else if (key.equals("backlog")) {
|
||||
setBacklog(ConversionUtil.toInt(value));
|
||||
} else if (key.equals("pipelineFactory")) {
|
||||
setPipelineFactory((ChannelPipelineFactory) value);
|
||||
} else if (key.equals("bufferFactory")) {
|
||||
setBufferFactory((ChannelBufferFactory) value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -121,29 +107,6 @@ public class DefaultServerSocketChannelConfig implements ServerSocketChannelConf
|
|||
socket.setPerformancePreferences(connectionTime, latency, bandwidth);
|
||||
}
|
||||
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return pipelineFactory;
|
||||
}
|
||||
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
if (pipelineFactory == null) {
|
||||
throw new NullPointerException("pipelineFactory");
|
||||
}
|
||||
this.pipelineFactory = pipelineFactory;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
}
|
||||
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
public int getBacklog() {
|
||||
return backlog;
|
||||
}
|
||||
|
@ -154,22 +117,4 @@ public class DefaultServerSocketChannelConfig implements ServerSocketChannelConf
|
|||
}
|
||||
this.backlog = backlog;
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getWriteTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setWriteTimeoutMillis(int writeTimeoutMillis) {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,9 @@ package org.jboss.netty.channel.socket;
|
|||
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.DefaultChannelConfig;
|
||||
import org.jboss.netty.util.ConversionUtil;
|
||||
|
||||
/**
|
||||
|
@ -42,11 +38,10 @@ import org.jboss.netty.util.ConversionUtil;
|
|||
* @version $Rev$, $Date$
|
||||
*
|
||||
*/
|
||||
public class DefaultSocketChannelConfig implements SocketChannelConfig {
|
||||
public class DefaultSocketChannelConfig extends DefaultChannelConfig
|
||||
implements SocketChannelConfig {
|
||||
|
||||
private final Socket socket;
|
||||
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
||||
private volatile int connectTimeoutMillis = 10000; // 10 seconds
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
|
@ -58,17 +53,12 @@ public class DefaultSocketChannelConfig implements SocketChannelConfig {
|
|||
this.socket = socket;
|
||||
}
|
||||
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e: options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an individual option. You can override this method to support
|
||||
* additional configuration parameters.
|
||||
*/
|
||||
@Override
|
||||
protected boolean setOption(String key, Object value) {
|
||||
if (super.setOption(key, value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key.equals("receiveBufferSize")) {
|
||||
setReceiveBufferSize(ConversionUtil.toInt(value));
|
||||
} else if (key.equals("sendBufferSize")) {
|
||||
|
@ -83,12 +73,6 @@ public class DefaultSocketChannelConfig implements SocketChannelConfig {
|
|||
setSoLinger(ConversionUtil.toInt(value));
|
||||
} else if (key.equals("trafficClass")) {
|
||||
setTrafficClass(ConversionUtil.toInt(value));
|
||||
} else if (key.equals("connectTimeoutMillis")) {
|
||||
setConnectTimeoutMillis(ConversionUtil.toInt(value));
|
||||
} else if (key.equals("pipelineFactory")) {
|
||||
setPipelineFactory((ChannelPipelineFactory) value);
|
||||
} else if (key.equals("bufferFactory")) {
|
||||
setBufferFactory((ChannelBufferFactory) value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -215,44 +199,4 @@ public class DefaultSocketChannelConfig implements SocketChannelConfig {
|
|||
throw new ChannelException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMillis() {
|
||||
return connectTimeoutMillis;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
}
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getWriteTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
if (connectTimeoutMillis < 0) {
|
||||
throw new IllegalArgumentException("connectTimeoutMillis: " + connectTimeoutMillis);
|
||||
}
|
||||
this.connectTimeoutMillis = connectTimeoutMillis;
|
||||
}
|
||||
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setWriteTimeoutMillis(int writeTimeoutMillis) {
|
||||
// Unused
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,9 @@ package org.jboss.netty.channel.socket.http;
|
|||
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.DefaultChannelConfig;
|
||||
import org.jboss.netty.channel.socket.SocketChannelConfig;
|
||||
import org.jboss.netty.util.ConversionUtil;
|
||||
|
||||
|
@ -39,32 +35,19 @@ import org.jboss.netty.util.ConversionUtil;
|
|||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
class HttpTunnelingSocketChannelConfig implements SocketChannelConfig {
|
||||
class HttpTunnelingSocketChannelConfig extends DefaultChannelConfig
|
||||
implements SocketChannelConfig {
|
||||
|
||||
final Socket socket;
|
||||
|
||||
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
||||
|
||||
private volatile int connectTimeoutMillis = 10000; // 10 seconds
|
||||
|
||||
private Integer trafficClass;
|
||||
|
||||
private Boolean tcpNoDelay;
|
||||
|
||||
private Integer soLinger;
|
||||
|
||||
private Integer sendBufferSize;
|
||||
|
||||
private Boolean reuseAddress;
|
||||
|
||||
private Integer receiveBufferSize;
|
||||
|
||||
private Integer connectionTime;
|
||||
|
||||
private Integer latency;
|
||||
|
||||
private Integer bandwidth;
|
||||
|
||||
private Boolean keepAlive;
|
||||
|
||||
/**
|
||||
|
@ -74,51 +57,23 @@ class HttpTunnelingSocketChannelConfig implements SocketChannelConfig {
|
|||
this.socket = socket;
|
||||
}
|
||||
|
||||
public void setOptions(Map<String, Object> options) {
|
||||
for (Entry<String, Object> e : options.entrySet()) {
|
||||
setOption(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an individual option. You can override this method to support
|
||||
* additional configuration parameters.
|
||||
*/
|
||||
@Override
|
||||
protected boolean setOption(String key, Object value) {
|
||||
if (key.equals("receiveBufferSize")) {
|
||||
setReceiveBufferSize(ConversionUtil.toInt(value));
|
||||
}
|
||||
else if (key.equals("sendBufferSize")) {
|
||||
} else if (key.equals("sendBufferSize")) {
|
||||
setSendBufferSize(ConversionUtil.toInt(value));
|
||||
}
|
||||
else if (key.equals("tcpNoDelay")) {
|
||||
} else if (key.equals("tcpNoDelay")) {
|
||||
setTcpNoDelay(ConversionUtil.toBoolean(value));
|
||||
}
|
||||
else if (key.equals("keepAlive")) {
|
||||
} else if (key.equals("keepAlive")) {
|
||||
setKeepAlive(ConversionUtil.toBoolean(value));
|
||||
}
|
||||
else if (key.equals("reuseAddress")) {
|
||||
} else if (key.equals("reuseAddress")) {
|
||||
setReuseAddress(ConversionUtil.toBoolean(value));
|
||||
}
|
||||
else if (key.equals("soLinger")) {
|
||||
} else if (key.equals("soLinger")) {
|
||||
setSoLinger(ConversionUtil.toInt(value));
|
||||
}
|
||||
else if (key.equals("trafficClass")) {
|
||||
} else if (key.equals("trafficClass")) {
|
||||
setTrafficClass(ConversionUtil.toInt(value));
|
||||
}
|
||||
else if (key.equals("writeTimeoutMillis")) {
|
||||
setWriteTimeoutMillis(ConversionUtil.toInt(value));
|
||||
}
|
||||
else if (key.equals("connectTimeoutMillis")) {
|
||||
setConnectTimeoutMillis(ConversionUtil.toInt(value));
|
||||
}
|
||||
else if (key.equals("pipelineFactory")) {
|
||||
setPipelineFactory((ChannelPipelineFactory) value);
|
||||
}
|
||||
else if (key.equals("bufferFactory")) {
|
||||
setBufferFactory((ChannelBufferFactory) value);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -277,77 +232,33 @@ class HttpTunnelingSocketChannelConfig implements SocketChannelConfig {
|
|||
|
||||
}
|
||||
|
||||
public int getConnectTimeoutMillis() {
|
||||
return connectTimeoutMillis;
|
||||
}
|
||||
|
||||
public ChannelBufferFactory getBufferFactory() {
|
||||
return bufferFactory;
|
||||
}
|
||||
|
||||
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
||||
if (bufferFactory == null) {
|
||||
throw new NullPointerException("bufferFactory");
|
||||
}
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
public ChannelPipelineFactory getPipelineFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getWriteTimeoutMillis() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
||||
if (connectTimeoutMillis < 0) {
|
||||
throw new IllegalArgumentException("connectTimeoutMillis: " + connectTimeoutMillis);
|
||||
}
|
||||
this.connectTimeoutMillis = connectTimeoutMillis;
|
||||
}
|
||||
|
||||
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
public void setWriteTimeoutMillis(int writeTimeoutMillis) {
|
||||
// Unused
|
||||
}
|
||||
|
||||
HttpTunnelingSocketChannelConfig copyConfig(Socket socket) {
|
||||
HttpTunnelingSocketChannelConfig config = new HttpTunnelingSocketChannelConfig(socket);
|
||||
config.setConnectTimeoutMillis(connectTimeoutMillis);
|
||||
config.setConnectTimeoutMillis(getConnectTimeoutMillis());
|
||||
if (trafficClass != null) {
|
||||
config.setTrafficClass(trafficClass);
|
||||
}
|
||||
if (tcpNoDelay != null) {
|
||||
config.setTcpNoDelay(tcpNoDelay);
|
||||
}
|
||||
|
||||
if (soLinger != null) {
|
||||
config.setSoLinger(soLinger);
|
||||
}
|
||||
|
||||
if (sendBufferSize != null) {
|
||||
config.setSendBufferSize(sendBufferSize);
|
||||
}
|
||||
|
||||
if (reuseAddress != null) {
|
||||
config.setReuseAddress(reuseAddress);
|
||||
}
|
||||
|
||||
if (receiveBufferSize != null) {
|
||||
config.setReceiveBufferSize(receiveBufferSize);
|
||||
}
|
||||
|
||||
if (keepAlive != null) {
|
||||
config.setKeepAlive(keepAlive);
|
||||
}
|
||||
if (connectionTime != null) {
|
||||
config.setPerformancePreferences(connectionTime, latency, bandwidth);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
|
@ -62,10 +62,8 @@ public abstract class AbstractCodecEmbedder<T> implements CodecEmbedder<T> {
|
|||
}
|
||||
|
||||
protected AbstractCodecEmbedder(ChannelBufferFactory bufferFactory, ChannelHandler... handlers) {
|
||||
pipeline = Channels.pipeline();
|
||||
configurePipeline(handlers);
|
||||
channel = new EmbeddedChannel(bufferFactory, pipeline, sink);
|
||||
fireInitialEvents();
|
||||
this(handlers);
|
||||
getChannel().getConfig().setBufferFactory(bufferFactory);
|
||||
}
|
||||
|
||||
private void fireInitialEvents() {
|
||||
|
|
|
@ -24,11 +24,11 @@ package org.jboss.netty.handler.codec.embedder;
|
|||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.AbstractChannel;
|
||||
import org.jboss.netty.channel.ChannelConfig;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.DefaultChannelConfig;
|
||||
|
||||
/**
|
||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||
|
@ -43,12 +43,7 @@ class EmbeddedChannel extends AbstractChannel {
|
|||
|
||||
EmbeddedChannel(ChannelPipeline pipeline, ChannelSink sink) {
|
||||
super(null, EmbeddedChannelFactory.INSTANCE, pipeline, sink);
|
||||
config = EmbeddedChannelConfig.DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
EmbeddedChannel(ChannelBufferFactory bufferFactory, ChannelPipeline pipeline, ChannelSink sink) {
|
||||
super(null, EmbeddedChannelFactory.INSTANCE, pipeline, sink);
|
||||
config = new EmbeddedChannelConfig(bufferFactory);
|
||||
config = new DefaultChannelConfig();
|
||||
}
|
||||
|
||||
public ChannelConfig getConfig() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user