Mercurial > hg > blitz_stable
view src/org/dancres/blitz/meta/RegistryFactory.java @ 23:b7e52953b7a6
Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Fri, 28 Aug 2009 17:23:33 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package org.dancres.blitz.meta; import java.io.File; import java.io.IOException; import java.util.Map; import java.util.HashMap; import org.dancres.blitz.disk.Disk; public class RegistryFactory { private static Map theMetas = new HashMap(); /** @param aName the name of the registry you wish to load/create @param anInitializer Registry instances are created under a transaction. Certain uses may require that initialization be done under the same transaction. In these cases, the caller should pass in an Initializer instance containing the appropriate "boot code". If no initialization is required, the caller may pass <code>null</code>. */ public static Registry get(String aName, Initializer anInitializer) throws IOException { synchronized(theMetas) { Registry myData = (Registry) theMetas.get(aName); if (myData == null) { myData = new RegistryImpl(aName, anInitializer); theMetas.put(aName, myData); } return myData; } } public static boolean exists(String aName) { return RegistryImpl.exists(aName); } public static void delete(String aName) throws IOException { synchronized(theMetas) { RegistryImpl myData = (RegistryImpl) theMetas.get(aName); if (myData != null) { theMetas.remove(aName); myData.delete(); } } } }