org.apache.aries.jpa.container.context.transaction.impl
Class JTAPersistenceContextRegistry
java.lang.Object
org.osgi.util.tracker.ServiceTracker
org.apache.aries.jpa.container.context.transaction.impl.JTAPersistenceContextRegistry
- All Implemented Interfaces:
- org.apache.aries.jpa.container.context.JTAPersistenceContextManager, org.osgi.util.tracker.ServiceTrackerCustomizer
public final class JTAPersistenceContextRegistry
- extends org.osgi.util.tracker.ServiceTracker
- implements org.apache.aries.jpa.container.context.JTAPersistenceContextManager
This class is used to manage the lifecycle of JTA peristence contexts
Fields inherited from class org.osgi.util.tracker.ServiceTracker |
context, filter |
Methods inherited from class org.osgi.util.tracker.ServiceTracker |
close, getService, getService, getServiceReference, getServiceReferences, getServices, getTrackingCount, modifiedService, open, open, remove, size, waitForService |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JTAPersistenceContextRegistry
public JTAPersistenceContextRegistry(org.osgi.framework.BundleContext context)
getExistingPersistenceContext
public final javax.persistence.EntityManager getExistingPersistenceContext(javax.persistence.EntityManagerFactory emf)
- Specified by:
getExistingPersistenceContext
in interface org.apache.aries.jpa.container.context.JTAPersistenceContextManager
manageExistingPersistenceContext
public final void manageExistingPersistenceContext(javax.persistence.EntityManagerFactory emf,
javax.persistence.EntityManager em)
throws javax.persistence.TransactionRequiredException
- Specified by:
manageExistingPersistenceContext
in interface org.apache.aries.jpa.container.context.JTAPersistenceContextManager
- Throws:
javax.persistence.TransactionRequiredException
getCurrentPersistenceContext
public final javax.persistence.EntityManager getCurrentPersistenceContext(javax.persistence.EntityManagerFactory persistenceUnit,
Map<?,?> properties,
AtomicLong activeCount,
DestroyCallback cbk)
throws javax.persistence.TransactionRequiredException
- Get a PersistenceContext for the current transaction. The persistence context will
automatically be closed when the transaction completes. This method will create
a new PersistenceContext if none exists for the current transaction, or will
return any existing PersistenceContext for this transaction.
- Parameters:
persistenceUnit
- The peristence unit to create the persitence context fromproperties
- Any properties that should be passed on the call to createEntityManager()
.
The properties are NOT used for retrieving an already created persistence context.activeCount
- The AtomicLong for counting instancescbk
- A callback called when the instance is destroyed
- Returns:
- A persistence context associated with the current transaction. Note that this will
need to be wrappered to obey the JPA spec by throwing the correct exceptions
- Throws:
{@link
- TransactionRequiredException} if there is no active transaction.
javax.persistence.TransactionRequiredException
isTransactionActive
public final boolean isTransactionActive()
- Specified by:
isTransactionActive
in interface org.apache.aries.jpa.container.context.JTAPersistenceContextManager
jtaIntegrationAvailable
public final boolean jtaIntegrationAvailable()
- Returns true if we have access to a
TransactionSynchronizationRegistry
and
can manage persistence contexts
- Returns:
addingService
public final Object addingService(org.osgi.framework.ServiceReference ref)
- Called by service tracker to indicate that a new
TransactionSynchronizationRegistry
is available in the runtime
- Specified by:
addingService
in interface org.osgi.util.tracker.ServiceTrackerCustomizer
- Overrides:
addingService
in class org.osgi.util.tracker.ServiceTracker
- Parameters:
ref
-
removedService
public final void removedService(org.osgi.framework.ServiceReference reference,
Object o)
- Specified by:
removedService
in interface org.osgi.util.tracker.ServiceTrackerCustomizer
- Overrides:
removedService
in class org.osgi.util.tracker.ServiceTracker
Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.