From 0682421ce1e48c5009570e857385e1e280aa0dd3 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 1 May 2012 18:23:59 +0900 Subject: [PATCH] Remove unused classes - ChannelPipelineFactory will be replaced with sometime else when I refactory the bootstrap package - FileRegion is going away. A user can deregister a channel and perform such operations by him/herself. If this turns out to be too difficult, I'll introduce a new 'sendfile' operation to the outbound handler. --- .../netty/channel/ChannelPipelineFactory.java | 42 -------- .../java/io/netty/channel/ChannelState.java | 99 ------------------- .../io/netty/channel/DefaultFileRegion.java | 89 ----------------- .../java/io/netty/channel/FileRegion.java | 89 ----------------- 4 files changed, 319 deletions(-) delete mode 100644 transport/src/main/java/io/netty/channel/ChannelPipelineFactory.java delete mode 100644 transport/src/main/java/io/netty/channel/ChannelState.java delete mode 100644 transport/src/main/java/io/netty/channel/DefaultFileRegion.java delete mode 100644 transport/src/main/java/io/netty/channel/FileRegion.java diff --git a/transport/src/main/java/io/netty/channel/ChannelPipelineFactory.java b/transport/src/main/java/io/netty/channel/ChannelPipelineFactory.java deleted file mode 100644 index c10c225549..0000000000 --- a/transport/src/main/java/io/netty/channel/ChannelPipelineFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2011 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import io.netty.bootstrap.Bootstrap; -import io.netty.bootstrap.ClientBootstrap; -import io.netty.bootstrap.ConnectionlessBootstrap; - -/** - * Creates a new {@link ChannelPipeline} for a new {@link Channel}. - *

- * When a {@linkplain ServerChannel server-side channel} accepts a new incoming - * connection, a new child channel is created for each newly accepted connection. - * A new child channel uses a new {@link ChannelPipeline}, which is created by - * the {@link ChannelPipelineFactory} specified in the server-side channel's - * {@link ChannelConfig#getPipelineFactory() "pipelineFactory"} option. - *

