for( ImportedServiceAssemblyImpl importedServiceDeclaration : importedServiceAssemblies.values() )
{
importedServiceDeclaration.addImportedServiceModel( importedServiceModels );
}
ModuleModel moduleModel = new ModuleModel( name,
metaInfo,
new ActivatorsModel<>( activators ),
new TransientsModel( transientModels ),
new EntitiesModel( entityModels ),
new ObjectsModel( objectModels ),
new ValuesModel( valueModels ),
new ServicesModel( serviceModels ),
new ImportedServicesModel( importedServiceModels ) );
// Check for duplicate service identities
Set<String> identities = new HashSet<>();
for( ServiceModel serviceModel : serviceModels )
{
String identity = serviceModel.identity();
if( identities.contains( identity ) )
{
throw new DuplicateServiceIdentityException(
"Duplicated service identity: " + identity + " in module " + moduleModel.name()
);
}
identities.add( identity );
}
for( ImportedServiceModel serviceModel : importedServiceModels )
{
String identity = serviceModel.identity();
if( identities.contains( identity ) )
{
throw new DuplicateServiceIdentityException(
"Duplicated service identity: " + identity + " in module " + moduleModel.name()
);
}
identities.add( identity );
}