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 addCloseableobjects 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 classCloseableRequestResources.CloseableResourceGroup
-
Constructor Summary
Constructors Constructor Description CloseableRequestResources()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Closeable closeable)Add a new resource that needs to be closed.CloseableRequestResources.CloseableResourceGroupaddGroup()voidclose()Close and removes all resources and resource groups which have been added so far.static voidcloseForQueryOptions(QueryOptions queryOptions)Closes an existingCloseableRequestResourcesif one is stored the QueryOptions and then removes it from the QueryOptions.static voidcloseQuietly(Closeable closeable)static CloseableRequestResourcesforQueryOptions(QueryOptions queryOptions)Returns an existingCloseableRequestResourcesfrom 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
forQueryOptions
public static CloseableRequestResources forQueryOptions(QueryOptions queryOptions)
Returns an existingCloseableRequestResourcesfrom 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 existingCloseableRequestResourcesif one is stored the QueryOptions and then removes it from the QueryOptions.- Parameters:
queryOptions- TheQueryOptions
-
closeQuietly
public static void closeQuietly(Closeable closeable)
-
-