TMF: Add new analysis module listener called when module are being instantiated
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 5 Feb 2014 19:13:02 +0000 (14:13 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 19 Feb 2014 15:48:36 +0000 (10:48 -0500)
Those listeners are managed by the analysis manager and the helpers need to
call a method from the analysis manager when they instantiate new module
objects so that the listeners are run on this module.

This will allow among other to associate the applicable outputs to the
analysis module being created.

Change-Id: I004e2b83dd233d8e9971807a517f37817f503ea0
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/21579
Tested-by: Hudson CI
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
IP-Clean: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModuleHelper.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/ITmfNewAnalysisModuleListener.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java

index 04b46436feed0ca9f170090bfac5789105da1210..184bfbd012407795a61ea9418de3233509ef3875 100644 (file)
@@ -98,6 +98,10 @@ public interface IAnalysisModuleHelper {
      * Creates a new instance of the {@link IAnalysisModule} represented by this
      * helper and initializes it with the trace.
      *
+     * After the module is fully created, this method should call
+     * {@link TmfAnalysisManager#analysisModuleCreated(IAnalysisModule)} in order
+     * for the new module listeners to be executed on this module.
+     *
      * @param trace
      *            The trace to be linked to the module
      * @return A new {@link IAnalysisModule} instance initialized with the
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/ITmfNewAnalysisModuleListener.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/ITmfNewAnalysisModuleListener.java
new file mode 100644 (file)
index 0000000..8ec84ae
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.analysis;
+
+/**
+ * This is the interface class must implement to listen to new analysis module
+ * objects being instantiated.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public interface ITmfNewAnalysisModuleListener {
+
+    /**
+     * Method called when an analysis module has just been instantiated.
+     *
+     * @param module
+     *            The newly instantiated analysis module
+     */
+    public void moduleCreated(IAnalysisModule module);
+}
index a063125ce3d220dff1f074e91ea02bb5396f4900..7a08e28490135392d3f5ef0b73486ffbd175426c 100644 (file)
@@ -38,6 +38,7 @@ public class TmfAnalysisManager {
     private static final Map<String, List<Class<? extends IAnalysisParameterProvider>>> fParameterProviders = new HashMap<>();
     private static final Map<Class<? extends IAnalysisParameterProvider>, IAnalysisParameterProvider> fParamProviderInstances = new HashMap<>();
     private static final List<IAnalysisModuleSource> fSources = new ArrayList<>();
+    private static final List<ITmfNewAnalysisModuleListener> fListeners = new ArrayList<>();
 
     /**
      * Registers a new source of modules
@@ -184,4 +185,20 @@ public class TmfAnalysisManager {
         }
     }
 
+    /**
+     * This method should be called when new analysis modules have been created
+     * by module helpers to that the {@link ITmfNewAnalysisModuleListener} can
+     * be executed on the module instance.
+     *
+     * @param module
+     *            The newly created analysis module
+     */
+    public static void analysisModuleCreated(IAnalysisModule module) {
+        synchronized (fListeners) {
+            for (ITmfNewAnalysisModuleListener listener : fListeners) {
+                listener.moduleCreated(module);
+            }
+        }
+    }
+
 }
index 6bd1892b21ac9ab0bbce9a846f6c64495baeb01f..5b5a94e1bd194348ad82088aa4242322016eecfd 100644 (file)
@@ -140,6 +140,7 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp
                 }
             }
             module.setTrace(trace);
+            TmfAnalysisManager.analysisModuleCreated(module);
         } catch (CoreException e) {
             Activator.logError("Error getting analysis modules from configuration files", e); //$NON-NLS-1$
         }
This page took 0.02743 seconds and 5 git commands to generate.