01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10:
11: package org.mmbase.model;
12:
13: import org.mmbase.util.*;
14: import java.util.*;
15:
16: /**
17: * @javadoc
18: */
19: public class ModelsManager {
20:
21: private static Map<String, CloudModel> models = new HashMap<String, CloudModel>();
22:
23: static {
24: init();
25: }
26:
27: public static void init() {
28: ResourceLoader applicationLoader = ResourceLoader
29: .getConfigurationRoot().getChildResourceLoader(
30: "applications");
31: Iterator<String> i = applicationLoader.getResourcePaths(
32: ResourceLoader.XML_PATTERN, false).iterator();
33: while (i.hasNext()) {
34: String modelname = i.next();
35: addModel(modelname.substring(0, modelname.length() - 4),
36: "applications/" + modelname);
37: }
38: }
39:
40: public static CloudModel addModel(String modelname, String path) {
41: CloudModel cm = new CloudModel(modelname);
42: cm.setPath(path);
43: models.put(modelname, cm);
44: return cm;
45: }
46:
47: public static CloudModel getModel(String name) {
48: return models.get(name);
49: }
50:
51: }
|