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(CloseableIteration<Elem,Exc> o) |
static <Elem,Exc extends Exception> |
Close(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) |
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() |
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> CloseableIteration<Elem,Exc> close(CloseableIteration<Elem,Exc> o)
public XMLStreamReader close(XMLStreamReader 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> CloseableIteration<Elem,Exc> Close(CloseableIteration<Elem,Exc> o)
public static XMLStreamReader Close(XMLStreamReader o)
public static <Obj> Obj Close(Obj o)
Copyright © 2017 Franz Inc.. All rights reserved.