Package org.jenkinsci.remoting.nio
Class SelectableFileChannelFactory
- java.lang.Object
-
- org.jenkinsci.remoting.nio.SelectableFileChannelFactory
-
public class SelectableFileChannelFactory extends Object
Extracts outSelectableChannel
fromInputStream
orOutputStream
. This hides the hack that works around the fact thatFileChannel
is not aSelectableChannel
.JDK didn't make
FileChannel
selectable because it's not selectable on Windows. But on POSIX, select API does support arbitrary file descriptors, including pipes and regular files.Methods on this class takes various JDK objects that own
FileDescriptor
and creates aSocketChannel
object that points to the same file descriptor, as a hack. Note that since it is not a real socket, various socket specific operations onSocketChannel
will fail, most notablyObject.toString()
- Since:
- 2.38
- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description SelectableFileChannelFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SocketChannel
create(FileDescriptor fd)
Create channel using the specified file descriptor.SocketChannel
create(FileInputStream in)
SocketChannel
create(FileOutputStream out)
SocketChannel
create(InputStream in)
SocketChannel
create(OutputStream out)
protected FileInputStream
unwrap(InputStream i)
protected FileOutputStream
unwrap(OutputStream i)
-
-
-
Method Detail
-
unwrap
@CheckForNull protected FileInputStream unwrap(InputStream i)
-
unwrap
@CheckForNull protected FileOutputStream unwrap(OutputStream i)
-
create
@CheckForNull public SocketChannel create(InputStream in) throws IOException
- Throws:
IOException
-
create
@CheckForNull public SocketChannel create(OutputStream out) throws IOException
- Throws:
IOException
-
create
@CheckForNull public SocketChannel create(FileInputStream in) throws IOException
- Throws:
IOException
-
create
@CheckForNull public SocketChannel create(FileOutputStream out) throws IOException
- Throws:
IOException
-
create
@CheckForNull public SocketChannel create(FileDescriptor fd)
Create channel using the specified file descriptor.- Parameters:
fd
- File Descriptor- Returns:
null
if the platform does not support it (e.g. Windows) OR the socket channel cannot be created. In the latter case the error message will be printed toLOGGER
then.
-
-