1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.core
.analysis
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.core
.runtime
.CoreException
;
19 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
20 import org
.eclipse
.core
.runtime
.InvalidRegistryObjectException
;
21 import org
.eclipse
.core
.runtime
.Platform
;
22 import org
.eclipse
.tracecompass
.internal
.tmf
.core
.Activator
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModuleSource
;
26 * Utility class for accessing TMF analysis module extensions from the
27 * platform's extensions registry and returning the module sources.
29 * @author Geneviève Bastien
31 public final class TmfAnalysisModuleSources
{
33 /** Extension point ID */
34 public static final String TMF_ANALYSIS_TYPE_ID
= "org.eclipse.linuxtools.tmf.core.analysis"; //$NON-NLS-1$
36 /** Extension point element 'module' */
37 public static final String SOURCE_ELEM
= "source"; //$NON-NLS-1$
39 /** Extension point attribute 'class' */
40 public static final String CLASS_ATTR
= "class"; //$NON-NLS-1$
42 private TmfAnalysisModuleSources() {
47 * Return the analysis module sources advertised in the extension
48 * point, in iterable format.
50 * @return List of {@link IAnalysisModuleSource}
52 public static Iterable
<IAnalysisModuleSource
> getSources() {
53 List
<IAnalysisModuleSource
> sources
= new ArrayList
<>();
54 // Get the sources element from the extension point
55 IConfigurationElement
[] config
= Platform
.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID
);
56 for (IConfigurationElement ce
: config
) {
57 String elementName
= ce
.getName();
58 if (elementName
.equals(SOURCE_ELEM
)) {
60 IAnalysisModuleSource source
= (IAnalysisModuleSource
) ce
.createExecutableExtension(CLASS_ATTR
);
62 } catch (InvalidRegistryObjectException e
) {
63 Activator
.logError("Error creating module source", e
); //$NON-NLS-1$
64 } catch (CoreException e
) {
65 Activator
.logError("Error creating module source", e
); //$NON-NLS-1$