Interrogating the PersistenceManagerFactory


JDOFactory is a utility class that can interrogate the factory for its default settings and supported options. JDOFactory also illustrates the use of the adaptor pattern to localize the vendor dependencies inherent in construction. Unlike most other example programs with this book, TestFactory uses construction to acquire a persistence manager factory. The TestFactory program writes the results of the interrogation to the console. After obtaining a persistence manager, it terminates. The TestFactory class is contained in the com.ysoft.jdo.book.factory.client package.

Building and Running the TestFactory Program

To build the TestFactory program, go to the bookants directory and type ant testfactory. This build is part of the ant learning-programs build. Listing 8-3 shows some of the expected output when using the reference implementation.

Listing 8-3: Expected Output from Running ant testfactory

start example
 testfactory:     [echo] creating runTestFactory.bat     [echo] Running TestFactory     [java] Starting TestFactory ...     [java] Using adaptor class: com.ysoft.jdo.book.factory.jdori.JDORIAdaptor     [java] The database (FOStoreTestDB.btd) exists     [java] Using URL: (fostore:FOStoreTestDB)     [java] Loaded factory adaptor: com.ysoft.jdo.book.factory.jdori.JDORIAdaptor     [java]     [java] Supported JDO Options     [java]    javax.jdo.option.TransientTransactional     [java]    javax.jdo.option.NontransactionalRead     [java]    javax.jdo.option.NontransactionalWrite     [java]    javax.jdo.option.RetainValues     [java]    javax.jdo.option.RestoreValues     [java]    javax.jdo.option.Optimistic     [java]    javax.jdo.option.ApplicationIdentity     [java]    javax.jdo.option.DatastoreIdentity     [java]    javax.jdo.option.ArrayList     [java]    javax.jdo.option.HashMap     [java]    javax.jdo.option.Hashtable     [java]    javax.jdo.option.LinkedList     [java]    javax.jdo.option.TreeMap     [java]    javax.jdo.option.TreeSet     [java]    javax.jdo.option.Vector     [java]    javax.jdo.option.Array     [java]    javax.jdo.option.NullCollection     [java]    javax.jdo.query.JDOQL     [java] Unsupported JDO Options     [java]    javax.jdo.option.NonDurableIdentity     [java]    javax.jdo.option.ChangeApplicationIdentity     [java]    javax.jdo.option.List     [java]    javax.jdo.option.Map     [java] Non-configurable properties     [java]    Key: VendorName, value: Sun Microsystems     [java]    Key: VersionNumber, value: 1.0     [java] Initial PMF transaction settings     [java]    Optimistic: true     [java]    Non-trans read: true     [java]    Non-trans write: false     [java]    RetainValues: true     [java]    RestoreValues: true     [java] Connection information     [java]    Connection driver: null     [java]    Connection factory: null     [java]    Connection factory2: null     [java]    Connection URL: fostore:FOStoreTestDB     [java]    Connection UserName: JDO     [java] Caching info     [java]    Ignore Cache: true     [java] Threading setting for PM's     [java]    Multithreading turned on: false     [java] This PMF can be serialized     [java] This PMF implements javax.naming.Referenceable     [java] Obtained PersistenceManagerFactory     [java] Just got 1 PersistenceManagers!     [java] Closing FOStoreDB     [java] -- All done!     [echo] created runTestFactory.bat BUILD SUCCESSFUL 
end example

Like the previous example, the build, after running TestFactory, also creates the batch file runTestFactory that can be used to run it again. The TestFactory program has no user interface. It runs to completion in a few seconds.




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