public class Closer extends Object implements Closeable
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)
Constructor and Description |
---|
Closer() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Must be called in a finally block, to close all resources
added with closeLater().
|
<Elem,Exc extends Exception> |
close(info.aduna.iteration.CloseableIteration<Elem,Exc> o) |
static <Elem,Exc extends Exception> |
Close(info.aduna.iteration.CloseableIteration<Elem,Exc> o) |
<CloseableType extends Closeable> |
close(CloseableType o) |
static <CloseableType extends Closeable> |
Close(CloseableType o) |
<CloseableType extends Closeable> |
close(CloseableType o) |
static <CloseableType extends Closeable> |
Close(CloseableType o) |
com.hp.hpl.jena.rdf.model.Model |
close(com.hp.hpl.jena.rdf.model.Model o) |
static com.hp.hpl.jena.rdf.model.Model |
Close(com.hp.hpl.jena.rdf.model.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() |
public <Obj> Obj closeLater(Obj o)
close()
.public boolean remove(Object o)
closeLater(Object)
public void close()
close
in interface Closeable
Closeable.close()
public Collection closeAll(Collection objects)
public <Obj> Obj close(Obj o)
public <Obj> Obj handleCloseException(Obj o, Throwable e)
public <CloseableType extends Closeable> CloseableType close(CloseableType o)
public <CloseableType extends Closeable> CloseableType close(CloseableType o)
public org.apache.commons.httpclient.MultiThreadedHttpConnectionManager close(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager o)
public org.apache.commons.httpclient.SimpleHttpConnectionManager close(org.apache.commons.httpclient.SimpleHttpConnectionManager o)
public <Elem,Exc extends Exception> info.aduna.iteration.CloseableIteration<Elem,Exc> close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)
public XMLStreamReader close(XMLStreamReader o)
public com.hp.hpl.jena.rdf.model.Model close(com.hp.hpl.jena.rdf.model.Model o)
public <Obj> Obj closeReflection(Obj o)
public static <CloseableType extends Closeable> CloseableType Close(CloseableType o)
public static <CloseableType extends Closeable> CloseableType Close(CloseableType o)
public static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Close(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager o)
public static org.apache.commons.httpclient.SimpleHttpConnectionManager Close(org.apache.commons.httpclient.SimpleHttpConnectionManager o)
public static <Elem,Exc extends Exception> info.aduna.iteration.CloseableIteration<Elem,Exc> Close(info.aduna.iteration.CloseableIteration<Elem,Exc> o)
public static XMLStreamReader Close(XMLStreamReader o)
public static com.hp.hpl.jena.rdf.model.Model Close(com.hp.hpl.jena.rdf.model.Model o)
public static <Obj> Obj Close(Obj o)