@Provider public class UnitOfWorkApplicationListener extends Object implements org.glassfish.jersey.server.monitoring.ApplicationEventListener
RequestEventListener
that listens for method events,
The RequestEventListener ensures an EntityManager is made available to the execution
context at method start, and ensures the EntityManager is removed at method completion.
The RequestEventListener creates and manages a transaction if required by the UnitOfWork
annotation.Constructor and Description |
---|
UnitOfWorkApplicationListener() |
UnitOfWorkApplicationListener(String name,
javax.persistence.EntityManagerFactory entityManagerFactory)
Construct an application event listener using the given name and EntityManagerFactory.
|
Modifier and Type | Method and 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 |
registerEntityManagerFactory(String name,
javax.persistence.EntityManagerFactory entityManagerFactory)
Register a EntityManagerFactory with the given name.
|
public UnitOfWorkApplicationListener()
public UnitOfWorkApplicationListener(String name, javax.persistence.EntityManagerFactory entityManagerFactory)
UnitOfWorkApplicationListener
should be added to a Jersey ResourceConfig
as a singleton.name
- a name of a EntityManager bundleentityManagerFactory
- a EntityManagerFactory
public void registerEntityManagerFactory(String name, javax.persistence.EntityManagerFactory entityManagerFactory)
name
- a name of an EntityManager bundleentityManagerFactory
- a EntityManagerFactory
public void onEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent event)
onEvent
in interface org.glassfish.jersey.server.monitoring.ApplicationEventListener
public org.glassfish.jersey.server.monitoring.RequestEventListener onRequest(org.glassfish.jersey.server.monitoring.RequestEvent event)
onRequest
in interface org.glassfish.jersey.server.monitoring.ApplicationEventListener
Copyright © 2016. All rights reserved.