Class ResourceRegistryStandardImpl
- java.lang.Object
-
- org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl
-
- All Implemented Interfaces:
ResourceRegistry
public final class ResourceRegistryStandardImpl extends Object implements ResourceRegistry
Helps to track statements and resultsets which need being closed. This class is not threadsafe.Note regarding performance: we had evidence that allocating Iterators to implement the cleanup on each element recursively was the dominant resource cost, so we decided using "forEach" and lambdas in this case. However the forEach/lambda combination is able to dodge allocating Iterators on HashMap and ArrayList, but not on HashSet (at least on JDK8 and 11). Therefore some types which should ideally be modelled as a Set have been implemented using HashMap.
-
-
Constructor Summary
Constructors Constructor Description ResourceRegistryStandardImpl()
ResourceRegistryStandardImpl(JdbcObserver jdbcObserver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelLastQuery()
static void
close(Statement statement)
boolean
hasRegisteredResources()
Does this registry currently have any registered resources?void
register(Blob blob)
void
register(Clob clob)
void
register(NClob nclob)
void
register(ResultSet resultSet, Statement statement)
Register a JDBC result set.void
register(Statement statement, boolean cancelable)
Register a JDBC statement.void
release(Blob blob)
void
release(Clob clob)
void
release(NClob nclob)
void
release(ResultSet resultSet, Statement statement)
Release a previously registered result set.void
release(Statement statement)
Release a previously registered statement.void
releaseResources()
-
-
-
Constructor Detail
-
ResourceRegistryStandardImpl
public ResourceRegistryStandardImpl()
-
ResourceRegistryStandardImpl
public ResourceRegistryStandardImpl(JdbcObserver jdbcObserver)
-
-
Method Detail
-
hasRegisteredResources
public boolean hasRegisteredResources()
Description copied from interface:ResourceRegistry
Does this registry currently have any registered resources?- Specified by:
hasRegisteredResources
in interfaceResourceRegistry
- Returns:
- True if the registry does have registered resources; false otherwise.
-
register
public void register(Statement statement, boolean cancelable)
Description copied from interface:ResourceRegistry
Register a JDBC statement.- Specified by:
register
in interfaceResourceRegistry
- Parameters:
statement
- The statement to register.cancelable
- Is the statement being registered capable of being cancelled? In other words, should we register it to be the target of subsequentResourceRegistry.cancelLastQuery()
calls?
-
release
public void release(Statement statement)
Description copied from interface:ResourceRegistry
Release a previously registered statement.- Specified by:
release
in interfaceResourceRegistry
- Parameters:
statement
- The statement to release.
-
release
public void release(ResultSet resultSet, Statement statement)
Description copied from interface:ResourceRegistry
Release a previously registered result set.- Specified by:
release
in interfaceResourceRegistry
- Parameters:
resultSet
- The result set to release.statement
- Statement from whichResultSet
has been generated.
-
close
public static void close(Statement statement)
-
register
public void register(ResultSet resultSet, Statement statement)
Description copied from interface:ResourceRegistry
Register a JDBC result set.Implementation note: Second parameter has been introduced to prevent multiple registrations of the same statement in case
ResultSet.getStatement()
does not return originalStatement
object.- Specified by:
register
in interfaceResourceRegistry
- Parameters:
resultSet
- The result set to register.statement
- Statement from whichResultSet
has been generated.
-
register
public void register(Blob blob)
- Specified by:
register
in interfaceResourceRegistry
-
release
public void release(Blob blob)
- Specified by:
release
in interfaceResourceRegistry
-
register
public void register(Clob clob)
- Specified by:
register
in interfaceResourceRegistry
-
release
public void release(Clob clob)
- Specified by:
release
in interfaceResourceRegistry
-
register
public void register(NClob nclob)
- Specified by:
register
in interfaceResourceRegistry
-
release
public void release(NClob nclob)
- Specified by:
release
in interfaceResourceRegistry
-
cancelLastQuery
public void cancelLastQuery()
- Specified by:
cancelLastQuery
in interfaceResourceRegistry
-
releaseResources
public void releaseResources()
- Specified by:
releaseResources
in interfaceResourceRegistry
-
-