Franz Inc, AllegroGraph

com.franz.util
Class Closer

java.lang.Object
  extended by com.franz.util.Closer
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
AGConnFactory, AGConnPool

public class Closer
extends Object
implements Closeable

Use or extend this class to add easy ability to safely close various resources.

Also, static Close functions for various object types. These close functions are null safe and will catch Exception and call log.warn instead of throwing.

TODO: track lastUsed and add method to removeAbandoned (beyond a timeout)

Since:
v4.3.3

Constructor Summary
Closer()
           
 
Method Summary
 void close()
          Must be called in a finally block, to close all resources added with closeLater().
<Elem,Exc extends Exception>
info.aduna.iteration.CloseableIteration<Elem,Exc>
close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)
           
static
<Elem,Exc extends Exception>
info.aduna.iteration.CloseableIteration<Elem,Exc>
Close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)
           
<CloseableType extends Closeable>
CloseableType
close(CloseableType o)
           
static
<CloseableType extends Closeable>
CloseableType
Close(CloseableType o)
           
<CloseableType extends Closeable>
CloseableType
close(CloseableType o)
           
static
<CloseableType extends Closeable>
CloseableType
Close(CloseableType o)
           
 Model close(Model o)
           
static Model Close(Model o)
           
 org.apache.commons.httpclient.MultiThreadedHttpConnectionManager close(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager o)
           
static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Close(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager o)
           
<Obj> Obj
close(Obj o)
          Close an object immediately, will not be closed "later".
static
<Obj> Obj
Close(Obj o)
           
 org.apache.commons.httpclient.SimpleHttpConnectionManager close(org.apache.commons.httpclient.SimpleHttpConnectionManager o)
           
static org.apache.commons.httpclient.SimpleHttpConnectionManager Close(org.apache.commons.httpclient.SimpleHttpConnectionManager o)
           
 XMLStreamReader close(XMLStreamReader o)
           
static XMLStreamReader Close(XMLStreamReader o)
           
 Collection closeAll(Collection objects)
          Close all objects immediately, will not be closed "later".
<Obj> Obj
closeLater(Obj o)
          Add a resource to be closed with close().
<Obj> Obj
closeReflection(Obj o)
           
<Obj> Obj
handleCloseException(Obj o, Throwable e)
          Subclass may override, default behavior is to log.warn and return the object.
 boolean remove(Object o)
          Remove object from collection so close will not be called later.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Closer

public Closer()
Method Detail

closeLater

public <Obj> Obj closeLater(Obj o)
Add a resource to be closed with close().


remove

public boolean remove(Object o)
Remove object from collection so close will not be called later.

See Also:
closeLater(Object)

close

public void close()
Must be called in a finally block, to close all resources added with closeLater().

Specified by:
close in interface Closeable
See Also:
Closeable.close()

closeAll

public Collection closeAll(Collection objects)
Close all objects immediately, will not be closed "later".


toString

public String toString()
Overrides:
toString in class Object

close

public <Obj> Obj close(Obj o)
Close an object immediately, will not be closed "later".


handleCloseException

public <Obj> Obj handleCloseException(Obj o,
                                      Throwable e)
Subclass may override, default behavior is to log.warn and return the object.


close

public <CloseableType extends Closeable> CloseableType close(CloseableType o)

close

public <CloseableType extends Closeable> CloseableType close(CloseableType o)

close

public org.apache.commons.httpclient.MultiThreadedHttpConnectionManager close(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager o)

close

public org.apache.commons.httpclient.SimpleHttpConnectionManager close(org.apache.commons.httpclient.SimpleHttpConnectionManager o)

close

public <Elem,Exc extends Exception> info.aduna.iteration.CloseableIteration<Elem,Exc> close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)

close

public XMLStreamReader close(XMLStreamReader o)

close

public Model close(Model o)

closeReflection

public <Obj> Obj closeReflection(Obj o)

Close

public static <CloseableType extends Closeable> CloseableType Close(CloseableType o)

Close

public static <CloseableType extends Closeable> CloseableType Close(CloseableType o)

Close

public static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Close(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager o)

Close

public static org.apache.commons.httpclient.SimpleHttpConnectionManager Close(org.apache.commons.httpclient.SimpleHttpConnectionManager o)

Close

public static <Elem,Exc extends Exception> info.aduna.iteration.CloseableIteration<Elem,Exc> Close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)

Close

public static XMLStreamReader Close(XMLStreamReader o)

Close

public static Model Close(Model o)

Close

public static <Obj> Obj Close(Obj o)

Copyright © 2008-2012 Franz Inc.