UsedLayersModel usedLayersModel = new UsedLayersModel( usedLayers );
List<ModuleModel> moduleModels = new ArrayList<>();
String name = layerAssembly.name();
if( name == null )
{
throw new AssemblyException( "Layer must have name set" );
}
ActivatorsModel<Layer> layerActivators = new ActivatorsModel<>( layerAssembly.activators() );
LayerModel layerModel = new LayerModel( name, layerAssembly.metaInfo(), usedLayersModel, layerActivators, moduleModels );
for( ModuleAssemblyImpl moduleAssembly : layerAssembly.moduleAssemblies() )
{
moduleModels.add( moduleAssembly.assembleModule( helper ) );
}
mapAssemblyModel.put( layerAssembly, layerModel );
layerModels.add( layerModel );
}
// Populate used layer lists
for( LayerAssemblyImpl layerAssembly : layerAssemblies )
{
Set<LayerAssembly> usesLayers = layerAssembly.uses();
List<LayerModel> usedLayers = mapUsedLayers.get( layerAssembly );
for( LayerAssembly usesLayer : usesLayers )
{
LayerModel layerModel = mapAssemblyModel.get( usesLayer );
usedLayers.add( layerModel );
}
}
// Bind model
// This will resolve all dependencies
try
{
// applicationModel.bind();
applicationModel.accept( new BindingVisitor( applicationModel ) );
}
catch( BindingException e )
{
throw new AssemblyException( "Unable to bind: " + applicationModel, e );
}
return applicationModel;
}