* @param the abstract archive
*/
public void write(Application application, ReadableArchive in,
WritableArchive out) throws IOException {
if (application.isVirtual()) {
ModuleDescriptor aModule = (ModuleDescriptor) application.getModules().iterator().next();
Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType());
write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, in, out);
} else {
// this is a real application.
// let's start by writing out all submodules deployment descriptors
for (ModuleDescriptor aModule : application.getModules()) {
Archivist moduleArchivist = archivistFactory.getArchivist(aModule.getModuleType());
WritableArchive moduleArchive = out.createSubArchive(aModule.getArchiveUri());
ReadableArchive moduleArchive2 = in.getSubArchive(aModule.getArchiveUri());
write((BundleDescriptor)aModule.getDescriptor(), moduleArchivist, moduleArchive2, moduleArchive);
}
// now let's write the application descriptor
ApplicationArchivist archivist = archivistProvider.get();
archivist.setDescriptor(application);