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/13 16:32:50 UTC

svn commit: r575324 - /mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/

Author: jvermillard
Date: Thu Sep 13 07:32:49 2007
New Revision: 575324

URL: http://svn.apache.org/viewvc?rev=575324&view=rev
Log:
Code formating

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/APRFilterChain.java
    mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRIoProcessor.java
    mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRLibrary.java
    mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRProtocol.java
    mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSession.java
    mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionConfig.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/AbstractAPRSessionConfig.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=575324&r1=575323&r2=575324&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 Thu Sep 13 07:32:49 2007
@@ -33,7 +33,6 @@
 import org.apache.mina.common.TransportMetadata;
 import org.apache.mina.util.NewThreadExecutor;
 import org.apache.tomcat.jni.Address;
-import org.apache.tomcat.jni.Pool;
 import org.apache.tomcat.jni.Socket;
 
 /**
@@ -48,136 +47,133 @@
  */
 public class APRConnector extends AbstractIoConnector {
 
-	/**
-	 * @noinspection StaticNonFinalField
-	 */
-	private static volatile int nextId = 0;
-
-	private final Object lock = new Object();
-
-	private final int id = nextId++;
-
-	// private final String threadName = "APRConnector-" + id;
-	private final int processorCount;
-
-	private final Executor executor;
-
-	private final APRIoProcessor[] ioProcessors;
-
-	private int processorDistributor = 0;
-
-	private APRProtocol protocol;
-	
-	/**
-	 * Create a connector with a single processing thread using a
-	 * NewThreadExecutor
-	 * @param protocol 
-	 *            The needed socket protocol (TCP,UDP,...)
-	 */
-	public APRConnector(APRProtocol protocol) {
-		this(protocol,1, new NewThreadExecutor());
-	}
-
-	/**
-	 * Create a connector with the desired number of processing threads
-	 * 
-	 * @param protocol 
-	 * 			  The needed socket protocol (TCP,UDP,...)
-	 * @param processorCount
-	 *            Number of processing threads
-	 * @param executor
-	 *            Executor to use for launching threads
-	 */
-	public APRConnector(APRProtocol protocol,int processorCount, Executor executor) {
-		super(new DefaultAPRSessionConfig());
-		
-		this.protocol=protocol;
-		
-		// load  the APR library
-		
-		APRLibrary.initialize();
-		
-		if (processorCount < 1) {
-			throw new IllegalArgumentException(
-					"Must have at least one processor");
-		}
-
-		this.executor = executor;
-		this.processorCount = processorCount;
-		ioProcessors = new APRIoProcessor[processorCount];
-
-		for (int i = 0; i < processorCount; i++) {
-			ioProcessors[i] = new APRIoProcessor("APRConnectorIoProcessor-"
-					+ id + "." + i, executor);
-		}
-	}
-
-	@Override
-	protected ConnectFuture doConnect(SocketAddress remoteAddress,
-			SocketAddress localAddress) {
-		boolean success = false;
-		try {
-			InetSocketAddress sockAddr = (InetSocketAddress) remoteAddress;
-			//pool = Pool.create(pool);
-			long inetAddr = 0;
-			inetAddr = Address.info(sockAddr.getHostName(), Socket.APR_INET,
-					sockAddr.getPort(), 0, APRLibrary.getLibrary().getPool());
-
-			// TODO : type of socket need to be configurable
-			long clientSock = Socket.create(Socket.APR_INET,
-					Socket.SOCK_STREAM, protocol.codeProto, APRLibrary.getLibrary().getPool());
-			
-			
-			
-			// FIXME : error checking
-			int ret = Socket.connect(clientSock, inetAddr);
-			System.err.println("Socket.connect : " + ret);
-			if (localAddress != null) {
-				// TODO, check if it's possible to bind to a local address
-			}
-
-			ConnectFuture future = new DefaultConnectFuture();
-			APRSessionImpl session = new APRSessionImpl(this, nextProcessor(),
-					clientSock,sockAddr,(InetSocketAddress)localAddress);
-
-			try {
-				getFilterChainBuilder().buildFilterChain(
-						session.getFilterChain());
-			} catch (Throwable e) {
-				throw (IOException) new IOException(
-						"Failed to create a session.").initCause(e);
-			}
-
-			// Set the ConnectFuture of the specified session, which will be
-			// removed and notified by AbstractIoFilterChain eventually.
-			session.setAttribute(AbstractIoFilterChain.CONNECT_FUTURE, future);
-
-			// Forward the remaining process to the APRIoProcessor.
-			// it's will validate the COnnectFuture when the session is in the poll set
-			session.getIoProcessor().addNew(session);
-			
-			success = true;
-			return future;
-		} catch (Exception e) {
-			return DefaultConnectFuture.newFailedFuture(e);
-		}
-	}
-
-
-	@Override
-	protected IoServiceListenerSupport getListeners() {
-		return super.getListeners();
-	}
-
-	private APRIoProcessor nextProcessor() {
-		if (processorDistributor++ < 0) {
-			processorDistributor = 0;
-		}
-
-		return ioProcessors[processorDistributor % processorCount];
-	}
-
-	public TransportMetadata getTransportMetadata() {
-		return APRSessionImpl.METADATA;
-	}
+    /**
+     * @noinspection StaticNonFinalField
+     */
+    private static volatile int nextId = 0;
+
+    private final int id = nextId++;
+
+    // private final String threadName = "APRConnector-" + id;
+    private final int processorCount;
+
+    private final Executor executor;
+
+    private final APRIoProcessor[] ioProcessors;
+
+    private int processorDistributor = 0;
+
+    private APRProtocol protocol;
+
+    /**
+     * Create a connector with a single processing thread using a
+     * NewThreadExecutor
+     * @param protocol 
+     *            The needed socket protocol (TCP,UDP,...)
+     */
+    public APRConnector(APRProtocol protocol) {
+        this(protocol, 1, new NewThreadExecutor());
+    }
+
+    /**
+     * Create a connector with the desired number of processing threads
+     * 
+     * @param protocol 
+     * 			  The needed socket protocol (TCP,UDP,...)
+     * @param processorCount
+     *            Number of processing threads
+     * @param executor
+     *            Executor to use for launching threads
+     */
+    public APRConnector(APRProtocol protocol, int processorCount,
+            Executor executor) {
+        super(new DefaultAPRSessionConfig());
+
+        this.protocol = protocol;
+
+        // load  the APR library
+
+        APRLibrary.initialize();
+
+        if (processorCount < 1) {
+            throw new IllegalArgumentException(
+                    "Must have at least one processor");
+        }
+
+        this.executor = executor;
+        this.processorCount = processorCount;
+        ioProcessors = new APRIoProcessor[processorCount];
+
+        for (int i = 0; i < processorCount; i++) {
+            ioProcessors[i] = new APRIoProcessor("APRConnectorIoProcessor-"
+                    + id + "." + i, executor);
+        }
+    }
+
+    @Override
+    protected ConnectFuture doConnect(SocketAddress remoteAddress,
+            SocketAddress localAddress) {
+        boolean success = false;
+        try {
+            InetSocketAddress sockAddr = (InetSocketAddress) remoteAddress;
+            //pool = Pool.create(pool);
+            long inetAddr = 0;
+            inetAddr = Address.info(sockAddr.getHostName(), Socket.APR_INET,
+                    sockAddr.getPort(), 0, APRLibrary.getLibrary().getPool());
+
+            // TODO : type of socket need to be configurable
+            long clientSock = Socket.create(Socket.APR_INET,
+                    Socket.SOCK_STREAM, protocol.codeProto, APRLibrary
+                            .getLibrary().getPool());
+
+            // FIXME : error checking
+            int ret = Socket.connect(clientSock, inetAddr);
+            System.err.println("Socket.connect : " + ret);
+            if (localAddress != null) {
+                // TODO, check if it's possible to bind to a local address
+            }
+
+            ConnectFuture future = new DefaultConnectFuture();
+            APRSessionImpl session = new APRSessionImpl(this, nextProcessor(),
+                    clientSock, sockAddr, (InetSocketAddress) localAddress);
+
+            try {
+                getFilterChainBuilder().buildFilterChain(
+                        session.getFilterChain());
+            } catch (Throwable e) {
+                throw (IOException) new IOException(
+                        "Failed to create a session.").initCause(e);
+            }
+
+            // Set the ConnectFuture of the specified session, which will be
+            // removed and notified by AbstractIoFilterChain eventually.
+            session.setAttribute(AbstractIoFilterChain.CONNECT_FUTURE, future);
+
+            // Forward the remaining process to the APRIoProcessor.
+            // it's will validate the COnnectFuture when the session is in the poll set
+            session.getIoProcessor().addNew(session);
+
+            success = true;
+            return future;
+        } catch (Exception e) {
+            return DefaultConnectFuture.newFailedFuture(e);
+        }
+    }
+
+    @Override
+    protected IoServiceListenerSupport getListeners() {
+        return super.getListeners();
+    }
+
+    private APRIoProcessor nextProcessor() {
+        if (processorDistributor++ < 0) {
+            processorDistributor = 0;
+        }
+
+        return ioProcessors[processorDistributor % processorCount];
+    }
+
+    public TransportMetadata getTransportMetadata() {
+        return APRSessionImpl.METADATA;
+    }
 }

Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRFilterChain.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRFilterChain.java?rev=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRFilterChain.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRFilterChain.java Thu Sep 13 07:32:49 2007
@@ -24,7 +24,6 @@
 
 import org.apache.mina.common.AbstractIoFilterChain;
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoService;
 import org.apache.mina.common.IoSession;
