String modid = getAttribute(modnode, "id");
String modref = getAttribute(modnode, "ref");
String url = getAttribute(modnode, "url");
if (modid == null)
throw new InvalidConfigurationException("Unnamed module.");
if (url == null && modref == null)
modref = modid; // compatibility
ModuleDefinition parent;
if (modref != null)
{
parent = id2mod.get(modref);
if (parent == null)
throw new InvalidConfigurationException(String.format("Module %s: Module interface specification is missing.", modid));
}
else
parent = cfg.getRootModule();
ModuleInterface iface = null;
if (url!=null)
iface = new ModuleInterfaceFrontend(cfg, url);
Map<String,UntypedValue> atts = extractAttributes(modnode);
if (pipeline_mods == null)
{
ModuleDefinition moddef = ModuleDefinition.create(parent, url, iface, extractCachePolicy(modnode), atts);
if (moddef.getInterface() == null)
throw new InvalidConfigurationException(String.format("Module %s: Incomplete module definition.", modid));
mod2id.put(moddef, modid);
if (!id2mod.containsKey(modid))
{
cfg.addModule(moddef);
for (String path : extractExportPaths(modnode))
cfg.getExports().put(path, moddef);
id2mod.put(modid, moddef);
}
return moddef;
}
else
{
PipelineModule moddef = new PipelineModule(parent, extractCachePolicy(modnode), atts);
if (moddef.getInterface() == null)
throw new InvalidConfigurationException(String.format("Module %s: Incomplete module definition.", modid));
pipeline_mods.put(modid, moddef);
return moddef;
}
}