JBoss Remoting 3.0.0.Beta2

org.jboss.remoting.spi
Class AbstractAutoCloseable<T>

java.lang.Object
  extended by org.jboss.remoting.spi.AbstractHandleableCloseable<T>
      extended by 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().


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.remoting.HandleableCloseable
HandleableCloseable.Key
 
Constructor Summary
protected AbstractAutoCloseable(Executor executor)
          Basic constructor.
 
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()
           
 
Methods inherited from class org.jboss.remoting.spi.AbstractHandleableCloseable
addCloseHandler, close, closeAction, finalize, getExecutor, isOpen
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.remoting.HandleableCloseable
addCloseHandler, close
 

Constructor Detail

AbstractAutoCloseable

protected AbstractAutoCloseable(Executor executor)
Basic constructor.

Parameters:
executor - the executor used to execute the close notification handlers
Method Detail

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

JBoss Remoting 3.0.0.Beta2

Copyright © 2008 JBoss, a division of Red Hat, Inc.