KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > model > ModelsManager


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9  */

10
11 package org.mmbase.model;
12
13 import org.mmbase.util.logging.*;
14 import org.mmbase.util.*;
15 import java.util.*;
16
17 public class ModelsManager {
18
19     private static Logger log = Logging.getLoggerInstance(ModelsManager.class);
20     private static HashMap models = new HashMap();
21
22     static {
23         init();
24     }
25
26     public static void init() {
27         ResourceLoader applicationLoader = ResourceLoader.getConfigurationRoot().getChildResourceLoader("applications");
28         Iterator i = applicationLoader.getResourcePaths(ResourceLoader.XML_PATTERN, false).iterator();
29         while (i.hasNext()) {
30             String JavaDoc modelname = (String JavaDoc) i.next();
31         addModel(modelname.substring(0,modelname.length()-4),"applications/"+modelname);
32         }
33     }
34
35
36     public static CloudModel addModel(String JavaDoc modelname,String JavaDoc path) {
37     CloudModel cm = new CloudModel(modelname);
38     cm.setPath(path);
39     models.put(modelname,cm);
40     return cm;
41     }
42
43     public static CloudModel getModel(String JavaDoc name) {
44     return (CloudModel)models.get(name);
45     }
46
47 }
48
Popular Tags