2009-02-09 01:31:50 +00:00
|
|
|
/*
|
|
|
|
* JBoss, Home of Professional Open Source
|
2009-02-21 19:08:08 +00:00
|
|
|
*
|
|
|
|
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
|
|
|
|
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
|
2009-02-09 01:31:50 +00:00
|
|
|
* full listing of individual contributors.
|
|
|
|
*
|
|
|
|
* This is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this software; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
|
|
*/
|
2009-02-21 19:08:08 +00:00
|
|
|
package org.jboss.netty.channel;
|
2009-02-09 01:31:50 +00:00
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
import org.jboss.netty.buffer.ChannelBufferFactory;
|
|
|
|
import org.jboss.netty.buffer.HeapChannelBufferFactory;
|
2009-02-21 19:08:08 +00:00
|
|
|
import org.jboss.netty.channel.socket.SocketChannelConfig;
|
2009-02-09 01:31:50 +00:00
|
|
|
|
|
|
|
/**
|
2009-02-21 19:08:08 +00:00
|
|
|
* The default {@link SocketChannelConfig} implementation.
|
|
|
|
*
|
2009-02-09 08:32:13 +00:00
|
|
|
* @author The Netty Project (netty-dev@lists.jboss.org)
|
2009-02-09 01:31:50 +00:00
|
|
|
* @author Trustin Lee (tlee@redhat.com)
|
2009-02-21 19:08:08 +00:00
|
|
|
*
|
2009-02-09 08:32:13 +00:00
|
|
|
* @version $Rev$, $Date$
|
2009-02-21 19:08:08 +00:00
|
|
|
*
|
2009-02-09 01:31:50 +00:00
|
|
|
*/
|
2009-02-21 19:08:08 +00:00
|
|
|
public class DefaultChannelConfig implements ChannelConfig {
|
2009-02-09 01:31:50 +00:00
|
|
|
|
|
|
|
private volatile ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance();
|
2009-02-21 19:08:08 +00:00
|
|
|
private volatile int connectTimeoutMillis = 10000; // 10 seconds
|
2009-02-09 01:31:50 +00:00
|
|
|
|
2009-02-21 19:08:08 +00:00
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
|
|
|
*/
|
|
|
|
public DefaultChannelConfig() {
|
2009-02-09 05:26:10 +00:00
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2009-02-09 01:31:50 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-02-21 19:08:08 +00:00
|
|
|
public int getConnectTimeoutMillis() {
|
|
|
|
return connectTimeoutMillis;
|
|
|
|
}
|
|
|
|
|
2009-02-09 01:31:50 +00:00
|
|
|
public ChannelBufferFactory getBufferFactory() {
|
|
|
|
return bufferFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBufferFactory(ChannelBufferFactory bufferFactory) {
|
2009-02-21 19:08:08 +00:00
|
|
|
if (bufferFactory == null) {
|
|
|
|
throw new NullPointerException("bufferFactory");
|
|
|
|
}
|
2009-02-09 01:31:50 +00:00
|
|
|
this.bufferFactory = bufferFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ChannelPipelineFactory getPipelineFactory() {
|
2009-02-21 19:08:08 +00:00
|
|
|
return null;
|
2009-02-09 01:31:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 19:08:08 +00:00
|
|
|
@Deprecated
|
|
|
|
public int getWriteTimeoutMillis() {
|
2009-02-09 01:31:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
|
2009-02-21 19:08:08 +00:00
|
|
|
if (connectTimeoutMillis < 0) {
|
|
|
|
throw new IllegalArgumentException("connectTimeoutMillis: " + connectTimeoutMillis);
|
|
|
|
}
|
|
|
|
this.connectTimeoutMillis = connectTimeoutMillis;
|
2009-02-09 01:31:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 19:08:08 +00:00
|
|
|
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
|
|
|
|
// Unused
|
2009-02-09 01:31:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
public void setWriteTimeoutMillis(int writeTimeoutMillis) {
|
|
|
|
// Unused
|
|
|
|
}
|
|
|
|
}
|