Class RemoteCloseableImpl<T>

java.lang.Object
org.newsclub.net.unix.rmi.RemoteCloseableImpl<T>
All Implemented Interfaces:
Closeable, AutoCloseable, Remote, RemoteCloseable<T>

public class RemoteCloseableImpl<T> extends Object implements RemoteCloseable<T>
The default implementation of RemoteCloseable.
Author:
Christian Kohlschütter
See Also:
  • Constructor Details

    • RemoteCloseableImpl

      public RemoteCloseableImpl(RMISocketFactory socketFactory, T obj) throws RemoteException
      Created a new instance.
      Parameters:
      socketFactory - The socket factory.
      obj - The object to wrap.
      Throws:
      RemoteException - on error.
  • Method Details

    • close

      public final void close() throws IOException
      Description copied from interface: RemoteCloseable
      Closes the resource on the server-side (i.e., where it was created), and — as long as the wrapped resource returned by RemoteCloseable.get() supports it — locally as well.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface RemoteCloseable<T>
      Throws:
      IOException - if there was a problem.
    • doClose

      protected void doClose(T obj) throws IOException
      Closes the given object.
      Parameters:
      obj - The object to close.
      Throws:
      IOException - on error.
    • get

      public T get() throws IOException
      Description copied from interface: RemoteCloseable
      Returns the resource (or the Remote instance of it). If the returned resource is Closeable, then closing via get().close()} will affect the client-side (local), but not necessarily the server-side as well (the exact behavior depends on the resource).
      Specified by:
      get in interface RemoteCloseable<T>
      Returns:
      The wrapped resource.
      Throws:
      NoSuchObjectException - if this instance has been closed already.
      IOException - if there was a problem.