org.apache.aries.jpa.container.context.impl
Class PersistenceContextManager

java.lang.Object
  extended by org.osgi.util.tracker.ServiceTracker
      extended by org.apache.aries.jpa.container.context.impl.PersistenceContextManager
All Implemented Interfaces:
org.osgi.util.tracker.ServiceTrackerCustomizer

public class PersistenceContextManager
extends org.osgi.util.tracker.ServiceTracker

This class is responsible for managing all of the persistence contexts at a defined scope, i.e. for a single framework or composite. It will automatically manage the lifecycle of all registered persistence contexts.


Field Summary
 
Fields inherited from class org.osgi.util.tracker.ServiceTracker
context
 
Constructor Summary
PersistenceContextManager(org.osgi.framework.BundleContext ctx, JTAPersistenceContextRegistry registry)
          Create a new PersistenceContextManager at a scope defined by the supplied BundleContext
 
Method Summary
 Object addingService(org.osgi.framework.ServiceReference reference)
           
 void close()
           
 void open()
           
 void quiesceAllUnits(DestroyCallback callback)
          Quiesce all the persistence units managed by this PersistenceContextManager
 void quiesceUnits(org.osgi.framework.Bundle bundleToQuiesce, DestroyCallback callback)
          Call this method to quiesce a given bundle
 void registerContext(String name, org.osgi.framework.Bundle client, HashMap<String,Object> properties)
          Register a persistence context definition with this manager
 void removedService(org.osgi.framework.ServiceReference ref, Object o)
           
 void unregisterContext(String name, org.osgi.framework.Bundle client)
          Unregister the supplied bundle as a client of the supplied persistence context
 
Methods inherited from class org.osgi.util.tracker.ServiceTracker
getService, getService, getServiceReference, getServiceReferences, getServices, getTrackingCount, modifiedService, open, remove, size, waitForService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceContextManager

public PersistenceContextManager(org.osgi.framework.BundleContext ctx,
                                 JTAPersistenceContextRegistry registry)
Create a new PersistenceContextManager at a scope defined by the supplied BundleContext

Parameters:
ctx - the bundle context to use for tracking services. In order to prevent this object becoming prematurely invalid it is best to use the BundleContext of the system bundle (Bundle 0).
Method Detail

close

public void close()
Overrides:
close in class org.osgi.util.tracker.ServiceTracker

addingService

public Object addingService(org.osgi.framework.ServiceReference reference)
Specified by:
addingService in interface org.osgi.util.tracker.ServiceTrackerCustomizer
Overrides:
addingService in class org.osgi.util.tracker.ServiceTracker

removedService

public void removedService(org.osgi.framework.ServiceReference ref,
                           Object o)
Specified by:
removedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer
Overrides:
removedService in class org.osgi.util.tracker.ServiceTracker

registerContext

public void registerContext(String name,
                            org.osgi.framework.Bundle client,
                            HashMap<String,Object> properties)
Register a persistence context definition with this manager

Parameters:
name - The name of the persistence unit for this context
client - The Bundle that uses this persistence context
properties - The Map of properties for this persistence context This must contain the PersistenceContextType

unregisterContext

public void unregisterContext(String name,
                              org.osgi.framework.Bundle client)
Unregister the supplied bundle as a client of the supplied persistence context

Parameters:
name - The name of the context
client - The bundle that is using the persistence context

open

public void open()
Overrides:
open in class org.osgi.util.tracker.ServiceTracker

quiesceUnits

public void quiesceUnits(org.osgi.framework.Bundle bundleToQuiesce,
                         DestroyCallback callback)
Call this method to quiesce a given bundle

Parameters:
bundleToQuiesce - The bundle to quiesce
callback - A callback indicating that we have finished quiescing

quiesceAllUnits

public void quiesceAllUnits(DestroyCallback callback)
Quiesce all the persistence units managed by this PersistenceContextManager

Parameters:
callback -


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.