Intercept connection pooling of Datasource connections in JEE container

浪子不回头ぞ 提交于 2019-12-08 14:46:14

问题


is it possible to intercept the connection pooling mechanism of a DataSource in a JEE container?

For (un)setting some information on the connection's context I'm searching for a way to intercept the pooling mechanism so that I know when and which connection is put back into the pool.

So does anyone know a (common) way to do this?

Some additional info:

  • The application runs on Wildfly
  • Using Hibernate for ORM

回答1:


The option connection-listener in datasource configuration can be the solution.

connection-listener:

An org.jboss.jca.adapters.jdbc.spi.listener.ConnectionListener that provides a possible to listen for connection activation and passivation in order to perform actions before the connection is returned to the application or returned to the pool

You can create a custom implementation of org.jboss.jca.adapters.jdbc.spi.listener.ConnectionListener and deploy it as a module to do that you want.



来源:https://stackoverflow.com/questions/41715182/intercept-connection-pooling-of-datasource-connections-in-jee-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!