tmf : Move initialization steps of modules into analysisReady() method
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / statistics / TmfStatisticsModule.java
index 5755f15082a4676e6909030b9ab62c96b57c520d..297a0f2a4aa411548447fe8e71e6541433ae49ba 100644 (file)
@@ -118,8 +118,7 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
         ITmfTrace trace = getTrace();
         if (trace == null) {
             /* This analysis was cancelled in the meantime */
-            fInitializationSucceeded = false;
-            fInitialized.countDown();
+            analysisReady(false);
             return false;
         }
 
@@ -127,15 +126,13 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
         IStatus status2 = eventTypesModule.schedule();
         if (!(status1.isOK() && status2.isOK())) {
             cancelSubAnalyses();
-            fInitializationSucceeded = false;
-            fInitialized.countDown();
+            analysisReady(false);
             return false;
         }
 
         /* Wait until the two modules are initialized */
         if (!totalsModule.waitForInitialization() || !eventTypesModule.waitForInitialization()) {
-            fInitializationSucceeded = false;
-            fInitialized.countDown();
+            analysisReady(false);
             return false;
         }
 
@@ -144,16 +141,14 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
 
         if (totalsSS == null || eventTypesSS == null) {
             /* This analysis was cancelled in the meantime */
-            fInitializationSucceeded = false;
-            fInitialized.countDown();
+            analysisReady(false);
             throw new IllegalStateException("TmfStatisticsModule : Sub-modules initialization succeeded but there is a null state system."); //$NON-NLS-1$
         }
 
         fStatistics = new TmfStateStatistics(totalsSS, eventTypesSS);
 
         /* fStatistics is now set, consider this module initialized */
-        fInitializationSucceeded = true;
-        fInitialized.countDown();
+        analysisReady(true);
 
         /*
          * The rest of this "execute" will encompass the "execute" of the two
@@ -166,6 +161,19 @@ public class TmfStatisticsModule extends TmfAbstractAnalysisModule
         return true;
     }
 
+    /**
+     * Make the module available and set whether the initialization went well or
+     * not. If not, no state system is available and
+     * {@link #waitForInitialization()} should return false.
+     *
+     * @param success
+     *            True if the initialization went well, false otherwise
+     */
+    private void analysisReady(boolean succeeded) {
+        fInitializationSucceeded = succeeded;
+        fInitialized.countDown();
+    }
+
     @Override
     protected void canceling() {
         /*
This page took 0.031413 seconds and 5 git commands to generate.