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

Extend this class to add easy ability to safely close various resources.

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

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.

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().
static
<Elem,Exc extends Exception>
info.aduna.iteration.CloseableIteration<Elem,Exc>
Close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)
           
static
<CloseableType extends Closeable>
CloseableType
Close(CloseableType o)
           
static
<CloseableType extends Closeable>
CloseableType
Close(CloseableType o)
           
static Model Close(Model 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)
           
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().
 boolean remove(Object o)
          Remove from closeLater(Object).
 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 from 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".


close

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


toString

public String toString()
Overrides:
toString in class Object

Close

public static <Obj> Obj Close(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 <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)

Copyright © 2008-2011 Franz Inc.