ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / analysis / TmfAnalysisModuleSources.java
CommitLineData
b3b03da0 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
b3b03da0
GB
3 *
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
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.internal.tmf.core.analysis;
14
15import java.util.ArrayList;
16import java.util.List;
17
18import org.eclipse.core.runtime.CoreException;
19import org.eclipse.core.runtime.IConfigurationElement;
20import org.eclipse.core.runtime.InvalidRegistryObjectException;
21import org.eclipse.core.runtime.Platform;
22import org.eclipse.linuxtools.internal.tmf.core.Activator;
23import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleSource;
24
25/**
26 * Utility class for accessing TMF analysis module extensions from the
27 * platform's extensions registry and returning the module sources.
28 *
29 * @author Geneviève Bastien
30 */
31public final class TmfAnalysisModuleSources {
32
33 /** Extension point ID */
34 public static final String TMF_ANALYSIS_TYPE_ID = "org.eclipse.linuxtools.tmf.core.analysis"; //$NON-NLS-1$
35
36 /** Extension point element 'module' */
37 public static final String SOURCE_ELEM = "source"; //$NON-NLS-1$
38
39 /** Extension point attribute 'class' */
40 public static final String CLASS_ATTR = "class"; //$NON-NLS-1$
41
42 private TmfAnalysisModuleSources() {
43
44 }
45
46 /**
47 * Return the analysis module sources advertised in the extension
48 * point, in iterable format.
49 *
50 * @return List of {@link IAnalysisModuleSource}
51 */
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)) {
59 try {
60 IAnalysisModuleSource source = (IAnalysisModuleSource) ce.createExecutableExtension(CLASS_ATTR);
61 sources.add(source);
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$
66 }
67
68 }
69 }
70 return sources;
71 }
72}
This page took 0.053411 seconds and 5 git commands to generate.