Closing a Persistence Manager Factory


JDO 1.0.1 adds a close method to the PersistenceManagerFactory interface.

 public void close() 

In order for this method to succeed, all of the transactions associated with the persistence managers that the factory produces must be inactive. If any are active, then this method throws a JDOUserException that contains a nested JDOUserException for each PersistenceManager that has an active transaction. This method performs a security check before closing the factory, and if the check fails, it throws a java.lang.SecurityException. JDO implementations may use this security check to prevent the application from closing the factory when doing so is inappropriate.

If the method is successful, then all open persistence managers obtained from this persistence manager factory are closed. The application cannot use a closed factory to obtain more persistence managers.

For some JDO implementations under some circumstances, closing the PersistenceManagerFactory can be a necessary housekeeping detail. You will need to consult the vendor's documentation to determine whether and when to call this method for the implementation and datastore that you are using. As a general rule, closing the factory is required when the datastore runs in the same JVM as JDO; otherwise, closing the factory is not required. Closing the factory can be an expensive operation that may impact performance if it is performed needlessly.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net