Chapter 6: Factories that Produce Persistence Managers


The PersistenceManager is both the principal service interface of JDO and the gateway to its other service interfaces. To obtain objects that implement the PersistenceManager interface, the application uses the PersistenceManagerFactory interface. In some cases, the application can obtain a PersistenceManager from a javax.resource.cci.ConnectionFactory interface, which is defined in the J2EE Connector Architecture (JCA). Since both the PersistenceManagerFactory and the ConnectionFactory are interfaces, how does the application obtain the object that implements one of these interfaces? As it turns out, the answer is nearly trivial. If all this chapter had to do was explain how to get a factory, it would be quite short.

In addition to producing persistence managers, the factories configure them as well. Understanding how the factories configure persistence managers provides the basis for understanding the proper way to use the factories in a managed environment. The PersistenceManagerFactory is also the telltale of the JDO implementation. It identifies the optional JDO features that the implementation supports.

The PersistenceManagerFactory Interface

Figure 6-1 shows the class diagram for the PersistenceManagerFactory interface. As the figure indicates, the object that implements the PersistenceManagerFactory interface is serializable. JNDI can store and retrieve serializable objects. As a result, a persistence manager factory can be stored in and retrieved from JNDI.

click to expand
Figure 6-1: The class diagram of the PersistenceManagerFactory interface

The PersistenceManagerFactory interface has 4 operations and 15 properties. The primary operation is getPersistenceManager. The 15 properties break down into 3 groups. The first 5 properties shown in Figure 6-1 also appear in the Transaction interface. The next 2 properties appear in the PersistenceManager interface. This chapter describes the relationship between the properties found in these other interfaces and the properties with the same names found in the PersistenceManagerFactory interface. The last group of 8 connection properties are unique to the PersistenceManagerFactory.

Note

Chapters 3 and 4 detail the PersistenceManager and Transaction interfaces and their properties.

The following sections describe the operations and properties of the PersistenceManagerFactory interface.




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