In order to access the functionalities of the JDO API you have to
deal with a special facade object that serves as the main entry point
to all JDO operations. This facade is specified by the Interface
javax.jdo.PersistenceManager.
A Vendor of a JDO compliant product must provide a specific
implementation of the javax.jdo.PersistenceManager
interface. JDO also specifies that a JDO implementation must provide a
javax.jdo.PersistenceManagerFactory
implementation that is
responsible for generating javax.jdo.PersistenceManager
instances.
So if you know how to use the JDO API you only have to learn how to obtain
the OJB specific PersistenceManagerFactory object. Ideally this will be
the only vendor specific operation.
In our tutorial application the PersistenceManagerFactory
object is
obtained in the constructor of the Application class and reached to
the use case implementations for further usage:
 |  |  |
 |
public Application()
{
factory = null;
manager = null;
try
{
// create OJB specific factory:
factory = new OjbStorePMF();
}
catch (Throwable t)
{
System.out.println("ERROR: " + t.getMessage());
t.printStackTrace();
}
useCases = new Vector();
useCases.add(new UCListAllProducts(factory));
useCases.add(new UCEnterNewProduct(factory));
useCases.add(new UCEditProduct(factory));
useCases.add(new UCDeleteProduct(factory));
useCases.add(new UCQuitApplication(factory));
}
|  |
 |  |  |
The class org.apache.ojb.jdori.sql.OjbStorePMF
is
the OJB specific javax.jdo.PersistenceManagerFactory
implementation.
TODO: Put information about the .jdo files
The PersistenceManagerFactory
object is reached to the constructors of the
UseCases. These constructors store it in a protected attribute factory
for further usage.