Class CloseableRequestResources
- java.lang.Object
-
- com.googlecode.cqengine.index.support.CloseableRequestResources
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class CloseableRequestResources extends Object implements Closeable
A QueryOption that allows to keep track of query resources which were opened to process a request and which need to be closed when processing of the request is finished. Theadd(Closeable)
method is used to addCloseable
objects to this object. Then when processing the request has finished (often whenResultSet.close()
is called), the engine will retrieve this object from the query options and call theclose()
method on this object, which will close all resources which had been added.- Author:
- Silvano Riz
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CloseableRequestResources.CloseableResourceGroup
-
Constructor Summary
Constructors Constructor Description CloseableRequestResources()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Closeable closeable)
Add a new resource that needs to be closed.CloseableRequestResources.CloseableResourceGroup
addGroup()
void
close()
Close and removes all resources and resource groups which have been added so far.static void
closeForQueryOptions(QueryOptions queryOptions)
Closes an existingCloseableRequestResources
if one is stored the QueryOptions and then removes it from the QueryOptions.static void
closeQuietly(Closeable closeable)
static CloseableRequestResources
forQueryOptions(QueryOptions queryOptions)
Returns an existingCloseableRequestResources
from the QueryOptions, or adds a new instance to the query options and returns that.
-
-
-
Method Detail
-
add
public void add(Closeable closeable)
Add a new resource that needs to be closed.- Parameters:
closeable
- The resource that needs to be closed
-
addGroup
public CloseableRequestResources.CloseableResourceGroup addGroup()
-
close
public void close()
Close and removes all resources and resource groups which have been added so far.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
forQueryOptions
public static CloseableRequestResources forQueryOptions(QueryOptions queryOptions)
Returns an existingCloseableRequestResources
from the QueryOptions, or adds a new instance to the query options and returns that.- Parameters:
queryOptions
- TheQueryOptions
- Returns:
- The existing QueryOptions's CloseableRequestResources or a new instance.
-
closeForQueryOptions
public static void closeForQueryOptions(QueryOptions queryOptions)
Closes an existingCloseableRequestResources
if one is stored the QueryOptions and then removes it from the QueryOptions.- Parameters:
queryOptions
- TheQueryOptions
-
closeQuietly
public static void closeQuietly(Closeable closeable)
-
-