package org.jerrymouse.database.jdo;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jerrymouse.database.DaoAdapter;

public final class JDOPMF {
	private static PersistenceManagerFactory pmfInstance;

	private static Log log = LogFactory.getLog(JDOPMF.class);

	public static PersistenceManagerFactory get() {
		if (pmfInstance == null) {
			log.debug("pmf:" + DaoAdapter.pmfName);
			pmfInstance = JDOHelper
					.getPersistenceManagerFactory(DaoAdapter.pmfName);
		}
		return pmfInstance;
	}

	public static PersistenceManager getPersistenceManager() {
		return get().getPersistenceManager();
	}

	private JDOPMF() {
	}
}