@@ -38,32 +37,32 @@
  */
 class APRFilterChain extends AbstractIoFilterChain {
 
-	APRFilterChain(IoSession parent) {
-		super(parent);
-	}
+    APRFilterChain(IoSession parent) {
+        super(parent);
+    }
 
-	@Override
-	protected void doWrite(IoSession session, WriteRequest writeRequest) {
-		APRSessionImpl s = (APRSessionImpl) session;
-		Queue<WriteRequest> writeRequestQueue = s.getWriteRequestQueue();
+    @Override
+    protected void doWrite(IoSession session, WriteRequest writeRequest) {
+        APRSessionImpl s = (APRSessionImpl) session;
+        Queue<WriteRequest> writeRequestQueue = s.getWriteRequestQueue();
 
-		// SocketIoProcessor.doFlush() will reset it after write is finished
-		// because the buffer will be passed with messageSent event.
-		((ByteBuffer) writeRequest.getMessage()).mark();
-		synchronized (writeRequestQueue) {
-			writeRequestQueue.offer(writeRequest);
-			if (writeRequestQueue.size() == 1
-					&& session.getTrafficMask().isWritable()) {
-				// Notify SocketIoProcessor only when writeRequestQueue was
-				// empty.
-				s.getIoProcessor().flush(s);
-			}
-		}
-	}
+        // SocketIoProcessor.doFlush() will reset it after write is finished
+        // because the buffer will be passed with messageSent event.
+        ((ByteBuffer) writeRequest.getMessage()).mark();
+        synchronized (writeRequestQueue) {
+            writeRequestQueue.offer(writeRequest);
+            if (writeRequestQueue.size() == 1
+                    && session.getTrafficMask().isWritable()) {
+                // Notify SocketIoProcessor only when writeRequestQueue was
+                // empty.
+                s.getIoProcessor().flush(s);
+            }
+        }
+    }
 
-	@Override
-	protected void doClose(IoSession session) throws IOException {
-		APRSessionImpl s = (APRSessionImpl) session;
-		s.getIoProcessor().remove(s);
-	}
+    @Override
+    protected void doClose(IoSession session) throws IOException {
+        APRSessionImpl s = (APRSessionImpl) session;
+        s.getIoProcessor().remove(s);
+    }
 }

Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRIoProcessor.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRIoProcessor.java?rev=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRIoProcessor.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRIoProcessor.java Thu Sep 13 07:32:49 2007
@@ -43,6 +43,7 @@
 import org.apache.tomcat.jni.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 /**
  * The class in charge of processing socket level IO events for the {@link APRConnector}
  * 
@@ -52,345 +53,358 @@
 
 class APRIoProcessor {
 
-	private final Logger logger = LoggerFactory.getLogger(getClass());
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+
+    private final Object lock = new Object();
+
+    private final String threadName;
+
+    private final Executor executor;
+
+    private long pool = 0; // memory pool
+
+    private long pollset = 0; // socket poller
+
+    private final Queue<APRSessionImpl> newSessions = new ConcurrentLinkedQueue<APRSessionImpl>();
+
+    private final Queue<APRSessionImpl> removingSessions = new ConcurrentLinkedQueue<APRSessionImpl>();
+
+    private final Queue<APRSessionImpl> trafficControllingSessions = new ConcurrentLinkedQueue<APRSessionImpl>();
+
+    private final Map<Long, APRSessionImpl> managedSessions = new HashMap<Long, APRSessionImpl>();
+
+    private long lastIdleCheckTime = System.currentTimeMillis();
+
+    private int socketCount = 0;
+
+    private Worker worker;
+
+    APRIoProcessor(String threadName, Executor executor) {
+        this.threadName = threadName;
+        this.executor = executor;
+
+        // initialize a memory pool for APR functions
+        pool = Pool.create(APRLibrary.getLibrary().getPool());
+        try {
+
+            // TODO : optimize/parametrize those values
+            pollset = Poll
+                    .create(
+                            32,
+                            pool,
+                            Poll.APR_POLLSET_THREADSAFE /* enable poll thread safeness */,
+                            10000000);
+
+        } catch (Error e) {
+            logger.error("APR Error : " + e.getDescription(), e);
+            // TODO : send that to the good logger
+        }
+    }
+
+    void addNew(APRSessionImpl session) {
+        newSessions.offer(session);
+
+        startupWorker();
+    }
+
+    void remove(APRSessionImpl session) {
+        scheduleRemove(session);
+        startupWorker();
+    }
+
+    private void startupWorker() {
+        synchronized (lock) {
+            if (worker == null) {
+                worker = new Worker();
+                executor.execute(new NamePreservingRunnable(worker));
+            }
+        }
+    }
+
+    void flush(APRSessionImpl session) {
+        // re-add the session to polling with POLLOUT flag 
+        pollOutSession(session);
+    }
+
+    private void scheduleRemove(APRSessionImpl session) {
+        removingSessions.offer(session);
+    }
 
