I’m trying to use the same connection pool to my database from the triggered webhook intent. I'm using the basic boilerplate (https://github.com/actions-on-google/dialogflow-webhook-boilerplate-java).
Every triggered intent does return ActionRequest
to me, however, it doesn't contain ServletContext
. So, how do I get normal request context using the actions-on-google-java
library? (https://github.com/actions-on-google/actions-on-google-java/blob/master/src/main/kotlin/com/google/actions/api/ActionRequest.kt)
I have tried to find alternative ways to get the pool, but my experience with Java is limited.
// this is what i would like to achieve but ActionRequest is limited
@ForIntent("DB test")
public ActionResponse DbTest(ActionRequest request)
{
...
DataSource pool = (DataSource) request.getServletContext().getAttribute("my-pool");
try (Connection conn = pool.getConnection())
{
// do database stuff
}
...
}