tmf: Add extension point to add custom trace types to plugins
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Sun, 27 Nov 2016 00:54:51 +0000 (01:54 +0100)
committerMarc-André Laperle <marc-andre.laperle@ericsson.com>
Fri, 2 Dec 2016 18:47:02 +0000 (13:47 -0500)
This new extension point is used to contribute custom Text or XML
trace types so that they are available automatically without the need
to be imported by the user manually.

Change-Id: Iff481d659626a8ed8d756d333ec6a240b4316b49
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/85831
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
13 files changed:
tmf/org.eclipse.tracecompass.tmf.core.tests/plugin.xml
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/AbstractCustomTraceExtensionTest.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/CustomTxtExtensionTest.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/CustomXmlExtensionTest.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/txt/testTxtExtensionDefinition.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/txt/valid/001.txt [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/xml/testXmlExtensionDefinition.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core/plugin.properties
tmf/org.eclipse.tracecompass.tmf.core/plugin.xml
tmf/org.eclipse.tracecompass.tmf.core/schema/org.eclipse.tracecompass.tmf.core.custom.trace.exsd [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java

index 7e7ec520c5fb5761b5ccff4e93eba9518188b45f..3c56bb2668929350eb94d120e7f208ca3f14fdf9 100644 (file)
             id="org.eclipse.tracecompass.tmf.core.tests.analysis1">
       </analysis>
    </extension>
+   <extension
+         point="org.eclipse.tracecompass.tmf.core.custom.trace">
+      <customTrace
+            file="testfiles/txt/testTxtExtensionDefinition.xml"
+            traceContentType="text">
+      </customTrace>
+   </extension>
+   <extension
+         point="org.eclipse.tracecompass.tmf.core.custom.trace">
+      <customTrace
+            file="testfiles/xml/testXmlExtensionDefinition.xml"
+            traceContentType="xml">
+      </customTrace>
+   </extension>
 
 </plugin>
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/AbstractCustomTraceExtensionTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/AbstractCustomTraceExtensionTest.java
new file mode 100644 (file)
index 0000000..bd5464e
--- /dev/null
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.tests.parsers.custom;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.function.Predicate;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceImportException;
+import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
+import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
+import org.junit.Test;
+
+/**
+ * Common code for custom trace type extension points tests.
+ */
+public abstract class AbstractCustomTraceExtensionTest {
+
+    /**
+     * @return Get the extension Id that will provide the trace type to test.
+     */
+    protected abstract String getExtensionId();
+
+    /**
+     * @return Get the path of the trace to test with the trace type provided by
+     *         an extension.
+     */
+    protected abstract String getTestTracePath();
+
+    /**
+     * Verifies that a trace type provided by an extension is present.
+     */
+    @Test
+    public void testTraceTypePresence() {
+        assertNotNull(TmfTraceType.getTraceType(getExtensionId()));
+    }
+
+    /**
+     * Verifies that a trace type contributed by an extension can validate a valid trace.
+     *
+     * @throws TmfTraceImportException
+     *             on error
+     */
+    @Test
+    public void testValidate() throws TmfTraceImportException {
+        final Predicate<TraceTypeHelper> predicateTracetypeIdEquals = (t) -> t.getTraceTypeId().equals(getExtensionId());
+        @NonNull List<TraceTypeHelper> traceTypes = TmfTraceType.selectTraceType(getTestTracePath(), getExtensionId());
+        String failureMessage = String.format("Could not find expected custom trace type %s in extensions", getExtensionId());
+        assertTrue(failureMessage, traceTypes.stream().anyMatch(predicateTracetypeIdEquals));
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/CustomTxtExtensionTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/CustomTxtExtensionTest.java
new file mode 100644 (file)
index 0000000..4231416
--- /dev/null
@@ -0,0 +1,28 @@
+/******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.tests.parsers.custom;
+
+/**
+ * Tests for Custom Text trace extension point.
+ */
+public class CustomTxtExtensionTest extends AbstractCustomTraceExtensionTest {
+    private static final String TEXT_TRACE_TYPE_EXTENSION_ID = "custom.txt.trace:Custom Text:testtxtextension";
+    private static final String TRACE_PATH_NAME = "testfiles/txt/valid/001.txt";
+
+    @Override
+    protected String getExtensionId() {
+        return TEXT_TRACE_TYPE_EXTENSION_ID;
+    }
+
+    @Override
+    protected String getTestTracePath() {
+        return TRACE_PATH_NAME;
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/CustomXmlExtensionTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/parsers/custom/CustomXmlExtensionTest.java
new file mode 100644 (file)
index 0000000..1c40a98
--- /dev/null
@@ -0,0 +1,28 @@
+/******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.tests.parsers.custom;
+
+/**
+ * Tests for Custom Text trace extension point.
+ */
+public class CustomXmlExtensionTest extends AbstractCustomTraceExtensionTest {
+    private static final String XML_TRACE_TYPE_EXTENSION_ID = "custom.xml.trace:Custom XML:testxmlextension";
+    private static final String TRACE_PATH_NAME = "testfiles/xml/valid/001.xml";
+
+    @Override
+    protected String getExtensionId() {
+        return XML_TRACE_TYPE_EXTENSION_ID;
+    }
+
+    @Override
+    protected String getTestTracePath() {
+        return TRACE_PATH_NAME;
+    }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/txt/testTxtExtensionDefinition.xml b/tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/txt/testTxtExtensionDefinition.xml
new file mode 100644 (file)
index 0000000..e65994f
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<CustomTxtTraceDefinitionList>
+<Definition name="testtxtextension">
+<TimeStampOutputFormat>Tn</TimeStampOutputFormat>
+<InputLine>
+<Cardinality max="2147483647" min="0"/>
+<RegEx>(\S+) (foo-event)</RegEx>
+<InputData action="0" format="dd/MM/yyyy HH:mm:ss:SSS" name="Timestamp" tag="TIMESTAMP"/>
+<InputData action="0" format="" name="Message" tag="MESSAGE"/>
+<InputLine>
+<Cardinality max="2147483647" min="0"/>
+<RegEx>(.*\S)</RegEx>
+<InputData action="2" tag="MESSAGE"/>
+</InputLine>
+</InputLine>
+<OutputColumn name="Timestamp" tag="TIMESTAMP"/>
+<OutputColumn name="Message" tag="MESSAGE"/>
+</Definition>
+</CustomTxtTraceDefinitionList>
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/txt/valid/001.txt b/tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/txt/valid/001.txt
new file mode 100644 (file)
index 0000000..bb32036
--- /dev/null
@@ -0,0 +1 @@
+1 foo-event
\ No newline at end of file
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/xml/testXmlExtensionDefinition.xml b/tmf/org.eclipse.tracecompass.tmf.core.tests/testfiles/xml/testXmlExtensionDefinition.xml
new file mode 100644 (file)
index 0000000..81a3b64
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<CustomXMLTraceDefinitionList>
+<Definition name="testxmlextension">
+<TimeStampOutputFormat>Tn</TimeStampOutputFormat>
+<InputElement name="trace">
+<InputElement logentry="true" name="element">
+<InputData action="0" name="Message" tag="MESSAGE"/>
+<Attribute name="time">
+<InputData action="0" format="dd/MM/yyyy HH:mm:ss:SSS" name="Timestamp" tag="TIMESTAMP"/>
+</Attribute>
+</InputElement>
+</InputElement>
+<OutputColumn name="Timestamp" tag="TIMESTAMP"/>
+<OutputColumn name="Message" tag="MESSAGE"/>
+</Definition>
+</CustomXMLTraceDefinitionList>
index a459c9db8208c95054e426fbb1974231bf238428..5bdd6e2d99c9da060252a7569997f9997f2e2d19 100644 (file)
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2013, 2014 Ericsson
+# Copyright (c) 2013, 2016 Ericsson
 #
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
@@ -17,6 +17,7 @@ Bundle-Name = Trace Compass TMF Core Plug-in
 extensionpoint.trace_type.name = Tmf Trace Type
 extensionpoint.analysis_module.name = Trace Analysis Module
 extensionpoint.ondemand_analysis.name = On-demand Analysis
+extensionpoint.custom_trace.name = Custom Trace
 
 # Experiment type
 experimenttype.type.generic = Generic Experiment
index f3dd3891e83bdab0f2517bd1542585cb39c4afb2..55b567e8fdbf75fec762c4fc19969b40bce0aadb 100644 (file)
@@ -4,6 +4,7 @@
    <extension-point id="org.eclipse.linuxtools.tmf.core.tracetype" name="%extensionpoint.trace_type.name" schema="schema/org.eclipse.linuxtools.tmf.core.tracetype.exsd"/>
    <extension-point id="org.eclipse.linuxtools.tmf.core.analysis" name="%extensionpoint.analysis_module.name" schema="schema/org.eclipse.linuxtools.tmf.core.analysis.exsd"/>
    <extension-point id="org.eclipse.tracecompass.tmf.core.analysis.ondemand" name="%extensionpoint.ondemand_analysis.name" schema="schema/org.eclipse.tracecompass.tmf.core.analysis.ondemand.exsd"/>
+   <extension-point id="org.eclipse.tracecompass.tmf.core.custom.trace" name="%extensionpoint.custom_trace.name" schema="schema/org.eclipse.tracecompass.tmf.core.custom.trace.exsd"/>
 
    <extension
          point="org.eclipse.core.runtime.preferences">
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/schema/org.eclipse.tracecompass.tmf.core.custom.trace.exsd b/tmf/org.eclipse.tracecompass.tmf.core/schema/org.eclipse.tracecompass.tmf.core.custom.trace.exsd
new file mode 100644 (file)
index 0000000..81bf1ec
--- /dev/null
@@ -0,0 +1,122 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tracecompass.tmf.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.tracecompass.tmf.core" id="org.eclipse.tracecompass.tmf.core.custom.trace" name="Custom Trace"/>
+      </appinfo>
+      <documentation>
+         This extension point is used to contribute custom trace types so that they are available automatically without the need to be imported by the user.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="customTrace"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="customTrace">
+      <annotation>
+         <appInfo>
+            <meta.element labelAttribute="file"/>
+         </appInfo>
+      </annotation>
+      <complexType>
+         <attribute name="file" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The path to the XML file describing the text trace.
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="resource"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="traceContentType" use="required">
+            <annotation>
+               <documentation>
+                  The type of content that the trace will have (XML or Text)
+               </documentation>
+            </annotation>
+            <simpleType>
+               <restriction base="string">
+                  <enumeration value="xml">
+                  </enumeration>
+                  <enumeration value="text">
+                  </enumeration>
+               </restriction>
+            </simpleType>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         Trace Compass 2.2
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         &lt;p&gt;For example, a custom text parser can be exported using the &quot;Manage Custom Parser&quot; dialog, then included in a plug-in so that it is automatically loaded without the user having to import it manually. The path to XML file describing the parser is specified in the extension point.
+&lt;/p&gt;
+&lt;pre&gt;
+   &lt;extension
+         point=&quot;org.eclipse.tracecompass.tmf.core.custom.trace&quot;&gt;
+      &lt;customtrace
+            file=&quot;parsers/customTextDefinition.xml&quot;&gt;
+      &lt;/customtrace&gt;
+   &lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+
+
+   <annotation>
+      <appinfo>
+         <meta.section type="copyright"/>
+      </appinfo>
+      <documentation>
+         Copyright (c) 2016 Ericsson
+
+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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
index 00f23f998749fdfca55a0612ee86e969db9e89c8..55efec0badedfd51a3d55f0de5d366f372efdc9c 100644 (file)
@@ -15,14 +15,24 @@ package org.eclipse.tracecompass.tmf.core.parsers.custom;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.AbstractMap.SimpleEntry;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map.Entry;
 
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
+import org.osgi.framework.Bundle;
 import org.w3c.dom.Element;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.ErrorHandler;
@@ -144,6 +154,11 @@ public abstract class CustomTraceDefinition {
     @Deprecated
     public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;
 
+    private static final String TMF_CUSTOM_TRACE_BUILTIN_EXTENSION_ID = "org.eclipse.tracecompass.tmf.core.custom.trace"; //$NON-NLS-1$
+    private static final String ATTRIBUTE_NAME_FILE = "file"; //$NON-NLS-1$
+    private static final String ATTRIBUTE_NAME_TRACE_CONTENT_TYPE = "traceContentType"; //$NON-NLS-1$
+    private static final String ELEMENT_NAME_CUSTOM_TRACE = "customTrace"; //$NON-NLS-1$
+
     /** Category of this trace definition */
     public String categoryName;
 
@@ -309,4 +324,52 @@ public abstract class CustomTraceDefinition {
         }
         return new SimpleEntry<>(tag, name);
     }
+
+    /**
+     * Get all the custom trace definition paths contributed by extensions, for
+     * a given content type (XML or Text).
+     *
+     * @param traceContentTypeToLoad
+     *            XML or Text (extension attribute value)
+     * @return the paths
+     *
+     * Note: This method is package-visible by design.
+     */
+    static final Collection<String> getExtensionDefinitionsPaths(String traceContentTypeToLoad) {
+        List<String> extensionDefinitionsPaths = new ArrayList<>();
+        IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_CUSTOM_TRACE_BUILTIN_EXTENSION_ID);
+        for (IConfigurationElement element : elements) {
+            if (!element.getName().equals(ELEMENT_NAME_CUSTOM_TRACE)) {
+                continue;
+            }
+
+            final String traceContentType = element.getAttribute(ATTRIBUTE_NAME_TRACE_CONTENT_TYPE);
+            if (!traceContentType.equals(traceContentTypeToLoad)) {
+                continue;
+            }
+
+            final String filename = element.getAttribute(ATTRIBUTE_NAME_FILE);
+            final String name = element.getContributor().getName();
+            SafeRunner.run(new ISafeRunnable() {
+                @Override
+                public void run() throws IOException {
+                    if (name != null) {
+                        Bundle bundle = Platform.getBundle(name);
+                        if (bundle != null) {
+                            URL xmlUrl = bundle.getResource(filename);
+                            URL locatedURL = FileLocator.toFileURL(xmlUrl);
+                            extensionDefinitionsPaths.add(locatedURL.getPath());
+                        }
+                    }
+                }
+
+                @Override
+                public void handleException(Throwable exception) {
+                    // Handled sufficiently in SafeRunner
+                }
+            });
+
+        }
+        return extensionDefinitionsPaths;
+    }
 }
index 20371425db4065c1f603e673edc61f819e00702a..a549f194275e985b8b4d461acc248bc66472f4f9 100644 (file)
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
@@ -116,6 +117,12 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition {
     private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format;
     private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomTxtTraceDefinition_outputColumn;
 
+    /**
+     * This is the value that the extension sets for traceContentType to be able
+     * to load an XML parser
+     **/
+    private static final String TRACE_CONTENT_TYPE_ATTRIBUTE_VALUE = "text"; //$NON-NLS-1$
+
     /**
      * Default constructor.
      */
@@ -669,6 +676,12 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition {
         defs.addAll(Arrays.asList(loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME)));
         if (includeDefaults) {
             defs.addAll(Arrays.asList(loadAll(CUSTOM_TXT_TRACE_DEFINITIONS_DEFAULT_PATH_NAME)));
+
+            // Also load definitions contributed by extensions
+            Collection<String> paths = getExtensionDefinitionsPaths(TRACE_CONTENT_TYPE_ATTRIBUTE_VALUE);
+            for (String customTraceDefinitionPath : paths) {
+                defs.addAll(Arrays.asList(loadAll(customTraceDefinitionPath)));
+            }
         }
         return defs.toArray(new CustomTxtTraceDefinition[0]);
 
index c0bf814d52ed1d759e2a5ec798e5b934417519e3..7b28785e7187cd749f3c214a6eb0aebf7afd2708 100644 (file)
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map.Entry;
@@ -120,6 +121,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition {
     private static final String FORMAT_ATTRIBUTE = Messages.CustomXmlTraceDefinition_format;
     private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn;
 
+    /**
+     * This is the value that the extension sets for traceContentType to be able
+     * to load an XML parser
+     **/
+    private static final String TRACE_CONTENT_TYPE_ATTRIBUTE_VALUE = "xml"; //$NON-NLS-1$
+
     /** Top-level input element */
     public CustomXmlInputElement rootInputElement;
 
@@ -333,6 +340,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition {
         defs.addAll(Arrays.asList(loadAll(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME)));
         if (includeDefaults) {
             defs.addAll(Arrays.asList(loadAll(CUSTOM_XML_TRACE_DEFINITIONS_DEFAULT_PATH_NAME)));
+
+            // Also load definitions contributed by extensions
+            Collection<String> paths = getExtensionDefinitionsPaths(TRACE_CONTENT_TYPE_ATTRIBUTE_VALUE);
+            for (String customTraceDefinitionPath : paths) {
+                defs.addAll(Arrays.asList(loadAll(customTraceDefinitionPath)));
+            }
         }
         return defs.toArray(new CustomXmlTraceDefinition[0]);
     }
This page took 0.03416 seconds and 5 git commands to generate.