Package io.dropwizard.hibernate
Class UnitOfWorkApplicationListener
- java.lang.Object
-
- io.dropwizard.hibernate.UnitOfWorkApplicationListener
-
- All Implemented Interfaces:
org.glassfish.jersey.server.monitoring.ApplicationEventListener
@Provider public class UnitOfWorkApplicationListener extends Object implements org.glassfish.jersey.server.monitoring.ApplicationEventListener
An application event listener that listens for Jersey application initialization to be finished, then creates a map of resource method that have metrics annotations. Finally, it listens for method start events, and returns aRequestEventListener
that updates the relevant metric for suitably annotated methods when it gets the request events indicating that the method is about to be invoked, or just got done being invoked.
-
-
Constructor Summary
Constructors Constructor Description UnitOfWorkApplicationListener()
UnitOfWorkApplicationListener(String name, org.hibernate.SessionFactory sessionFactory)
Construct an application event listener using the given name and session factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event)
org.glassfish.jersey.server.monitoring.RequestEventListener
onRequest(org.glassfish.jersey.server.monitoring.RequestEvent event)
void
registerSessionFactory(String name, org.hibernate.SessionFactory sessionFactory)
Register a session factory with the given name.
-
-
-
Constructor Detail
-
UnitOfWorkApplicationListener
public UnitOfWorkApplicationListener()
-
UnitOfWorkApplicationListener
public UnitOfWorkApplicationListener(String name, org.hibernate.SessionFactory sessionFactory)
Construct an application event listener using the given name and session factory. When using this constructor, theUnitOfWorkApplicationListener
should be added to a JerseyResourceConfig
as a singleton.- Parameters:
name
- a name of a Hibernate bundlesessionFactory
- aSessionFactory
-
-
Method Detail
-
registerSessionFactory
public void registerSessionFactory(String name, org.hibernate.SessionFactory sessionFactory)
Register a session factory with the given name.- Parameters:
name
- a name of a Hibernate bundlesessionFactory
- aSessionFactory
-
onEvent
public void onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event)
- Specified by:
onEvent
in interfaceorg.glassfish.jersey.server.monitoring.ApplicationEventListener
-
onRequest
public org.glassfish.jersey.server.monitoring.RequestEventListener onRequest(org.glassfish.jersey.server.monitoring.RequestEvent event)
- Specified by:
onRequest
in interfaceorg.glassfish.jersey.server.monitoring.ApplicationEventListener
-
-