Author: michiel
Date: 2010-04-13 18:08:20 +0200 (Tue, 13 Apr 2010)
New Revision: 41916

Modified:
   mmbase/trunk/bridge/src/main/java/org/mmbase/module/Module.java
Log:
made it possible to limit the modules which are implicitely started. Perhaps 
for test-cases

Modified: mmbase/trunk/bridge/src/main/java/org/mmbase/module/Module.java
===================================================================
--- mmbase/trunk/bridge/src/main/java/org/mmbase/module/Module.java     
2010-04-13 15:49:37 UTC (rev 41915)
+++ mmbase/trunk/bridge/src/main/java/org/mmbase/module/Module.java     
2010-04-13 16:08:20 UTC (rev 41916)
@@ -493,13 +493,14 @@
 
     /**
      * Makes sure that modules are loaded and started.
+     * @param names Limit to these modules.
      * @since MMBase-1.9
      */
-    private static synchronized void checkModules(boolean startOnLoad) {
+    public static synchronized void checkModules(boolean startOnLoad, 
String... names) {
         // are the modules loaded yet ? if not load them
         if (modules == null) { // still null after obtaining lock
             log.service("Loading MMBase modules...");
-            modules = loadModulesFromDisk();
+            modules = loadModulesFromDisk(names);
             if (log.isDebugEnabled()) {
                 log.debug("Modules not loaded, loading them..");
             }
@@ -566,7 +567,11 @@
      * @return A HashTable with <module-name> --> Module-instance
      */
     @SuppressWarnings("deprecation")
-    private static synchronized Map<String, Module>  loadModulesFromDisk() {
+    private static synchronized Map<String, Module>  
loadModulesFromDisk(String... names) {
+        Set<String> namesSet = new HashSet<String>();
+        for (String n : names) {
+            namesSet.add(n);
+        }
         Map<String, Module> results = Collections.synchronizedMap(new 
TreeMap<String, Module>());
         ResourceLoader moduleLoader = getModuleLoader();
         Collection<String> mods = 
moduleLoader.getResourcePaths(ResourceLoader.XML_PATTERN, false/* 
non-recursive*/);
@@ -585,6 +590,11 @@
                 if (moduleName == null) {
                     moduleName = ResourceLoader.getName(file);
                 }
+                if (namesSet.size() > 0 && ! namesSet.contains(moduleName)) {
+                    log.info("Skipping " + moduleName);
+                    continue;
+                }
+
                 String className = parser.getClassName();
                 // try starting the module and give it its properties
                 try {

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to