Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SwImportFacade.java

Go to the documentation of this file.
00001 
00059 package com.arcle.rmt.j2se.bridge.swimport;
00060 
00061 import java.util.Iterator;
00062 import java.util.Collection;
00063 import java.util.Arrays;
00064 import java.io.PrintWriter;
00065 import java.lang.ref.SoftReference;
00066 
00067 import com.arcle.rmt.j2se.bridge.swimport.rqml.*;
00068 import com.arcle.rmt.superwaba.model.Document;
00069 import com.arcle.rmt.j2se.model.RQMLDocument;
00070 
00080 public final class SwImportFacade {
00084     private SwImportFacade() {  }
00085 
00099     public boolean importFirstClass(Document srcDoc,
00100             RQMLDocument dstDoc, PrintWriter log) {
00101         boolean ok = true;
00102         boolean success;
00103         Iterator iter = getImporters().iterator();
00104         while (iter.hasNext()) {
00105             FirstClassImporter importer = (FirstClassImporter) iter.next();
00106             success = importer.importFirstClass(srcDoc, dstDoc);
00107             if (!success) {
00108                 log.println("Import failed for: " + importer);
00109             }
00110             ok &= success;
00111         }
00112         return ok;
00113     }
00114 
00115     //-----------------------------------------------------------------------
00116     // Accessor Methods
00117 
00121     public synchronized static SwImportFacade getInstance() {
00122         if (_instance == null) {
00123             _instance = new SwImportFacade();
00124         }
00125         return _instance;
00126     }
00127 
00133     protected synchronized Collection getImporters() {
00134         Collection imp = (Collection) _importers.get();
00135         if (imp == null) {
00136             imp = createImporters();
00137             _importers = new SoftReference(imp);
00138         }
00139         return imp;
00140     }
00141 
00142     //-----------------------------------------------------------------------
00143     // Factory methods
00144 
00166     protected Collection createImporters() {
00167         return Arrays.asList(new FirstClassImporter[] {
00168             new RequirementImport(),
00169             new UsecaseImport(),
00170             new StakeholderImport(),
00171             new AssumptionImport(),
00172             new IssueImport(),
00173             new LexiconImport(),
00174             new ContextImport(),
00175             new TaxonomyImport(),
00176             new ProjectImport()
00177         });
00178     }
00179 
00180     //-----------------------------------------------------------------------
00181     // Member variables
00182 
00187     private SoftReference _importers = new SoftReference(null);
00188 
00192     private static SwImportFacade _instance = null;
00193 }

Generated on Fri Jun 18 19:51:26 2004 for Arcle Rambutan by doxygen 1.3.5