01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdo;
12:
13: import javax.jdo.PersistenceManagerFactory;
14: import javax.jdo.JDOHelper;
15: import java.util.Properties;
16:
17: /**
18: * Bootstrap class for JDOHelper.getPersistenceManagerFactory. This checks
19: * the 'versant.host' property to see if remote access is required and delegates to
20: * the appropriate PMF class.
21: */
22: public class BootstrapPMF {
23:
24: /**
25: * This is called be JDOHelper to construct a PM factory from a properties
26: * file.
27: */
28: public static PersistenceManagerFactory getPersistenceManagerFactory(
29: Properties props) {
30: String 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
39: .setProperty(
40: "javax.jdo.PersistenceManagerFactoryClass",
41: "com.versant.core.jdo.remote.RemotePersistenceManagerFactory");
42: return JDOHelper.getPersistenceManagerFactory(props,
43: BootstrapPMF.class.getClassLoader());
44: }
45: return PersistenceManagerFactoryImp
46: .getPersistenceManagerFactory(props);
47: }
48:
49: }
|