Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/meta/RegistryFactory.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.meta; | |
2 | |
3 import java.io.File; | |
4 import java.io.IOException; | |
5 | |
6 import java.util.Map; | |
7 import java.util.HashMap; | |
8 | |
9 import org.dancres.blitz.disk.Disk; | |
10 | |
11 public class RegistryFactory { | |
12 private static Map theMetas = new HashMap(); | |
13 | |
14 /** | |
15 @param aName the name of the registry you wish to load/create | |
16 @param anInitializer Registry instances are created under a transaction. | |
17 Certain uses may require that initialization be done under the same | |
18 transaction. In these cases, the caller should pass in an Initializer | |
19 instance containing the appropriate "boot code". If no initialization | |
20 is required, the caller may pass <code>null</code>. | |
21 */ | |
22 public static Registry get(String aName, Initializer anInitializer) | |
23 throws IOException { | |
24 | |
25 synchronized(theMetas) { | |
26 Registry myData = (Registry) theMetas.get(aName); | |
27 | |
28 if (myData == null) { | |
29 myData = new RegistryImpl(aName, anInitializer); | |
30 theMetas.put(aName, myData); | |
31 } | |
32 | |
33 return myData; | |
34 } | |
35 } | |
36 | |
37 public static boolean exists(String aName) { | |
38 return RegistryImpl.exists(aName); | |
39 } | |
40 | |
41 public static void delete(String aName) throws IOException { | |
42 synchronized(theMetas) { | |
43 RegistryImpl myData = (RegistryImpl) theMetas.get(aName); | |
44 | |
45 if (myData != null) { | |
46 theMetas.remove(aName); | |
47 myData.delete(); | |
48 } | |
49 } | |
50 } | |
51 } |