/hazelcast/src/main/java/com/hazelcast/nio/DefaultSocketChannelWrapper.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 103 lines · 66 code · 22 blank · 15 comment · 0 complexity · 77324eb280a5294f7c5db5a9bc7c4e87 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.hazelcast.nio;
  17. import java.io.IOException;
  18. import java.net.Socket;
  19. import java.net.SocketAddress;
  20. import java.nio.ByteBuffer;
  21. import java.nio.channels.*;
  22. public class DefaultSocketChannelWrapper implements SocketChannelWrapper {
  23. protected final SocketChannel socketChannel;
  24. public DefaultSocketChannelWrapper(SocketChannel socketChannel) {
  25. this.socketChannel = socketChannel;
  26. }
  27. public boolean isBlocking() {
  28. return socketChannel.isBlocking();
  29. }
  30. public int validOps() {
  31. return socketChannel.validOps();
  32. }
  33. public Socket socket() {
  34. return socketChannel.socket();
  35. }
  36. public boolean isConnected() {
  37. return socketChannel.isConnected();
  38. }
  39. public boolean isConnectionPending() {
  40. return socketChannel.isConnectionPending();
  41. }
  42. public boolean connect(SocketAddress socketAddress) throws IOException {
  43. return socketChannel.connect(socketAddress);
  44. }
  45. public boolean finishConnect() throws IOException {
  46. return socketChannel.finishConnect();
  47. }
  48. public int read(ByteBuffer byteBuffer) throws IOException {
  49. return socketChannel.read(byteBuffer);
  50. }
  51. public long read(ByteBuffer[] byteBuffers, int i, int i1) throws IOException {
  52. return socketChannel.read(byteBuffers, i, i1);
  53. }
  54. public long read(ByteBuffer[] byteBuffers) throws IOException {
  55. return socketChannel.read(byteBuffers);
  56. }
  57. public int write(ByteBuffer byteBuffer) throws IOException {
  58. return socketChannel.write(byteBuffer);
  59. }
  60. public long write(ByteBuffer[] byteBuffers, int i, int i1) throws IOException {
  61. return socketChannel.write(byteBuffers, i, i1);
  62. }
  63. public long write(ByteBuffer[] byteBuffers) throws IOException {
  64. return socketChannel.write(byteBuffers);
  65. }
  66. public SelectableChannel configureBlocking(boolean b) throws IOException {
  67. return socketChannel.configureBlocking(b);
  68. }
  69. public boolean isOpen() {
  70. return socketChannel.isOpen();
  71. }
  72. public void close() throws IOException {
  73. socketChannel.close();
  74. }
  75. public SelectionKey keyFor(Selector selector) {
  76. return socketChannel.keyFor(selector);
  77. }
  78. public SelectionKey register(Selector selector, int i, Object o) throws ClosedChannelException {
  79. return socketChannel.register(selector, i, o);
  80. }
  81. }