-	private final Object lock = new Object();
+    // TODO : do something with traffic control 
+    private void scheduleTrafficControl(APRSessionImpl session) {
+        trafficControllingSessions.offer(session);
+    }
 
-	private final String threadName;
+    private void doAddNew() {
+        for (;;) {
+            APRSessionImpl session = newSessions.poll();
+
+            if (session == null) {
+                break;
+            }
+
+            // polling the socket for read
+            System.err.println("pollset : " + pollset);
+            System.err.println("Socket : " + session.getAPRSocket());
+            int rv;
+            rv = Poll
+                    .add(pollset, session.getAPRSocket(), Poll.APR_POLLIN/*| Poll.APR_POLLOUT*/);
+            if (rv == Status.APR_SUCCESS) {
+                ((ConnectFuture) session
+                        .getAttribute(AbstractIoFilterChain.CONNECT_FUTURE))
+                        .setSession(session);
+                System.out.println("Added worker to pollset");
+                managedSessions.put(session.getAPRSocket(), session);
+                socketCount++;
+                // AbstractIoFilterChain.CONNECT_FUTURE is cleared inside here
+                // in AbstractIoFilterChain.fireSessionOpened().
+                getServiceListeners(session).fireSessionCreated(session);
+            } else {
+                // FIXME: find a way to bring the real APR error from returned codes
+                session.getFilterChain().fireExceptionCaught(
+                        session,
+                        new RuntimeException("APR Error : "
+                                + Error.strerror(rv)));
+            }
+        }
+    }
 
-	private final Executor executor;
+    private void doRemove() {
+        for (;;) {
+            APRSessionImpl session = removingSessions.poll();
+
+            if (session == null) {
+                break;
+            }
+
+            // remove of the pollset
+            Poll.remove(pollset, session.getAPRSocket());
+
+            // close the socket
+            Socket.close(session.getAPRSocket());
+            clearWriteRequestQueue(session);
+            getServiceListeners(session).fireSessionDestroyed(session);
+        }
+    }
 
