You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by jv...@apache.org on 2007/09/12 15:23:50 UTC
svn commit: r574953 - in
/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr:
APRConnector.java APRSessionImpl.java AbstractAPRSessionConfig.java
DefaultAPRSessionConfig.java
Author: jvermillard
Date: Wed Sep 12 06:23:50 2007
New Revision: 574953
URL: http://svn.apache.org/viewvc?rev=574953&view=rev
Log:
APRSession configuration
Added:
mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java
Modified:
mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRConnector.java
mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionImpl.java
mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/DefaultAPRSessionConfig.java
Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRConnector.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRConnector.java?rev=574953&r1=574952&r2=574953&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRConnector.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRConnector.java Wed Sep 12 06:23:50 2007
@@ -90,6 +90,8 @@
long clientSock = Socket.create(Socket.APR_INET,
Socket.SOCK_STREAM, Socket.APR_PROTO_TCP, pool);
+
+
// FIXME : error checking
int ret = Socket.connect(clientSock, inetAddr);
System.err.println("Socket.connect : " + ret);
Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionImpl.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionImpl.java?rev=574953&r1=574952&r2=574953&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionImpl.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionImpl.java Wed Sep 12 06:23:50 2007
@@ -5,20 +5,24 @@
import java.util.Queue;
import org.apache.mina.common.AbstractIoSession;
+import org.apache.mina.common.AbstractIoSessionConfig;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.DefaultTransportMetadata;
import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSessionConfig;
+import org.apache.mina.common.RuntimeIOException;
import org.apache.mina.common.TransportMetadata;
import org.apache.mina.common.WriteRequest;
+import org.apache.tomcat.jni.Socket;
public class APRSessionImpl extends AbstractIoSession implements APRSession {
private long socket;
private final IoService service;
- private final APRSessionConfig config = new DefaultAPRSessionConfig();
+ private final APRSessionConfig config = new APRSessionConfigImpl();
private final APRIoProcessor ioProcessor;
@@ -124,4 +128,99 @@
public TransportMetadata getTransportMetadata() {
return METADATA;
}
+
+ private class APRSessionConfigImpl extends AbstractAPRSessionConfig implements APRSessionConfig {
+
+ public boolean isKeepAlive() {
+ try {
+ return Socket.optGet(getAPRSocket(), Socket.APR_SO_KEEPALIVE)==1;
+ } catch(Exception e) {
+ throw new RuntimeException("APR Exception",e);
+ }
+ }
+
+ public void setKeepAlive(boolean on) {
+ Socket.optSet(getAPRSocket(), Socket.APR_SO_KEEPALIVE, on?1:0);
+ }
+
+ public boolean isOobInline() {
+ return Socket.atmark(getAPRSocket());
+ }
+
+ public void setOobInline(boolean on) {
+ // TODO : where the f***k it's in APR ?
+ throw new RuntimeIOException("Unsupported");
+ }
+
+ public boolean isReuseAddress() {
+ try {
+ return Socket.optGet(getAPRSocket(), Socket.APR_SO_REUSEADDR)==1;
+ } catch(Exception e) {
+ throw new RuntimeException("APR Exception",e);
+ }
+ }
+
+ public void setReuseAddress(boolean on) {
+ Socket.optSet(getAPRSocket(), Socket.APR_SO_REUSEADDR,on?1:0);
+ }
+
+ public int getSoLinger() {
+ try {
+ return Socket.optGet(getAPRSocket(), Socket.APR_SO_LINGER);
+ } catch(Exception e) {
+ throw new RuntimeException("APR Exception",e);
+ }
+ }
+
+ public void setSoLinger(int linger) {
+ // TODO : it's me or APR isn't able to disable linger ?
+ Socket.optSet(getAPRSocket(), Socket.APR_SO_LINGER,linger);
+ }
+
+ public boolean isTcpNoDelay() {
+ try {
+ return Socket.optGet(getAPRSocket(), Socket.APR_TCP_NODELAY)==1;
+ } catch(Exception e) {
+ throw new RuntimeException("APR Exception",e);
+ }
+ }
+
+ public void setTcpNoDelay(boolean on) {
+ Socket.optSet(getAPRSocket(), Socket.APR_TCP_NODELAY,on?1:0);
+ }
+
+ public int getTrafficClass() {
+ // TODO : find how to do that with APR
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void setTrafficClass(int tc) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public int getSendBufferSize() {
+ try {
+ return Socket.optGet(getAPRSocket(), Socket.APR_SO_SNDBUF);
+ } catch(Exception e) {
+ throw new RuntimeException("APR Exception",e);
+ }
+ }
+
+ public void setSendBufferSize(int size) {
+ Socket.optSet(getAPRSocket(), Socket.APR_SO_SNDBUF,size);
+ }
+
+ public int getReceiveBufferSize() {
+ try {
+ return Socket.optGet(getAPRSocket(), Socket.APR_SO_RCVBUF);
+ } catch(Exception e) {
+ throw new RuntimeException("APR Exception",e);
+ }
+ }
+
+ public void setReceiveBufferSize(int size) {
+ Socket.optSet(getAPRSocket(), Socket.APR_SO_RCVBUF,size);
+ }
+
+ }
}
Added: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java?rev=574953&view=auto
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java (added)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java Wed Sep 12 06:23:50 2007
@@ -0,0 +1,29 @@
+package org.apache.mina.transport.apr;
+
+import org.apache.mina.common.AbstractIoSessionConfig;
+import org.apache.mina.common.IoSessionConfig;
+
+public abstract class AbstractAPRSessionConfig extends AbstractIoSessionConfig implements APRSessionConfig {
+
+ public AbstractAPRSessionConfig() {
+ super();
+ }
+
+ @Override
+ protected final void doSetAll(IoSessionConfig config) {
+ if (config instanceof DefaultAPRSessionConfig) {
+ DefaultAPRSessionConfig cfg = (DefaultAPRSessionConfig) config;
+ setKeepAlive(cfg.isKeepAlive());
+ setOobInline(cfg.isOobInline());
+ setReceiveBufferSize(cfg.getReceiveBufferSize());
+ setReuseAddress(cfg.isReuseAddress());
+ setSendBufferSize(cfg.getSendBufferSize());
+ setSoLinger(cfg.getSoLinger());
+ setTcpNoDelay(cfg.isTcpNoDelay());
+ if (getTrafficClass() != cfg.getTrafficClass()) {
+ setTrafficClass(cfg.getTrafficClass());
+ }
+ }
+ }
+
+}
\ No newline at end of file
Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/DefaultAPRSessionConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/DefaultAPRSessionConfig.java?rev=574953&r1=574952&r2=574953&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/DefaultAPRSessionConfig.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/DefaultAPRSessionConfig.java Wed Sep 12 06:23:50 2007
@@ -1,94 +1,115 @@
package org.apache.mina.transport.apr;
-import org.apache.mina.common.AbstractIoSessionConfig;
-import org.apache.mina.common.IoSessionConfig;
-public class DefaultAPRSessionConfig extends AbstractIoSessionConfig implements APRSessionConfig {
+public class DefaultAPRSessionConfig extends AbstractAPRSessionConfig implements APRSessionConfig {
+
+ private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
- public int getReceiveBufferSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getSendBufferSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getSoLinger() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getTrafficClass() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public boolean isKeepAlive() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isOobInline() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isReuseAddress() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isTcpNoDelay() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void setKeepAlive(boolean keepAlive) {
- // TODO Auto-generated method stub
-
- }
-
- public void setOobInline(boolean oobInline) {
- // TODO Auto-generated method stub
-
- }
-
- public void setReceiveBufferSize(int receiveBufferSize) {
- // TODO Auto-generated method stub
-
- }
-
- public void setReuseAddress(boolean reuseAddress) {
- // TODO Auto-generated method stub
-
- }
-
- public void setSendBufferSize(int sendBufferSize) {
- // TODO Auto-generated method stub
-
- }
-
- public void setSoLinger(int soLinger) {
- // TODO Auto-generated method stub
-
- }
-
- public void setTcpNoDelay(boolean tcpNoDelay) {
- // TODO Auto-generated method stub
-
- }
-
- public void setTrafficClass(int trafficClass) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void doSetAll(IoSessionConfig config) {
- // TODO Auto-generated method stub
-
- }
-
+ private static boolean SET_SEND_BUFFER_SIZE_AVAILABLE = false;
+
+ private static boolean GET_TRAFFIC_CLASS_AVAILABLE = false;
+
+ private static boolean SET_TRAFFIC_CLASS_AVAILABLE = false;
+
+ private static boolean DEFAULT_REUSE_ADDRESS = false;
+
+ private static int DEFAULT_RECEIVE_BUFFER_SIZE = 1024;
+
+ private static int DEFAULT_SEND_BUFFER_SIZE = 1024;
+
+ private static int DEFAULT_TRAFFIC_CLASS = 0;
+
+ private static boolean DEFAULT_KEEP_ALIVE = false;
+
+ private static boolean DEFAULT_OOB_INLINE = false;
+
+ private static int DEFAULT_SO_LINGER = -1;
+
+ private static boolean DEFAULT_TCP_NO_DELAY = false;
+
+ private boolean reuseAddress = DEFAULT_REUSE_ADDRESS;
+
+ private int receiveBufferSize = DEFAULT_RECEIVE_BUFFER_SIZE;
+
+ private int sendBufferSize = DEFAULT_SEND_BUFFER_SIZE;
+
+ private int trafficClass = DEFAULT_TRAFFIC_CLASS;
+
+ private boolean keepAlive = DEFAULT_KEEP_ALIVE;
+
+ private boolean oobInline = DEFAULT_OOB_INLINE;
+
+ private int soLinger = DEFAULT_SO_LINGER;
+
+ private boolean tcpNoDelay = DEFAULT_TCP_NO_DELAY;
+
+ /**
+ * Creates a new instance.
+ */
+ DefaultAPRSessionConfig() {
+ }
+
+ public boolean isReuseAddress() {
+ return reuseAddress;
+ }
+
+ public void setReuseAddress(boolean reuseAddress) {
+ this.reuseAddress = reuseAddress;
+ }
+
+ public int getReceiveBufferSize() {
+ return receiveBufferSize;
+ }
+
+ public void setReceiveBufferSize(int receiveBufferSize) {
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
+ public int getSendBufferSize() {
+ return sendBufferSize;
+ }
+
+ public void setSendBufferSize(int sendBufferSize) {
+ this.sendBufferSize = sendBufferSize;
+ }
+
+ public int getTrafficClass() {
+ return trafficClass;
+ }
+
+ public void setTrafficClass(int trafficClass) {
+ this.trafficClass = trafficClass;
+ }
+
+ public boolean isKeepAlive() {
+ return keepAlive;
+ }
+
+ public void setKeepAlive(boolean keepAlive) {
+ this.keepAlive = keepAlive;
+ }
+
+ public boolean isOobInline() {
+ return oobInline;
+ }
+
+ public void setOobInline(boolean oobInline) {
+ this.oobInline = oobInline;
+ }
+
+ public int getSoLinger() {
+ return soLinger;
+ }
+
+ public void setSoLinger(int soLinger) {
+ this.soLinger = soLinger;
+ }
+
+ public boolean isTcpNoDelay() {
+ return tcpNoDelay;
+ }
+
+ public void setTcpNoDelay(boolean tcpNoDelay) {
+ this.tcpNoDelay = tcpNoDelay;
+ }
}