{
List<VirtualFile> archives = root.getChildren();
if (archives != null)
{
String earPath = root.getPathName();
ModulesMetaData modules = j2eeMetaData.getModules();
if (modules == null)
{
modules = new ModulesMetaData();
j2eeMetaData.setModules(modules);
}
for (VirtualFile vfArchive : archives)
{
String filename = earRelativePath(earPath, vfArchive.getPathName());
// Check if the module already exists, i.e. it is declared in jboss-app.xml
ModuleMetaData moduleMetaData = j2eeMetaData.getModule(filename);
int type = typeFromSuffix(unit, filename, vfArchive);
if (type >= 0 && moduleMetaData == null)
{
moduleMetaData = new ModuleMetaData();
AbstractModule module = null;
switch(type)
{
case J2eeModuleMetaData.EJB:
module = new EjbModuleMetaData();
break;
case J2eeModuleMetaData.CLIENT:
module = new JavaModuleMetaData();
break;
case J2eeModuleMetaData.CONNECTOR:
module = new ConnectorModuleMetaData();
break;
case J2eeModuleMetaData.SERVICE:
case J2eeModuleMetaData.HAR:
module = new ServiceModuleMetaData();
break;
case J2eeModuleMetaData.WEB:
module = new WebModuleMetaData();
break;
}
module.setFileName(filename);
moduleMetaData.setValue(module);
modules.add(moduleMetaData);
}
}
}
}