Java 6 NIO compatibility fix

This commit is contained in:
nathan 2016-03-17 19:57:08 +01:00
parent 24b844e4e3
commit 64df20fcdf
3 changed files with 29 additions and 93 deletions

View File

@ -7,15 +7,14 @@
*/ */
package com.barchart.udt.nio; package com.barchart.udt.nio;
import com.barchart.udt.SocketUDT;
import com.barchart.udt.TypeUDT;
import java.io.IOException; import java.io.IOException;
import java.net.ProtocolFamily;
import java.nio.channels.DatagramChannel; import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe; import java.nio.channels.Pipe;
import java.nio.channels.spi.SelectorProvider; import java.nio.channels.spi.SelectorProvider;
import com.barchart.udt.SocketUDT;
import com.barchart.udt.TypeUDT;
/** /**
* selection provider for UDT * selection provider for UDT
* <p> * <p>
@ -80,11 +79,6 @@ public class SelectorProviderUDT extends SelectorProvider {
throw new UnsupportedOperationException("feature not available"); throw new UnsupportedOperationException("feature not available");
} }
@Override
public DatagramChannel openDatagramChannel(final ProtocolFamily family) throws IOException {
throw new UnsupportedOperationException("feature not available");
}
/** /**
* Not supported. * Not supported.
*/ */

View File

@ -7,18 +7,14 @@
*/ */
package com.barchart.udt.nio; 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.SocketUDT;
import com.barchart.udt.TypeUDT; import com.barchart.udt.TypeUDT;
import com.barchart.udt.anno.ThreadSafe; 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 * {@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(); return (SelectorProviderUDT) super.provider();
} }
@Override
public ServerSocketChannel bind(final SocketAddress local, final int backlog) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public <T> ServerSocketChannel setOption(final SocketOption<T> name, final T value) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public <T> T getOption(final SocketOption<T> name) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public Set<SocketOption<?>> supportedOptions() {
throw new UnsupportedOperationException();
}
@Override @Override
public synchronized NioServerSocketUDT socket() { public synchronized NioServerSocketUDT socket() {
if (socketAdapter == null) { if (socketAdapter == null) {
@ -160,9 +136,4 @@ public class ServerSocketChannelUDT extends ServerSocketChannel implements Chann
public TypeUDT typeUDT() { public TypeUDT typeUDT() {
return providerUDT().type(); return providerUDT().type();
} }
@Override
public SocketAddress getLocalAddress() throws IOException {
throw new UnsupportedOperationException();
}
} }

View File

@ -7,26 +7,22 @@
*/ */
package com.barchart.udt.nio; 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.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.SocketOption;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.nio.channels.ConnectionPendingException; import java.nio.channels.ConnectionPendingException;
import java.nio.channels.IllegalBlockingModeException; import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
import java.nio.channels.UnresolvedAddressException; 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 * {@link SocketChannel}-like wrapper for {@link SocketUDT}, can be either
@ -246,13 +242,13 @@ public class SocketChannelUDT extends SocketChannel implements ChannelUDT {
} }
@Override // @Override
public SocketAddress getRemoteAddress() throws IOException { // public SocketAddress getRemoteAddress() throws IOException {
if(this.isConnectFinished()) { // if(this.isConnectFinished()) {
return remoteSocket; // return remoteSocket;
} // }
return null; // return null;
} // }
@Override @Override
protected void implCloseSelectableChannel() throws IOException { protected void implCloseSelectableChannel() throws IOException {
@ -537,36 +533,11 @@ public class SocketChannelUDT extends SocketChannel implements ChannelUDT {
} }
@Override // @Override
public <T> SocketChannel setOption(final SocketOption<T> name, final T value) throws IOException { // public SocketAddress getLocalAddress() throws IOException {
throw new UnsupportedOperationException(); // if(this.isConnected()) {
} // return localAddress;
// }
@Override // return null;
public <T> T getOption(final SocketOption<T> name) throws IOException { // }
throw new UnsupportedOperationException();
}
@Override
public Set<SocketOption<?>> 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;
}
} }