-	private long pool = 0; // memory pool
-
-	private long pollset = 0; // socket poller
-
-	private final Queue<APRSessionImpl> newSessions = new ConcurrentLinkedQueue<APRSessionImpl>();
-
-	private final Queue<APRSessionImpl> removingSessions = new ConcurrentLinkedQueue<APRSessionImpl>();
-
-	private final Queue<APRSessionImpl> trafficControllingSessions = new ConcurrentLinkedQueue<APRSessionImpl>();
-
-	private final Map<Long, APRSessionImpl> managedSessions = new HashMap<Long, APRSessionImpl>();
-
-	private long lastIdleCheckTime = System.currentTimeMillis();
-
-	private int socketCount = 0;
-
-	private Worker worker;
-
-	APRIoProcessor(String threadName, Executor executor) {
-		this.threadName = threadName;
-		this.executor = executor;
-
-		// initialize a memory pool for APR functions
-		pool = Pool.create(APRLibrary.getLibrary().getPool());
-		try {
-
-			// TODO : optimize/parametrize those values
-			pollset = Poll.create(32, pool, Poll.APR_POLLSET_THREADSAFE /* enable poll thread safeness */, 10000000);	
-			
-		} catch (Error e) {
-			logger.error("APR Error : " + e.getDescription(), e);
-			// TODO : send that to the good logger
-		}
-	}
-
-	void addNew(APRSessionImpl session) {
-		newSessions.offer(session);
-
-		startupWorker();
-	}
-
-	void remove(APRSessionImpl session) {
-		scheduleRemove(session);
-		startupWorker();
-	}
-
-	private void startupWorker() {
-		synchronized (lock) {
-			if (worker == null) {
-				worker = new Worker();
-				executor.execute(new NamePreservingRunnable(worker));
-			}
-		}
-	}
-
-	void flush(APRSessionImpl session) {
-		// re-add the session to polling with POLLOUT flag 
-		pollOutSession(session);
-	}
-    
-	private void scheduleRemove(APRSessionImpl session) {
-		removingSessions.offer(session);
-	}
-
-	// TODO : do something with traffic control 
-	private void scheduleTrafficControl(APRSessionImpl session) {
-		trafficControllingSessions.offer(session);
-	}
-
-	private void doAddNew() {
-		for (;;) {
-			APRSessionImpl session = newSessions.poll();
-
-			if (session == null) {
-				break;
-			}
-
-			// polling the socket for read
-			System.err.println("pollset : "+pollset);
-			System.err.println("Socket : "+session.getAPRSocket());
-			int rv;
-				rv = Poll.add(pollset, session.getAPRSocket(), Poll.APR_POLLIN/*| Poll.APR_POLLOUT*/);
-			if (rv == Status.APR_SUCCESS) {
-				((ConnectFuture)session.getAttribute(AbstractIoFilterChain.CONNECT_FUTURE)).setSession(session);
-				System.out.println("Added worker to pollset");
-				managedSessions.put(session.getAPRSocket(), session);
-				socketCount++;
-				// AbstractIoFilterChain.CONNECT_FUTURE is cleared inside here
-				// in AbstractIoFilterChain.fireSessionOpened().
-				getServiceListeners(session).fireSessionCreated(session);
-			} else {
-				// FIXME: find a way to bring the real APR error from returned codes
-				session.getFilterChain().fireExceptionCaught(session,
-						new RuntimeException("APR Error : "+Error.strerror(rv)));
-			}
-		}
-	}
-
-	private void doRemove() {
-		for (;;) {
-			APRSessionImpl session = removingSessions.poll();
-
-			if (session == null) {
-				break;
-			}
-
-			// remove of the pollset
-			Poll.remove(pollset, session.getAPRSocket());	
-			
-			// close the socket
-			Socket.close(session.getAPRSocket());
-			clearWriteRequestQueue(session);
-			getServiceListeners(session).fireSessionDestroyed(session);
-		}
-	}
-	
     private void pollOutSession(APRSessionImpl session) {
-	    int rv= Poll.remove(pollset, session.getAPRSocket());
-		if(rv!=Status.APR_SUCCESS) {
-			System.err.println("poll.remove Error : "+Error.strerror(rv));
-		}
-		rv = Poll.add(pollset, session.getAPRSocket(),Poll.APR_POLLIN | Poll.APR_POLLOUT);
-		if (rv == Status.APR_SUCCESS) {
-			// ok
-		} else {
-			System.err.println("poll.add Error : "+Error.strerror(rv));
-		}
-    }
-
-	private void read(APRSessionImpl session) {
-		byte[] buf = session.getReadBuffer();
-		// FIXME : hardcoded read value for testing
-		int bytes = Socket.recv(session.getAPRSocket(), buf, 0, 1024);
-		if (bytes > 0) {
-			ByteBuffer bbuf = ByteBuffer.allocate(bytes);
-			bbuf.put(buf, 0, bytes);
-			bbuf.flip();
-			session.increaseReadBytes(bytes);
-			session.getFilterChain().fireMessageReceived(session, bbuf);
-		} else if (bytes < 0) {
-			logger.debug("Read {} bytes, scheduling for remove", bytes);
-			scheduleRemove(session);
-		}
-	}
-
-	private void write(APRSessionImpl session) {
-		if (session.getWriteRequestQueue().size() <= 0)
-			return;
-		Queue<WriteRequest> writeRequestQueue = session.getWriteRequestQueue();
-		
-		for (;;) {
-
-			WriteRequest req;
-
-			synchronized (writeRequestQueue) {
-				req = writeRequestQueue.peek();
-			}
-
-			if (req == null) {
-				// remove of write polling
-       			int rv= Poll.remove(pollset, session.getAPRSocket());
-    			if(rv!=Status.APR_SUCCESS) {
-    				System.err.println("poll.remove Error : "+Error.strerror(rv));
-    			}
-    			rv = Poll.add(pollset, session.getAPRSocket(),Poll.APR_POLLIN);
-    			if (rv == Status.APR_SUCCESS) {
-    				// ok
-    			} else {
-    				System.err.println("poll.add Error : "+Error.strerror(rv));
-    			}
-				break;
-			}
-
-			ByteBuffer buf = (ByteBuffer) req.getMessage();
-			if (buf.remaining() == 0) {
-				synchronized (writeRequestQueue) {
-					writeRequestQueue.poll();
-				}
-				session.increaseWrittenMessages();
-				buf.reset();
-				session.getFilterChain().fireMessageSent(session, req);
-				continue;
-			}
-			// be sure APR_SO_NONBLOCK was set, or it will block
-			int toWrite = buf.remaining();
-			
-			int writtenBytes;
-			// APR accept ByteBuffer, only if they are Direct ones, due to native code
-			if(buf.isDirect()) {
-				writtenBytes = Socket.sendb(session.getAPRSocket(), buf.buf(),
-						0, toWrite);
-			} else {
-				writtenBytes = Socket.send(session.getAPRSocket(), buf.array(),
-						0, toWrite);
-				// FIXME : kludgy ?
-				buf.position(buf.position()+writtenBytes);
-			}
-			if (writtenBytes > 0) {
-				// increase
-				
-				session.increaseWrittenBytes(writtenBytes);
-			} else {
-				// FIXME : send the exception
-				System.err.println(Error.strerror(writtenBytes*-1));
-			}
-
-			// kernel buffer full for this socket, wait next polling
-			if (buf.hasRemaining())
-				break;
-		}
-	}
-
-	private void clearWriteRequestQueue(APRSessionImpl session) {
-		Queue<WriteRequest> writeRequestQueue = session.getWriteRequestQueue();
-		WriteRequest req;
-
-		while ((req = writeRequestQueue.poll()) != null) {
-			req.getFuture().setWritten(false);
-		}
-	}
-
-	private void notifyIdleness() {
-		// process idle sessions
-		long currentTime = System.currentTimeMillis();
-		if ((currentTime - lastIdleCheckTime) >= 1000) {
-			lastIdleCheckTime = currentTime;
-			for (APRSessionImpl session : managedSessions.values()) {
-				notifyIdleness(session, currentTime);
-			}
-		}
-	}
-
-	private void notifyIdleness(APRSessionImpl session, long currentTime) {
-		notifyIdleness0(session, currentTime, session.getConfig()
-				.getIdleTimeInMillis(IdleStatus.BOTH_IDLE),
-				IdleStatus.BOTH_IDLE, Math.max(session.getLastIoTime(), session
-						.getLastIdleTime(IdleStatus.BOTH_IDLE)));
-		notifyIdleness0(session, currentTime, session.getConfig()
-				.getIdleTimeInMillis(IdleStatus.READER_IDLE),
-				IdleStatus.READER_IDLE, Math.max(session.getLastReadTime(),
-						session.getLastIdleTime(IdleStatus.READER_IDLE)));
-		notifyIdleness0(session, currentTime, session.getConfig()
-				.getIdleTimeInMillis(IdleStatus.WRITER_IDLE),
-				IdleStatus.WRITER_IDLE, Math.max(session.getLastWriteTime(),
-						session.getLastIdleTime(IdleStatus.WRITER_IDLE)));
-
-		notifyWriteTimeout(session, currentTime, session.getConfig()
-				.getWriteTimeoutInMillis(), session.getLastWriteTime());
-	}
-
-	private void notifyIdleness0(APRSessionImpl session, long currentTime,
-			long idleTime, IdleStatus status, long lastIoTime) {
-		if (idleTime > 0 && lastIoTime != 0
-				&& (currentTime - lastIoTime) >= idleTime) {
-			session.increaseIdleCount(status);
-			session.getFilterChain().fireSessionIdle(session, status);
-		}
-	}
-
-	private void notifyWriteTimeout(APRSessionImpl session, long currentTime,
-			long writeTimeout, long lastIoTime) {
-		// TODO : I understand nothing here :)
-	}
-
-	private IoServiceListenerSupport getServiceListeners(IoSession session) {
-		IoService service = session.getService();
-		if (service instanceof APRConnector) {
-			return ((APRConnector) service).getListeners();
-		} else
-			return null;
-	}
-
-	private class Worker implements Runnable {
-		public void run() {
-			Thread.currentThread().setName(APRIoProcessor.this.threadName);
-
-			for (;;) {
-
-				try {
-
-					// pop new sessions
-					doAddNew();
-
-					if (socketCount < 1) {
-						return; // no need to poll an empty pollset
-					}
-
-					// TODO : doUpdateTrafficMask();
-
-					/* is it OK ? : Two times size of the created pollset */
-					long[] desc = new long[socketCount * 2];
-
-					/* use 100 milliseconds poll timeout, TODO : parameterize for more latency/CPU usage control*/
-					int rv = Poll.poll(pollset, 100000, desc, false);
-					if (rv > 0) {
-						for (int n = 0; n < rv; n++) {
-							long clientSock = desc[n * 2 + 1];
-
-							APRSessionImpl session = managedSessions
-									.get(clientSock);
-
-							if (!session.isConnected()) {
-								clearWriteRequestQueue(session);
-								continue;
-							}
-
-							if ( (desc[n * 2] & Poll.APR_POLLIN) >0 )
-								read(session);
-							if ( (desc[n * 2] & Poll.APR_POLLOUT) >0 )
-								write(session);
-						}
-					}
-				//	doFlush();
-					notifyIdleness();
-					doRemove();
-				} catch (Throwable t) {
-					ExceptionMonitor.getInstance().exceptionCaught(t);
-
-					try {
-						Thread.sleep(1000);
-					} catch (InterruptedException e1) {
-						ExceptionMonitor.getInstance().exceptionCaught(e1);
-					}
-				}
-			}
-		}
-	}
-	
-	@Override
-	protected void finalize() throws Throwable {
-		// TODO : necessary I think, need to check APR doc
-		Pool.clear(pool);
-	}
+        int rv = Poll.remove(pollset, session.getAPRSocket());
+        if (rv != Status.APR_SUCCESS) {
+            System.err.println("poll.remove Error : " + Error.strerror(rv));
+        }
+        rv = Poll.add(pollset, session.getAPRSocket(), Poll.APR_POLLIN
+                | Poll.APR_POLLOUT);
+        if (rv == Status.APR_SUCCESS) {
+            // ok
+        } else {
+            System.err.println("poll.add Error : " + Error.strerror(rv));
+        }
+    }
+
+    private void read(APRSessionImpl session) {
+        byte[] buf = session.getReadBuffer();
+        // FIXME : hardcoded read value for testing
+        int bytes = Socket.recv(session.getAPRSocket(), buf, 0, 1024);
+        if (bytes > 0) {
+            ByteBuffer bbuf = ByteBuffer.allocate(bytes);
+            bbuf.put(buf, 0, bytes);
+            bbuf.flip();
+            session.increaseReadBytes(bytes);
+            session.getFilterChain().fireMessageReceived(session, bbuf);
+        } else if (bytes < 0) {
+            logger.debug("Read {} bytes, scheduling for remove", bytes);
+            scheduleRemove(session);
+        }
+    }
+
+    private void write(APRSessionImpl session) {
+        if (session.getWriteRequestQueue().size() <= 0)
+            return;
+        Queue<WriteRequest> writeRequestQueue = session.getWriteRequestQueue();
+
+        for (;;) {
+
+            WriteRequest req;
+
+            synchronized (writeRequestQueue) {
+                req = writeRequestQueue.peek();
+            }
+
+            if (req == null) {
+                // remove of write polling
+                int rv = Poll.remove(pollset, session.getAPRSocket());
+                if (rv != Status.APR_SUCCESS) {
+                    System.err.println("poll.remove Error : "
+                            + Error.strerror(rv));
+                }
+                rv = Poll.add(pollset, session.getAPRSocket(), Poll.APR_POLLIN);
+                if (rv == Status.APR_SUCCESS) {
+                    // ok
+                } else {
+                    System.err
+                            .println("poll.add Error : " + Error.strerror(rv));
+                }
+                break;
+            }
+
+            ByteBuffer buf = (ByteBuffer) req.getMessage();
+            if (buf.remaining() == 0) {
+                synchronized (writeRequestQueue) {
+                    writeRequestQueue.poll();
+                }
+                session.increaseWrittenMessages();
+                buf.reset();
+                session.getFilterChain().fireMessageSent(session, req);
+                continue;
+            }
+            // be sure APR_SO_NONBLOCK was set, or it will block
+            int toWrite = buf.remaining();
+
+            int writtenBytes;
+            // APR accept ByteBuffer, only if they are Direct ones, due to native code
+            if (buf.isDirect()) {
+                writtenBytes = Socket.sendb(session.getAPRSocket(), buf.buf(),
+                        0, toWrite);
+            } else {
+                writtenBytes = Socket.send(session.getAPRSocket(), buf.array(),
+                        0, toWrite);
+                // FIXME : kludgy ?
+                buf.position(buf.position() + writtenBytes);
+            }
+            if (writtenBytes > 0) {
+                // increase
+
+                session.increaseWrittenBytes(writtenBytes);
+            } else {
+                // FIXME : send the exception
+                System.err.println(Error.strerror(writtenBytes * -1));
+            }
+
+            // kernel buffer full for this socket, wait next polling
+            if (buf.hasRemaining())
+                break;
+        }
+    }
+
+    private void clearWriteRequestQueue(APRSessionImpl session) {
+        Queue<WriteRequest> writeRequestQueue = session.getWriteRequestQueue();
+        WriteRequest req;
+
+        while ((req = writeRequestQueue.poll()) != null) {
+            req.getFuture().setWritten(false);
+        }
+    }
+
+    private void notifyIdleness() {
+        // process idle sessions
+        long currentTime = System.currentTimeMillis();
+        if ((currentTime - lastIdleCheckTime) >= 1000) {
+            lastIdleCheckTime = currentTime;
+            for (APRSessionImpl session : managedSessions.values()) {
+                notifyIdleness(session, currentTime);
+            }
+        }
+    }
+
+    private void notifyIdleness(APRSessionImpl session, long currentTime) {
+        notifyIdleness0(session, currentTime, session.getConfig()
+                .getIdleTimeInMillis(IdleStatus.BOTH_IDLE),
+                IdleStatus.BOTH_IDLE, Math.max(session.getLastIoTime(), session
+                        .getLastIdleTime(IdleStatus.BOTH_IDLE)));
+        notifyIdleness0(session, currentTime, session.getConfig()
+                .getIdleTimeInMillis(IdleStatus.READER_IDLE),
+                IdleStatus.READER_IDLE, Math.max(session.getLastReadTime(),
+                        session.getLastIdleTime(IdleStatus.READER_IDLE)));
+        notifyIdleness0(session, currentTime, session.getConfig()
+                .getIdleTimeInMillis(IdleStatus.WRITER_IDLE),
+                IdleStatus.WRITER_IDLE, Math.max(session.getLastWriteTime(),
+                        session.getLastIdleTime(IdleStatus.WRITER_IDLE)));
+
+        notifyWriteTimeout(session, currentTime, session.getConfig()
+                .getWriteTimeoutInMillis(), session.getLastWriteTime());
+    }
+
+    private void notifyIdleness0(APRSessionImpl session, long currentTime,
+            long idleTime, IdleStatus status, long lastIoTime) {
+        if (idleTime > 0 && lastIoTime != 0
+                && (currentTime - lastIoTime) >= idleTime) {
+            session.increaseIdleCount(status);
+            session.getFilterChain().fireSessionIdle(session, status);
+        }
+    }
+
+    private void notifyWriteTimeout(APRSessionImpl session, long currentTime,
+            long writeTimeout, long lastIoTime) {
+        // TODO : I understand nothing here :)
+    }
+
+    private IoServiceListenerSupport getServiceListeners(IoSession session) {
+        IoService service = session.getService();
+        if (service instanceof APRConnector) {
+            return ((APRConnector) service).getListeners();
+        } else
+            return null;
+    }
+
+    private class Worker implements Runnable {
+        public void run() {
+            Thread.currentThread().setName(APRIoProcessor.this.threadName);
+
+            for (;;) {
+
+                try {
+
+                    // pop new sessions
+                    doAddNew();
+
+                    if (socketCount < 1) {
+                        return; // no need to poll an empty pollset
+                    }
+
+                    // TODO : doUpdateTrafficMask();
+
+                    /* is it OK ? : Two times size of the created pollset */
+                    long[] desc = new long[socketCount * 2];
+
+                    /* use 100 milliseconds poll timeout, TODO : parameterize for more latency/CPU usage control*/
+                    int rv = Poll.poll(pollset, 100000, desc, false);
+                    if (rv > 0) {
+                        for (int n = 0; n < rv; n++) {
+                            long clientSock = desc[n * 2 + 1];
+
+                            APRSessionImpl session = managedSessions
+                                    .get(clientSock);
+
+                            if (!session.isConnected()) {
+                                clearWriteRequestQueue(session);
+                                continue;
+                            }
+
+                            if ((desc[n * 2] & Poll.APR_POLLIN) > 0)
+                                read(session);
+                            if ((desc[n * 2] & Poll.APR_POLLOUT) > 0)
+                                write(session);
+                        }
+                    }
+                    //	doFlush();
+                    notifyIdleness();
+                    doRemove();
+                } catch (Throwable t) {
+                    ExceptionMonitor.getInstance().exceptionCaught(t);
+
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException e1) {
+                        ExceptionMonitor.getInstance().exceptionCaught(e1);
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        // TODO : necessary I think, need to check APR doc
+        Pool.clear(pool);
+    }
 }

Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRLibrary.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRLibrary.java?rev=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRLibrary.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRLibrary.java Thu Sep 13 07:32:49 2007
@@ -32,46 +32,44 @@
  * @version $Rev:  $, $Date:  $
  */
 class APRLibrary {
-	
-	// is APR library was initialized (load of native libraries)
-	private static APRLibrary library=null;
-	
-	
-	static synchronized APRLibrary getLibrary() {
-		if(!isInitialized())
-			initialize();
-		return library; 
-	}
-
-	static synchronized void initialize() {
-		if(library==null)
-			library=new APRLibrary();
-	}
-	
-	static synchronized boolean isInitialized() {
-		return library!=null;
-	}
-	
-	
-	
-	// APR memory pool (package wide mother pool)	
-	private long pool = -1;
-	
-	private APRLibrary() {
-		try {
-			Library.initialize(null);
-		} catch (Exception e) {
-			throw new RuntimeException("Error loading Apache Portable Runtime (APR)",e);
-		}
-		pool = Pool.create(0);		
-	}
-	
-	protected void finalize() throws Throwable {
-		//		 TODO : necessary I think, need to check APR doc
-		Pool.clear(pool);
-	}
-	
-	public long getPool() {
-		return pool;
-	}
+
+    // is APR library was initialized (load of native libraries)
+    private static APRLibrary library = null;
+
+    static synchronized APRLibrary getLibrary() {
+        if (!isInitialized())
+            initialize();
+        return library;
+    }
+
+    static synchronized void initialize() {
+        if (library == null)
+            library = new APRLibrary();
+    }
+
+    static synchronized boolean isInitialized() {
+        return library != null;
+    }
+
+    // APR memory pool (package wide mother pool)	
+    private long pool = -1;
+
+    private APRLibrary() {
+        try {
+            Library.initialize(null);
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Error loading Apache Portable Runtime (APR)", e);
+        }
+        pool = Pool.create(0);
+    }
+
+    protected void finalize() throws Throwable {
+        //		 TODO : necessary I think, need to check APR doc
+        Pool.clear(pool);
+    }
+
+    public long getPool() {
+        return pool;
+    }
 }

Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRProtocol.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRProtocol.java?rev=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRProtocol.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRProtocol.java Thu Sep 13 07:32:49 2007
@@ -28,12 +28,13 @@
  * @version $Rev:  $, $Date:  $
  */
 public enum APRProtocol {
-	TCP(Socket.APR_PROTO_TCP),
-	UDP(Socket.APR_PROTO_UDP),
-	SCTP(Socket.APR_PROTO_SCTP);
-	
-	int codeProto;
+    TCP(Socket.APR_PROTO_TCP), 
+    UDP(Socket.APR_PROTO_UDP),
+    SCTP(Socket.APR_PROTO_SCTP);
+
+    int codeProto;
+
     private APRProtocol(int codeProto) {
-        this.codeProto=codeProto;
+        this.codeProto = codeProto;
     }
 }

Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSession.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSession.java?rev=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSession.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSession.java Thu Sep 13 07:32:49 2007
@@ -30,11 +30,11 @@
  * @version $Rev:  $, $Date:  $
  */
 public interface APRSession extends IoSession {
-	APRSessionConfig getConfig();
+    APRSessionConfig getConfig();
 
-	InetSocketAddress getRemoteAddress();
+    InetSocketAddress getRemoteAddress();
 
-	InetSocketAddress getLocalAddress();
+    InetSocketAddress getLocalAddress();
 
-	InetSocketAddress getServiceAddress();
+    InetSocketAddress getServiceAddress();
 }

Modified: mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionConfig.java?rev=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionConfig.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/APRSessionConfig.java Thu Sep 13 07:32:49 2007
@@ -31,7 +31,7 @@
  * @version $Rev:  $, $Date:  $
  */
 public interface APRSessionConfig extends IoSessionConfig {
-	
+
     /**
      * @see Socket#getReuseAddress()
      */

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=575324&r1=575323&r2=575324&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 Thu Sep 13 07:32:49 2007
@@ -44,212 +44,215 @@
  * @version $Rev:  $, $Date:  $
  */
 class APRSessionImpl extends AbstractIoSession implements APRSession {
-	private long socket;
+    private long socket;
 
-	private final IoService service;
+    private final IoService service;
 
-	private final APRSessionConfig config = new APRSessionConfigImpl();
+    private final APRSessionConfig config = new APRSessionConfigImpl();
 
-	private final APRIoProcessor ioProcessor;
+    private final APRIoProcessor ioProcessor;
 
-	private final APRFilterChain filterChain;
+    private final APRFilterChain filterChain;
 
-	private final Queue<WriteRequest> writeRequestQueue;
+    private final Queue<WriteRequest> writeRequestQueue;
 
-	private final IoHandler handler;
+    private final IoHandler handler;
 
-	private byte[] readBuffer=new byte[1024]; //FIXME : fixed rcvd buffer, need to change that to a config value
+    private byte[] readBuffer = new byte[1024]; //FIXME : fixed rcvd buffer, need to change that to a config value
 
-	private final InetSocketAddress remoteAddress;
+    private final InetSocketAddress remoteAddress;
 
-	private final InetSocketAddress localAddress;
-	
-	static final TransportMetadata METADATA = new DefaultTransportMetadata("Apache Portable Runtime socket", false,true,InetSocketAddress.class, APRSessionConfig.class, ByteBuffer.class);
+    private final InetSocketAddress localAddress;
 
-	/**
-	 * Creates a new instance.
-	 */
-	APRSessionImpl(IoService service, APRIoProcessor ioProcessor, long socket,
-			InetSocketAddress remoteAddress, InetSocketAddress localAddress) {
-		this.service = service;
-		this.ioProcessor = ioProcessor;
-		this.filterChain = new APRFilterChain(this);
-		this.writeRequestQueue = new LinkedList<WriteRequest>();
-		this.handler = service.getHandler();
-		this.remoteAddress = remoteAddress;
-		this.localAddress = localAddress;
-		this.socket=socket;
-	}
+    static final TransportMetadata METADATA = new DefaultTransportMetadata(
+            "Apache Portable Runtime socket", false, true,
+            InetSocketAddress.class, APRSessionConfig.class, ByteBuffer.class);
 
-	long getAPRSocket() {
-		return socket;
-	}
+    /**
+     * Creates a new instance.
+     */
+    APRSessionImpl(IoService service, APRIoProcessor ioProcessor, long socket,
+            InetSocketAddress remoteAddress, InetSocketAddress localAddress) {
+        this.service = service;
+        this.ioProcessor = ioProcessor;
+        this.filterChain = new APRFilterChain(this);
+        this.writeRequestQueue = new LinkedList<WriteRequest>();
+        this.handler = service.getHandler();
+        this.remoteAddress = remoteAddress;
+        this.localAddress = localAddress;
+        this.socket = socket;
+    }
 
-	@Override
-	protected void updateTrafficMask() {
-		// TODO : this.ioProcessor.updateTrafficMask( this );
-	}
+    long getAPRSocket() {
+        return socket;
+    }
 
-	public APRSessionConfig getConfig() {
-		return config;
-	}
+    @Override
+    protected void updateTrafficMask() {
+        // TODO : this.ioProcessor.updateTrafficMask( this );
+    }
 
-	public InetSocketAddress getLocalAddress() {
-		return localAddress;
-	}
+    public APRSessionConfig getConfig() {
+        return config;
+    }
 
-	byte[] getReadBuffer() {
-		return readBuffer;
-	}
+    public InetSocketAddress getLocalAddress() {
+        return localAddress;
+    }
 
-	public InetSocketAddress getRemoteAddress() {
-		return remoteAddress;
-	}
+    byte[] getReadBuffer() {
+        return readBuffer;
+    }
 
-	Queue<WriteRequest> getWriteRequestQueue() {
-		return writeRequestQueue;
-	}
+    public InetSocketAddress getRemoteAddress() {
+        return remoteAddress;
+    }
 
-	public IoFilterChain getFilterChain() {
+    Queue<WriteRequest> getWriteRequestQueue() {
+        return writeRequestQueue;
+    }
+
+    public IoFilterChain getFilterChain() {
 
-		return filterChain;
-	}
+        return filterChain;
+    }
 
-	public IoHandler getHandler() {
-		return handler;
-	}
+    public IoHandler getHandler() {
+        return handler;
+    }
 
-	public int getScheduledWriteMessages() {
-		synchronized (writeRequestQueue) {
-			return writeRequestQueue.size();
-		}
-	}
+    public int getScheduledWriteMessages() {
+        synchronized (writeRequestQueue) {
+            return writeRequestQueue.size();
+        }
+    }
 
     protected void write0(WriteRequest writeRequest) {
         filterChain.fireFilterWrite(this, writeRequest);
     }
 
-	public long getScheduledWriteBytes() {
-		int size = 0;
-		synchronized (writeRequestQueue) {
-			for (Object o : writeRequestQueue) {
-				if (o instanceof ByteBuffer) {
-					size += ((ByteBuffer) o).remaining();
-				}
-			}
-		}
-
-		return size;
-	}
-
-	public IoService getService() {
-		return service;
-	}
-	
-	APRIoProcessor getIoProcessor() {
-		return ioProcessor;
-	}
-
-	@Override
-	public InetSocketAddress getServiceAddress() {
-		return (InetSocketAddress) super.getServiceAddress();
-	}
-
-	public TransportMetadata getTransportMetadata() {
-		return METADATA;
-	}
-	
-	private class APRSessionConfigImpl extends AbstractAPRSessionConfig implements APRSessionConfig {
-		
+    public long getScheduledWriteBytes() {
+        int size = 0;
+        synchronized (writeRequestQueue) {
+            for (Object o : writeRequestQueue) {
+                if (o instanceof ByteBuffer) {
+                    size += ((ByteBuffer) o).remaining();
+                }
+            }
+        }
+
+        return size;
+    }
+
+    public IoService getService() {
+        return service;
+    }
+
+    APRIoProcessor getIoProcessor() {
+        return ioProcessor;
+    }
+
+    @Override
+    public InetSocketAddress getServiceAddress() {
+        return (InetSocketAddress) super.getServiceAddress();
+    }
+
+    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);
-        	}
+            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);
+            Socket.optSet(getAPRSocket(), Socket.APR_SO_KEEPALIVE, on ? 1 : 0);
         }
 
         public boolean isOobInline() {
-        	return Socket.atmark(getAPRSocket());
+            return Socket.atmark(getAPRSocket());
         }
 
         public void setOobInline(boolean on) {
-        	// TODO : where the f***k it's in APR ?
-        	throw new UnsupportedOperationException("Not implemented");
+            // TODO : where the f***k it's in APR ?
+            throw new UnsupportedOperationException("Not implemented");
         }
 
         public boolean isReuseAddress() {
-        	try {
-        		return Socket.optGet(getAPRSocket(), Socket.APR_SO_REUSEADDR)==1;
-        	} catch(Exception e) {
-        		throw new RuntimeException("APR Exception",e);
-        	}
+            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);
+            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);
-        	}
+            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);
+            // 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);
-        	}
+            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);
+            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");
+            // TODO : find how to do that with APR
+            throw new UnsupportedOperationException("Not implemented");
         }
 
         public void setTrafficClass(int tc) {
-        	throw new UnsupportedOperationException("Not implemented");
+            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);
-        	}
+            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);
+            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);
-        	}
+            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);
+            Socket.optSet(getAPRSocket(), Socket.APR_SO_RCVBUF, size);
         }
 
     }

Modified: 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=575324&r1=575323&r2=575324&view=diff
==============================================================================
--- mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java (original)
+++ mina/sandbox/jvermillard/apr/src/main/java/org/apache/mina/transport/apr/AbstractAPRSessionConfig.java Thu Sep 13 07:32:49 2007
@@ -29,27 +29,28 @@
  * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev:  $, $Date:  $
  */
-abstract class AbstractAPRSessionConfig extends AbstractIoSessionConfig implements APRSessionConfig {
+abstract class AbstractAPRSessionConfig extends AbstractIoSessionConfig
+        implements APRSessionConfig {
 
-	public AbstractAPRSessionConfig() {
-		super();
-	}
+    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());
-	        }
-	    }
-	}
+    @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());
+            }
+        }
+    }
 
 }

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=575324&r1=575323&r2=575324&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 Thu Sep 13 07:32:49 2007
@@ -21,16 +21,16 @@
 
 import org.apache.mina.common.IoSession;
 
-
 /**
  * Default configuration for {@link APRSession}
  * 
  * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev:  $, $Date:  $
  */
-class DefaultAPRSessionConfig extends AbstractAPRSessionConfig implements APRSessionConfig {
-    
-	private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
+class DefaultAPRSessionConfig extends AbstractAPRSessionConfig implements
+        APRSessionConfig {
+
+    private static boolean SET_RECEIVE_BUFFER_SIZE_AVAILABLE = false;
 
     private static boolean SET_SEND_BUFFER_SIZE_AVAILABLE = false;