if (modules == null)
{
throw new DeploymentException(unit + " has attached " + JBossAppMetaData.class.getSimpleName() +
" but it has no associated " + ModulesMetaData.class.getSimpleName());
}
ModuleMetaData ourModule = null;
String uniqueName = null;
// Synchronize on the modules to ensure concurrent deployments of the
// modules pass serially through this logic
synchronized(modules)
{
ourModule = modules.get(modulePath);
if (ourModule == null)
{
String parentUnitName = unit.getParent().getName();
throw new DeploymentException("No module with relative path " +
modulePath + " found in set of modules for " + parentUnitName + " " + modules.keySet());
}
uniqueName = name;
if (!isNameUnique(uniqueName, ourModule, modules))
{
// Try the relative path w/ extension removed
uniqueName = trimExtension(unit.getRelativePath());
if (uniqueName.equals(name) || !isNameUnique(uniqueName, ourModule, modules))
{
// Try leaving the extension
uniqueName = unit.getRelativePath();
if (!isNameUnique(uniqueName, ourModule, modules))
{
// To get here, people would have to configure in xml a
// module name that conflicts with the relative path of
// another module. Not likely, but...
// Append a digit until the name is unique
int i = 0;
do
{
i++;
uniqueName = name + "-" + i;
}
while (!isNameUnique(uniqueName, ourModule, modules));
}
}
}
ourModule.setUniqueName(uniqueName);
}
// Log a WARN if we had to change the module name
if (configuredName != null && !configuredName.equals(uniqueName))