- * Also, when a {@link ClientBootstrap} or {@link ConnectionlessBootstrap} - * creates a new channel, it uses the {@link Bootstrap#getPipelineFactory() "pipelineFactory"} - * property to create a new {@link ChannelPipeline} for each new channel. - * @apiviz.has io.netty.channel.ChannelPipeline oneway - - creates - */ -public interface ChannelPipelineFactory { - - /** - * Returns a newly created {@link ChannelPipeline}. - */ - ChannelPipeline getPipeline() throws Exception; -} diff --git a/transport/src/main/java/io/netty/channel/ChannelState.java b/transport/src/main/java/io/netty/channel/ChannelState.java deleted file mode 100644 index 3cb428751f..0000000000 --- a/transport/src/main/java/io/netty/channel/ChannelState.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2011 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import java.net.SocketAddress; - -/** - * The current or future state of a {@link Channel}. - *

- * The state of a {@link Channel} is interpreted differently depending on the - * {@linkplain ChannelStateEvent#getValue() value} of a {@link ChannelStateEvent} - * and the direction of the event in a {@link ChannelPipeline}: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
DirectionStateValueMeaning
Upstream{@link #OPEN}{@code true}The channel is open.
Upstream{@link #OPEN}{@code false}The channel is closed.
Upstream{@link #BOUND}{@link SocketAddress}The channel is bound to a local address.
Upstream{@link #BOUND}{@code null}The channel is unbound to a local address.
Upstream{@link #CONNECTED}{@link SocketAddress}The channel is connected to a remote address.
Upstream{@link #CONNECTED}{@code null}The channel is disconnected from a remote address.
Upstream{@link #INTEREST_OPS}an integerThe channel interestOps has been changed.
Downstream{@link #OPEN}{@code true}N/A
Downstream{@link #OPEN}{@code false}Close the channel.
Downstream{@link #BOUND}{@link SocketAddress}Bind the channel to the specified local address.
Downstream{@link #BOUND}{@code null}Unbind the channel from the current local address.
Downstream{@link #CONNECTED}{@link SocketAddress}Connect the channel to the specified remote address.
Downstream{@link #CONNECTED}{@code null}Disconnect the channel from the current remote address.
Downstream{@link #INTEREST_OPS}an integerChange the interestOps of the channel.
- *

- * To see how an event is interpreted further, please refer to {@link ChannelEvent}. - */ -public enum ChannelState { - /** - * Represents a {@link Channel}'s {@link Channel#isOpen() open} property - */ - OPEN, - - /** - * Represents a {@link Channel}'s {@link Channel#isBound() bound} property - */ - BOUND, - - /** - * Represents a {@link Channel}'s {@link Channel#isConnected() connected} - * property - */ - CONNECTED, - - /** - * Represents a {@link Channel}'s {@link Channel#getInterestOps() interestOps} - * property - */ - INTEREST_OPS -} diff --git a/transport/src/main/java/io/netty/channel/DefaultFileRegion.java b/transport/src/main/java/io/netty/channel/DefaultFileRegion.java deleted file mode 100644 index 4ceb20feb9..0000000000 --- a/transport/src/main/java/io/netty/channel/DefaultFileRegion.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2011 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import java.io.IOException; -import java.nio.channels.FileChannel; -import java.nio.channels.WritableByteChannel; - -import io.netty.logging.InternalLogger; -import io.netty.logging.InternalLoggerFactory; - -public class DefaultFileRegion implements FileRegion { - - private static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultFileRegion.class); - - private final FileChannel file; - private final long position; - private final long count; - private final boolean releaseAfterTransfer; - - /** - * Calls {@link #DefaultFileRegion(FileChannel, long, long, boolean)} - * with true as the last argument. - */ - public DefaultFileRegion(FileChannel file, long position, long count) { - this(file, position, count, true); - } - - public DefaultFileRegion(FileChannel file, long position, long count, boolean releaseAfterTransfer) { - this.file = file; - this.position = position; - this.count = count; - this.releaseAfterTransfer = releaseAfterTransfer; - } - - @Override - public long getPosition() { - return position; - } - - @Override - public long getCount() { - return count; - } - - @Override - public boolean releaseAfterTransfer() { - return releaseAfterTransfer; - } - - @Override - public long transferTo(WritableByteChannel target, long position) throws IOException { - long count = this.count - position; - if (count < 0 || position < 0) { - throw new IllegalArgumentException( - "position out of range: " + position + - " (expected: 0 - " + (this.count - 1) + ")"); - } - if (count == 0) { - return 0L; - } - - return file.transferTo(this.position + position, count, target); - } - - @Override - public void releaseExternalResources() { - try { - file.close(); - } catch (IOException e) { - if (logger.isWarnEnabled()) { - logger.warn("Failed to close a file.", e); - } - } - } -} diff --git a/transport/src/main/java/io/netty/channel/FileRegion.java b/transport/src/main/java/io/netty/channel/FileRegion.java deleted file mode 100644 index eebb4ec516..0000000000 --- a/transport/src/main/java/io/netty/channel/FileRegion.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2011 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, - * version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package io.netty.channel; - -import java.io.IOException; -import java.nio.channels.FileChannel; -import java.nio.channels.WritableByteChannel; - -import io.netty.util.ExternalResourceReleasable; - -/** - * A region of a file that is sent via a {@link Channel} which supports - * zero-copy file transfer. - * - *

Upgrade your JDK / JRE

- * - * {@link FileChannel#transferTo(long, long, WritableByteChannel)} has at least - * four known bugs in the old versions of Sun JDK and perhaps its derived ones. - * Please upgrade your JDK to 1.6.0_18 or later version if you are going to use - * zero-copy file transfer. - * - * - *

Check your operating system and JDK / JRE

- * - * If your operating system (or JDK / JRE) does not support zero-copy file - * transfer, sending a file with {@link FileRegion} might fail or yield worse - * performance. For example, sending a large file doesn't work well in Windows. - * - *

Not all transports support it

- * - * Currently, the NIO transport is the only transport that supports {@link FileRegion}. - * Attempting to write a {@link FileRegion} to non-NIO {@link Channel} will trigger - * a {@link ClassCastException} or a similar exception. - */ -public interface FileRegion extends ExternalResourceReleasable { - - // FIXME Make sure all transports support writing a FileRegion - // Even if zero copy cannot be achieved, all transports should emulate it. - - /** - * Returns the offset in the file where the transfer began. - */ - long getPosition(); - - /** - * Returns the number of bytes to transfer. - */ - long getCount(); - - /** - * Returns true if {@link #releaseExternalResources()} has to - * be called after the transfer of this {@link FileRegion} is complete. - */ - boolean releaseAfterTransfer(); - - /** - * Transfers the content of this file region to the specified channel. - * - * @param target the destination of the transfer - * @param position the relative offset of the file where the transfer - * begins from. For example, 0 will make the - * transfer start from {@link #getPosition()}th byte and - * {@link #getCount()} - 1 will make the last - * byte of the region transferred. - */ - long transferTo(WritableByteChannel target, long position) throws IOException; -}