From 64df20fcdfdde8e27970662ffb871209056eab90 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 17 Mar 2016 19:57:08 +0100 Subject: [PATCH] Java 6 NIO compatibility fix --- .../barchart/udt/nio/SelectorProviderUDT.java | 12 +--- .../udt/nio/ServerSocketChannelUDT.java | 39 ++-------- .../barchart/udt/nio/SocketChannelUDT.java | 71 ++++++------------- 3 files changed, 29 insertions(+), 93 deletions(-) diff --git a/src/com/barchart/udt/nio/SelectorProviderUDT.java b/src/com/barchart/udt/nio/SelectorProviderUDT.java index 642b6e7f..65290e13 100644 --- a/src/com/barchart/udt/nio/SelectorProviderUDT.java +++ b/src/com/barchart/udt/nio/SelectorProviderUDT.java @@ -7,15 +7,14 @@ */ package com.barchart.udt.nio; +import com.barchart.udt.SocketUDT; +import com.barchart.udt.TypeUDT; + import java.io.IOException; -import java.net.ProtocolFamily; import java.nio.channels.DatagramChannel; import java.nio.channels.Pipe; import java.nio.channels.spi.SelectorProvider; -import com.barchart.udt.SocketUDT; -import com.barchart.udt.TypeUDT; - /** * selection provider for UDT *

@@ -80,11 +79,6 @@ public class SelectorProviderUDT extends SelectorProvider { throw new UnsupportedOperationException("feature not available"); } - @Override - public DatagramChannel openDatagramChannel(final ProtocolFamily family) throws IOException { - throw new UnsupportedOperationException("feature not available"); - } - /** * Not supported. */ diff --git a/src/com/barchart/udt/nio/ServerSocketChannelUDT.java b/src/com/barchart/udt/nio/ServerSocketChannelUDT.java index 6aaaf583..86740903 100644 --- a/src/com/barchart/udt/nio/ServerSocketChannelUDT.java +++ b/src/com/barchart/udt/nio/ServerSocketChannelUDT.java @@ -7,18 +7,14 @@ */ package com.barchart.udt.nio; -import java.io.IOException; -import java.net.SocketAddress; -import java.net.SocketOption; -import java.nio.channels.ServerSocketChannel; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.barchart.udt.SocketUDT; import com.barchart.udt.TypeUDT; import com.barchart.udt.anno.ThreadSafe; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.nio.channels.ServerSocketChannel; /** * {@link ServerSocketChannel}-like wrapper for {@link SocketUDT} can be either @@ -113,26 +109,6 @@ public class ServerSocketChannelUDT extends ServerSocketChannel implements Chann return (SelectorProviderUDT) super.provider(); } - @Override - public ServerSocketChannel bind(final SocketAddress local, final int backlog) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public ServerSocketChannel setOption(final SocketOption name, final T value) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public T getOption(final SocketOption name) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public Set> supportedOptions() { - throw new UnsupportedOperationException(); - } - @Override public synchronized NioServerSocketUDT socket() { if (socketAdapter == null) { @@ -160,9 +136,4 @@ public class ServerSocketChannelUDT extends ServerSocketChannel implements Chann public TypeUDT typeUDT() { return providerUDT().type(); } - - @Override - public SocketAddress getLocalAddress() throws IOException { - throw new UnsupportedOperationException(); - } } diff --git a/src/com/barchart/udt/nio/SocketChannelUDT.java b/src/com/barchart/udt/nio/SocketChannelUDT.java index 82e201bf..edd3f5cf 100644 --- a/src/com/barchart/udt/nio/SocketChannelUDT.java +++ b/src/com/barchart/udt/nio/SocketChannelUDT.java @@ -7,26 +7,22 @@ */ package com.barchart.udt.nio; +import com.barchart.udt.ExceptionUDT; +import com.barchart.udt.SocketUDT; +import com.barchart.udt.TypeUDT; +import com.barchart.udt.anno.ThreadSafe; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; -import java.net.SocketOption; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.ConnectionPendingException; import java.nio.channels.IllegalBlockingModeException; import java.nio.channels.SocketChannel; import java.nio.channels.UnresolvedAddressException; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.barchart.udt.ExceptionUDT; -import com.barchart.udt.SocketUDT; -import com.barchart.udt.TypeUDT; -import com.barchart.udt.anno.ThreadSafe; /** * {@link SocketChannel}-like wrapper for {@link SocketUDT}, can be either @@ -246,13 +242,13 @@ public class SocketChannelUDT extends SocketChannel implements ChannelUDT { } - @Override - public SocketAddress getRemoteAddress() throws IOException { - if(this.isConnectFinished()) { - return remoteSocket; - } - return null; - } +// @Override +// public SocketAddress getRemoteAddress() throws IOException { +// if(this.isConnectFinished()) { +// return remoteSocket; +// } +// return null; +// } @Override protected void implCloseSelectableChannel() throws IOException { @@ -537,36 +533,11 @@ public class SocketChannelUDT extends SocketChannel implements ChannelUDT { } - @Override - public SocketChannel setOption(final SocketOption name, final T value) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public T getOption(final SocketOption name) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public Set> supportedOptions() { - throw new UnsupportedOperationException(); - } - - @Override - public SocketChannel shutdownInput() throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public SocketChannel shutdownOutput() throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public SocketAddress getLocalAddress() throws IOException { - if(this.isConnected()) { - return localAddress; - } - return null; - } +// @Override +// public SocketAddress getLocalAddress() throws IOException { +// if(this.isConnected()) { +// return localAddress; +// } +// return null; +// } }