* 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
--- /dev/null
+/*******************************************************************************
+ * 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);
+}
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
}
}
+ /**
+ * 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);
+ }
+ }
+ }
+
}
}
}
module.setTrace(trace);
+ TmfAnalysisManager.analysisModuleCreated(module);
} catch (CoreException e) {
Activator.logError("Error getting analysis modules from configuration files", e); //$NON-NLS-1$
}