Module org.newsclub.net.unix.rmi
Package org.newsclub.net.unix.rmi
Class RemoteFileDescriptorBase<T>
java.lang.Object
org.newsclub.net.unix.rmi.RemoteFileDescriptorBase<T>
- Type Parameters:
T- The resource type.
- All Implemented Interfaces:
Closeable,Externalizable,Serializable,AutoCloseable,FileDescriptorAccess
- Direct Known Subclasses:
RemoteFileDescriptor,RemoteFileInput,RemoteFileOutput
public abstract class RemoteFileDescriptorBase<T>
extends Object
implements Externalizable, Closeable, FileDescriptorAccess
A wrapper that allows a
FileDescriptor be sent via RMI over AF_UNIX sockets.- Author:
- Christian Kohlschütter
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicReference<T> An optional, closeable resource that is related to this instance. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized instance; used for externalization. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()final FileDescriptorReturns the file descriptor.protected final intReturns the "magic value" for this type of file descriptor.final voidreadExternal(ObjectInput objIn) final voidwriteExternal(ObjectOutput objOut)
-
Field Details
-
resource
An optional, closeable resource that is related to this instance. If the reference is non-null, this will be closed uponclose(). For unidirectional implementations, this could be the corresponding input/output stream. For bidirectional implementations (e.g., a Socket, Pipe, etc.), this should close both directions.
-
-
Constructor Details
-
RemoteFileDescriptorBase
public RemoteFileDescriptorBase()Creates an uninitialized instance; used for externalization.- See Also:
-
-
Method Details
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
getFileDescriptor
Returns the file descriptor. This is either the original one that was specified in the constructor or a copy that was sent via RMI over an AF_UNIX connection as part of an ancillary message.- Specified by:
getFileDescriptorin interfaceFileDescriptorAccess- Returns:
- The file descriptor.
-
getMagicValue
protected final int getMagicValue()Returns the "magic value" for this type of file descriptor. The magic value consists of an indicator ("this is a file descriptor") as well as its capabilities (read/write). It is used to prevent, for example, converting an output stream to an input stream.- Returns:
- The magic value.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-