From b53164978a9a264fbe26679c07e32731a4d495f9 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 6 Jul 2012 15:50:45 +0200 Subject: Remove XML parsing from module processing, use Castor unmarshalling instead. Create module item with collection of imported Items and module XML registered as an outcome. --- src/main/java/com/c2kernel/process/module/ModuleManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/c2kernel/process/module/ModuleManager.java') diff --git a/src/main/java/com/c2kernel/process/module/ModuleManager.java b/src/main/java/com/c2kernel/process/module/ModuleManager.java index ca47ec9..0870c6f 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleManager.java +++ b/src/main/java/com/c2kernel/process/module/ModuleManager.java @@ -4,6 +4,7 @@ import java.net.URL; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.Properties; import com.c2kernel.common.CannotManageException; @@ -16,9 +17,11 @@ import com.c2kernel.process.Gateway; import com.c2kernel.scripting.ScriptingEngineException; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; +import com.c2kernel.utils.Resource; public class ModuleManager { ArrayList modules = new ArrayList(); + HashMap modulesXML = new HashMap(); Properties props = new Properties(); boolean isServer; @@ -29,10 +32,11 @@ public class ModuleManager { while(moduleEnum.hasMoreElements()) { URL newModuleURL = moduleEnum.nextElement(); try { - //Module newModule = (Module)Gateway.getMarshaller().unmarshall(FileStringUtility.url2String(newModuleURL)); - //Resource.addModuleBaseURL(newModule.ns, newModule.resURL); - Module newModule = new Module(FileStringUtility.url2String(newModuleURL)); + String moduleXML = FileStringUtility.url2String(newModuleURL); + Module newModule = (Module)Gateway.getMarshaller().unmarshall(moduleXML); + Resource.addModuleBaseURL(newModule.ns, newModule.resURL); modules.add(newModule); + modulesXML.put(newModule.ns, moduleXML); 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()); @@ -96,7 +100,7 @@ public class ModuleManager { Logger.debug(3, "Registering modules"); for (Module thisMod : modules) { Logger.msg("Registering module "+thisMod.getName()); - thisMod.importAll(serverEntity); + thisMod.importAll(serverEntity, modulesXML.get(thisMod.ns)); Logger.msg("Module "+thisMod.getName()+" registered"); } } -- cgit v1.2.3