From c2169f2b73b7dad4ca18956c7af423242d4eb17d Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 16 Jun 2009 08:06:00 +0000 Subject: [PATCH] Renamed ChunkStream to ChunkedInput Renamed ChunkStreamWriteHandler to ChunkedWriteHandler Renamed FileChunkStream to ChunkedFile --- ...{FileChunkStream.java => ChunkedFile.java} | 10 +++++----- .../{ChunkStream.java => ChunkedInput.java} | 2 +- ...eHandler.java => ChunkedWriteHandler.java} | 20 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) rename src/main/java/org/jboss/netty/handler/stream/{FileChunkStream.java => ChunkedFile.java} (88%) rename src/main/java/org/jboss/netty/handler/stream/{ChunkStream.java => ChunkedInput.java} (97%) rename src/main/java/org/jboss/netty/handler/stream/{ChunkStreamWriteHandler.java => ChunkedWriteHandler.java} (89%) diff --git a/src/main/java/org/jboss/netty/handler/stream/FileChunkStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java similarity index 88% rename from src/main/java/org/jboss/netty/handler/stream/FileChunkStream.java rename to src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java index 10c658226f..18bf54b580 100644 --- a/src/main/java/org/jboss/netty/handler/stream/FileChunkStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedFile.java @@ -33,7 +33,7 @@ import java.io.RandomAccessFile; * @author Trustin Lee (tlee@redhat.com) * @version $Rev$, $Date$ */ -public class FileChunkStream implements ChunkStream { +public class ChunkedFile implements ChunkedInput { private static final int DEFAULT_CHUNK_SIZE = 8192; @@ -43,19 +43,19 @@ public class FileChunkStream implements ChunkStream { private final int chunkSize; private volatile long offset; - public FileChunkStream(File file) throws IOException { + public ChunkedFile(File file) throws IOException { this(file, DEFAULT_CHUNK_SIZE); } - public FileChunkStream(File file, int chunkSize) throws IOException { + public ChunkedFile(File file, int chunkSize) throws IOException { this(new RandomAccessFile(file, "r"), chunkSize); } - public FileChunkStream(RandomAccessFile file, int chunkSize) throws IOException { + public ChunkedFile(RandomAccessFile file, int chunkSize) throws IOException { this(file, 0, file.length(), chunkSize); } - public FileChunkStream(RandomAccessFile file, long offset, long length, int chunkSize) throws IOException { + public ChunkedFile(RandomAccessFile file, long offset, long length, int chunkSize) throws IOException { if (file == null) { throw new NullPointerException("file"); } diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java similarity index 97% rename from src/main/java/org/jboss/netty/handler/stream/ChunkStream.java rename to src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java index 254dc91904..b7fad7edc3 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedInput.java @@ -29,7 +29,7 @@ package org.jboss.netty.handler.stream; * @author Trustin Lee (tlee@redhat.com) * @version $Rev$, $Date$ */ -public interface ChunkStream { +public interface ChunkedInput { boolean available() throws Exception; Object readChunk() throws Exception; void close() throws Exception; diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkStreamWriteHandler.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java similarity index 89% rename from src/main/java/org/jboss/netty/handler/stream/ChunkStreamWriteHandler.java rename to src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java index b4f37392c1..ed4d94f644 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkStreamWriteHandler.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedWriteHandler.java @@ -48,10 +48,10 @@ import org.jboss.netty.util.internal.LinkedTransferQueue; * @version $Rev$, $Date$ */ @ChannelPipelineCoverage("one") -public class ChunkStreamWriteHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler { +public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler { private static final InternalLogger logger = - InternalLoggerFactory.getInstance(ChunkStreamWriteHandler.class); + InternalLoggerFactory.getInstance(ChunkedWriteHandler.class); private final Queue queue = new LinkedTransferQueue(); @@ -101,20 +101,20 @@ public class ChunkStreamWriteHandler implements ChannelUpstreamHandler, ChannelD } Object m = currentEvent.getMessage(); - if (m instanceof ChunkStream) { - ChunkStream stream = (ChunkStream) m; + if (m instanceof ChunkedInput) { + ChunkedInput chunks = (ChunkedInput) m; Object chunk; boolean last; try { - chunk = stream.readChunk(); - last = !stream.available(); + chunk = chunks.readChunk(); + last = !chunks.available(); } catch (Throwable t) { currentEvent.getFuture().setFailure(t); fireExceptionCaught(ctx, t); try { - stream.close(); + chunks.close(); } catch (Throwable t2) { - logger.warn("Failed to close a stream.", t2); + logger.warn("Failed to close a chunked input.", t2); } break; } @@ -128,7 +128,7 @@ public class ChunkStreamWriteHandler implements ChannelUpstreamHandler, ChannelD writeFuture.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) throws Exception { - ((ChunkStream) currentEvent.getMessage()).close(); + ((ChunkedInput) currentEvent.getMessage()).close(); } }); @@ -139,7 +139,7 @@ public class ChunkStreamWriteHandler implements ChannelUpstreamHandler, ChannelD throws Exception { if (!future.isSuccess()) { currentEvent.getFuture().setFailure(future.getCause()); - ((ChunkStream) currentEvent.getMessage()).close(); + ((ChunkedInput) currentEvent.getMessage()).close(); } } });