org.compass.gps.device.jpa
Interface EntityManagerWrapper

All Known Implementing Classes:
AbstractEntityManagerWrapper, DefaultEntityManagerWrapper, JtaEntityManagerWrapper, ResourceLocalEntityManagerWrapper

public interface EntityManagerWrapper

An EntityManager wrapper allows controlling the creation and destruction of JPA EntityManagers, as well as any transactions control (such as JPA resource local EntityTransaction).

Used by JpaGpsDevice when performing the index operation.

Author:
kimchy

Method Summary
 void close()
          Closes the current EntityManager, commiting the transaction if necessary.
 void closeOnError()
          Closes the current EntityManager, rollback the transaction if necessary.
 javax.persistence.EntityManager getEntityManager()
          Returns the EntityManager opened by the wrapper open operation.
 EntityManagerWrapper newInstance()
          Creates a new instance of this entity manager wrapper for multi threaded usage.
 void open()
          Opens the warpper for a session of reading enteties for indexing.
 void setUp(javax.persistence.EntityManagerFactory entityManagerFactory)
          Sets up the entity manager wrapper with the EntityManagerFactory.
 

Method Detail

setUp

void setUp(javax.persistence.EntityManagerFactory entityManagerFactory)
Sets up the entity manager wrapper with the EntityManagerFactory.

Parameters:
entityManagerFactory - The EntityManagerFactory the wrapper will use

open

void open()
          throws JpaGpsDeviceException,
                 javax.persistence.PersistenceException
Opens the warpper for a session of reading enteties for indexing.

Throws:
JpaGpsDeviceException
javax.persistence.PersistenceException

getEntityManager

javax.persistence.EntityManager getEntityManager()
                                                 throws IllegalStateException
Returns the EntityManager opened by the wrapper open operation.

Returns:
The current EntityManager
Throws:
IllegalStateException - If not called between the open and close* operations

close

void close()
           throws JpaGpsDeviceException,
                  javax.persistence.PersistenceException
Closes the current EntityManager, commiting the transaction if necessary.

Throws:
JpaGpsDeviceException
javax.persistence.PersistenceException

closeOnError

void closeOnError()
                  throws JpaGpsDeviceException,
                         javax.persistence.PersistenceException
Closes the current EntityManager, rollback the transaction if necessary.

Throws:
JpaGpsDeviceException
javax.persistence.PersistenceException

newInstance

EntityManagerWrapper newInstance()
Creates a new instance of this entity manager wrapper for multi threaded usage.



Copyright (c) 2004-2008 The Compass Project.