summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/process/ModuleManager.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2012-06-14 11:35:25 +0200
committerAndrew Branson <andrew.branson@cern.ch>2012-06-14 11:35:25 +0200
commitf20547a9f617a971d7dfa64a5a4564cd2f013170 (patch)
tree03cfcd0b2b344abedfcf857d320a3532a4649b49 /src/main/java/com/c2kernel/process/ModuleManager.java
parente55bf67f1ba4565ba2816ba58ab13b27807dd540 (diff)
Created ModuleException
Diffstat (limited to 'src/main/java/com/c2kernel/process/ModuleManager.java')
-rw-r--r--src/main/java/com/c2kernel/process/ModuleManager.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/com/c2kernel/process/ModuleManager.java b/src/main/java/com/c2kernel/process/ModuleManager.java
index e7be9e8..b336681 100644
--- a/src/main/java/com/c2kernel/process/ModuleManager.java
+++ b/src/main/java/com/c2kernel/process/ModuleManager.java
@@ -1,5 +1,6 @@
package com.c2kernel.process;
+import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -16,23 +17,30 @@ public class ModuleManager {
Properties props = new Properties();
boolean isServer;
- public ModuleManager(Enumeration<URL> moduleEnum, boolean isServer) {
+ public ModuleManager(Enumeration<URL> moduleEnum, boolean isServer) throws ModuleException{
this.isServer = isServer;
ArrayList<String> loadedModules = new ArrayList<String>();
+ ArrayList<String> moduleNs = new ArrayList<String>();
while(moduleEnum.hasMoreElements()) {
URL newModuleURL = moduleEnum.nextElement();
try {
Module newModule = new Module(FileStringUtility.url2String(newModuleURL));
modules.add(newModule);
- loadedModules.add(newModule.getName());
+ if (loadedModules.contains(newModule.getName())) throw new ModuleException("Module name clash: "+newModule.getName());
+ if (moduleNs.contains(newModule.getNs())) throw new ModuleException("Module namespace clash: "+newModule.getNs());
+ Logger.debug(4, "Module found: "+newModule.getNs()+" - "+newModule.getName());
+ loadedModules.add(newModule.getName()); moduleNs.add(newModule.getNs());
Properties modProp = isServer?newModule.getServerProperties():newModule.getClientProperties();
for (Enumeration<?> e = modProp.propertyNames(); e.hasMoreElements();) {
String propName = (String)e.nextElement();
props.put(propName, modProp.get(propName));
}
- } catch (Exception e) {
+ } catch (ModuleException e) {
Logger.error("Could not load module description from "+newModuleURL);
+ throw e;
+ } catch (IOException e) {
Logger.error(e);
+ throw new ModuleException("Could not load module.xml from "+newModuleURL);
}
}
@@ -74,7 +82,7 @@ public class ModuleManager {
ItemProxy serverEntity = (ItemProxy)Gateway.getProxyManager().getProxy(new DomainPath("/servers/"+Gateway.getProperty("ItemServer.name")));
Logger.debug(3, "Registering modules");
for (Module thisMod : modules) {
- Logger.debug(4, "Registering module "+thisMod.getName());
+ Logger.msg("Registering module "+thisMod.getName());
thisMod.importAll(serverEntity);
Logger.msg("Module "+thisMod.getName()+" registered");
}