KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > BootstrapPMF


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo;
13
14 import javax.jdo.PersistenceManagerFactory;
15 import javax.jdo.JDOHelper;
16 import java.util.Properties JavaDoc;
17
18 /**
19  * Bootstrap class for JDOHelper.getPersistenceManagerFactory. This checks
20  * the 'versant.host' property to see if remote access is required and delegates to
21  * the appropriate PMF class.
22  */

23 public class BootstrapPMF {
24
25     /**
26      * This is called be JDOHelper to construct a PM factory from a properties
27      * file.
28      */

29     public static PersistenceManagerFactory getPersistenceManagerFactory(Properties JavaDoc props) {
30         String JavaDoc host = props.getProperty("versant.host");
31         if (host == null) {
32             host = props.getProperty("host");
33             if (host != null) {
34                 props.setProperty("versant.host", host);
35             }
36         }
37         if (host != null && host.trim().length() > 0) {
38             props.setProperty(
39                     "javax.jdo.PersistenceManagerFactoryClass",
40                     "com.versant.core.jdo.remote.RemotePersistenceManagerFactory");
41             return JDOHelper.getPersistenceManagerFactory(props,
42                     BootstrapPMF.class.getClassLoader());
43         }
44         return PersistenceManagerFactoryImp.getPersistenceManagerFactory(props);
45     }
46
47 }
48
49
50
Popular Tags