org.jboss.remoting.spi
Class AbstractAutoCloseable<T>
java.lang.Object
org.jboss.remoting.spi.AbstractHandleableCloseable<T>
org.jboss.remoting.spi.AbstractAutoCloseable<T>
- All Implemented Interfaces:
- Closeable, HandleableCloseable<T>, AutoCloseable<T>
public abstract class AbstractAutoCloseable<T>
- extends AbstractHandleableCloseable<T>
- implements AutoCloseable<T>
A closeable implementation that supports reference counting. Since the initial reference count is zero, implementors
must be careful to ensure that the first operation invoked is a call to getHandle()
.
Method Summary |
protected void |
dec()
Decrement the reference count by one. |
Handle<T> |
getHandle()
Get a handle to this resource. |
protected void |
inc()
Increment the reference count by one. |
String |
toString()
|
AbstractAutoCloseable
protected AbstractAutoCloseable(Executor executor)
- Basic constructor.
- Parameters:
executor
- the executor used to execute the close notification handlers
dec
protected void dec()
throws IOException
- Decrement the reference count by one. If the count drops to zero, the resource is closed.
- Throws:
IOException
- if the reference count dropped to zero and the close operation threw an exception
inc
protected void inc()
throws IOException
- Increment the reference count by one. If the resource is closed, an exception is thrown.
- Throws:
RemotingException
- if the resource is closed
IOException
getHandle
public Handle<T> getHandle()
throws IOException
- Get a handle to this resource. Increments the reference count by one. If the resource is closed, an exception
is thrown.
- Specified by:
getHandle
in interface AutoCloseable<T>
- Returns:
- the handle
- Throws:
RemotingException
- if the resource is closed
IOException
- if an error occurs, particularly if this resource is already closed
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2008 JBoss, a division of Red Hat, Inc.