From 377065fae7d4977899ea9c922c20e45c8bab3769 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Tue, 31 Jul 2012 13:51:19 +0200 Subject: interims changes --- jetty-io/pom.xml | 10 +++++ .../java/org/eclipse/jetty/io/WriteFlusher.java | 47 ++++++++++++++++++++++ .../org/eclipse/jetty/io/WriteFlusherTest.java | 18 +++++++++ 3 files changed, 75 insertions(+) create mode 100644 jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusherTest.java diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index fb0997f6e0..76dde2062b 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -21,6 +21,16 @@ jetty-test-helper test + + org.mockito + mockito-core + test + + + junit + junit + test + diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java index 30f7275f1d..868846ce64 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java @@ -36,6 +36,53 @@ abstract public class WriteFlusher _endp=endp; } + private enum State + { + IDLE, + WRITING, + CLOSED + } + + private abstract class WriteFlusherState + { + private State _state; + private ByteBuffer[] _buffers; + private Object _context; + private Callback _callback; + + private WriteFlusherState(State state, ByteBuffer[] buffers, Object context, Callback callback) + { + _state = state; + _buffers = buffers; + _context = context; + _callback = callback; + } + } + + private class WriteFlusherIdleState extends WriteFlusherState + { + private WriteFlusherIdleState() + { + super(null,null,null,null); + } + } + + private class WriteFlusherWritingState extends WriteFlusherState + { + private WriteFlusherWritingState(State state, ByteBuffer[] buffers, Object context, Callback callback) + { + super(state, buffers, context, callback); + } + } + + private class WriteFlusherClosingState extends WriteFlusherState + { + private WriteFlusherClosingState() + { + super(null,null,null,null); + } + } + /* ------------------------------------------------------------ */ public synchronized void write(C context, Callback callback, ByteBuffer... buffers) { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusherTest.java b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusherTest.java new file mode 100644 index 0000000000..e49693d700 --- /dev/null +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusherTest.java @@ -0,0 +1,18 @@ +//======================================================================== +//Copyright 2012 Mort Bay Consulting Pty. Ltd. +//------------------------------------------------------------------------ +//All rights reserved. This program and the accompanying materials +//are made available under the terms of the Eclipse Public License v1.0 +//and Apache License v2.0 which accompanies this distribution. +//The Eclipse Public License is available at +//http://www.eclipse.org/legal/epl-v10.html +//The Apache License v2.0 is available at +//http://www.opensource.org/licenses/apache2.0.php +//You may elect to redistribute this code under either of these licenses. +//======================================================================== +package org.eclipse.jetty.io; + +@RunWith(Mockit) +public class WriteFlusherTest +{ +} -- cgit v1.2.3