I have a static initialisation method and two static data members as follows:
public class DataExchange { private static final Object objLockPMF = new Object(); private static volatile PersistenceManagerFactory g_pmf = null; /** * If this class's static singleton <code>PersistenceManagerFactory</code> * is <code>null</code>, then construct it in a synchronised block of code. * @return * This class's static singleton <code>PersistenceManagerFactory</code>. */ public static PersistenceManagerFactory getPersistenceManagerFactory() { if (g_pmf == null) synchronized(objLockPMF) { if (g_pmf == null) { loadProperties(); // My method which loads the string g_sDatabaseMode g_pmf = JDOHelper.getPersistenceManagerFactory(g_sDatabaseMode); } } return g_pmf; } } I then call the above static method when my Wicket application initiates by creating a queued task which calls this method fairly immediately but asynchronously. I ensure that my home page performs no data exchange, so creating the PMF does not delay the showing of the first page. I also call the above static method at the start of every data exchange. There will be nothing to construct unless the queued task has not yet finished or GAE has shut the relevant Wicket application instance down. For example (which will not be a surprise) when using a transaction: PersistenceManager pm = DataExchange.getPersistenceManagerFactory().getPersistenceManager(); Transaction tx = pm.currentTransaction(); try { tx.begin(); // // Persistence code // tx.commit(); } finally { try { if (tx.isActive()) // Because of an exception, say tx.rollback(); } finally { pm.close(); } } Enjoy, Ian intmanch wrote: > > Hi Ian, > > Thanks a lot for your response. I use as you PMF, not JPA, that's quite > simple and easy to use. Can you give me more details (code snippet) about > the initialization of the PMF? Is there any other point to take into > consideration for the performance? > -- View this message in context: http://old.nabble.com/Wicket-GAE-performance-tp28118591p28133464.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org