org.jboss.xnio
Class WeakCloseable

java.lang.Object
  extended by org.jboss.xnio.WeakCloseable
All Implemented Interfaces:
java.io.Closeable

public final class WeakCloseable
extends java.lang.Object
implements java.io.Closeable

A Closeable that holds a weak reference to another Closeable, which can be used to close the other without creating a strong reference to it.


Constructor Summary
WeakCloseable(java.io.Closeable resource)
          Construct a new instance.
WeakCloseable(java.lang.ref.WeakReference<java.io.Closeable> resource)
          Construct a new instance.
 
Method Summary
 void close()
          Closes this resource and releases any system resources associated with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeakCloseable

public WeakCloseable(java.lang.ref.WeakReference<java.io.Closeable> resource)
Construct a new instance.

Parameters:
resource - the target resource

WeakCloseable

public WeakCloseable(java.io.Closeable resource)
Construct a new instance.

Parameters:
resource - the target resource
Method Detail

close

public void close()
           throws java.io.IOException
Closes this resource and releases any system resources associated with it. If the resource is already closed, then invoking this method has no effect. In addition, if the resource has already been garbage collected, this operation has no effect.

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException