Commit | Line | Data |
---|---|---|
79b33284 | 1 | /******************************************************************************* |
c19380ab | 2 | * Copyright (c) 2012, 2015 Ericsson |
11252342 | 3 | * |
79b33284 FC |
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 | |
11252342 | 8 | * |
79b33284 FC |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
9bc60be7 | 13 | package org.eclipse.tracecompass.internal.lttng2.kernel.core; |
79b33284 | 14 | |
83d1b60e PP |
15 | import java.io.IOException; |
16 | ||
9fa32496 | 17 | import org.eclipse.core.runtime.IStatus; |
79b33284 | 18 | import org.eclipse.core.runtime.Plugin; |
9fa32496 | 19 | import org.eclipse.core.runtime.Status; |
66838307 | 20 | import org.eclipse.jdt.annotation.NonNullByDefault; |
dc327459 GB |
21 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpEventMatching; |
22 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.matching.TcpLttngEventMatching; | |
664dac59 | 23 | import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiAnalysisFactoryException; |
2bdf0193 | 24 | import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventMatching; |
79b33284 FC |
25 | import org.osgi.framework.BundleContext; |
26 | ||
27 | /** | |
28 | * <b><u>Activator</u></b> | |
29 | * <p> | |
30 | * The activator class controls the plug-in life cycle | |
31 | */ | |
66838307 | 32 | @NonNullByDefault({}) |
79b33284 FC |
33 | public class Activator extends Plugin { |
34 | ||
35 | // ------------------------------------------------------------------------ | |
36 | // Attributes | |
37 | // ------------------------------------------------------------------------ | |
38 | ||
11252342 AM |
39 | /** |
40 | * The plug-in ID | |
41 | */ | |
c19380ab | 42 | public static final String PLUGIN_ID = "org.eclipse.tracecompass.lttng2.kernel.core"; //$NON-NLS-1$ |
11252342 AM |
43 | |
44 | /** | |
45 | * The shared instance | |
46 | */ | |
47 | private static Activator plugin; | |
79b33284 | 48 | |
79b33284 FC |
49 | // ------------------------------------------------------------------------ |
50 | // Constructors | |
51 | // ------------------------------------------------------------------------ | |
52 | ||
11252342 AM |
53 | /** |
54 | * The constructor | |
55 | */ | |
56 | public Activator() { | |
57 | } | |
79b33284 FC |
58 | |
59 | // ------------------------------------------------------------------------ | |
60 | // Accessors | |
61 | // ------------------------------------------------------------------------ | |
62 | ||
11252342 AM |
63 | /** |
64 | * Returns the shared instance | |
65 | * | |
66 | * @return the shared instance | |
67 | */ | |
68 | public static Activator getDefault() { | |
69 | return plugin; | |
70 | } | |
79b33284 FC |
71 | |
72 | // ------------------------------------------------------------------------ | |
73 | // Operators | |
74 | // ------------------------------------------------------------------------ | |
75 | ||
11252342 AM |
76 | @Override |
77 | public void start(BundleContext context) throws Exception { | |
78 | super.start(context); | |
79 | plugin = this; | |
e73a4ba5 GB |
80 | TmfEventMatching.registerMatchObject(new TcpEventMatching()); |
81 | TmfEventMatching.registerMatchObject(new TcpLttngEventMatching()); | |
83d1b60e PP |
82 | |
83 | try { | |
84 | LttngAnalysesLoader.load(); | |
664dac59 | 85 | } catch (LamiAnalysisFactoryException | IOException e) { |
83d1b60e PP |
86 | // Not the end of the world if the analyses are not available |
87 | logWarning("Cannot find LTTng analyses configuration files: " + e.getMessage()); //$NON-NLS-1$ | |
88 | } | |
11252342 AM |
89 | } |
90 | ||
91 | @Override | |
92 | public void stop(BundleContext context) throws Exception { | |
93 | plugin = null; | |
94 | super.stop(context); | |
95 | } | |
96 | ||
9fa32496 BH |
97 | /** |
98 | * Logs a message with severity INFO in the runtime log of the plug-in. | |
11252342 | 99 | * |
9fa32496 BH |
100 | * @param message A message to log |
101 | */ | |
102 | public void logInfo(String message) { | |
103 | getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message)); | |
104 | } | |
11252342 | 105 | |
9fa32496 BH |
106 | /** |
107 | * Logs a message and exception with severity INFO in the runtime log of the plug-in. | |
11252342 | 108 | * |
9fa32496 BH |
109 | * @param message A message to log |
110 | * @param exception A exception to log | |
111 | */ | |
112 | public void logInfo(String message, Throwable exception) { | |
113 | getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception)); | |
114 | } | |
115 | ||
116 | /** | |
117 | * Logs a message and exception with severity WARNING in the runtime log of the plug-in. | |
11252342 | 118 | * |
9fa32496 BH |
119 | * @param message A message to log |
120 | */ | |
121 | public void logWarning(String message) { | |
122 | getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message)); | |
123 | } | |
11252342 | 124 | |
9fa32496 BH |
125 | /** |
126 | * Logs a message and exception with severity WARNING in the runtime log of the plug-in. | |
11252342 | 127 | * |
9fa32496 BH |
128 | * @param message A message to log |
129 | * @param exception A exception to log | |
130 | */ | |
131 | public void logWarning(String message, Throwable exception) { | |
132 | getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception)); | |
133 | } | |
134 | ||
135 | /** | |
136 | * Logs a message and exception with severity ERROR in the runtime log of the plug-in. | |
11252342 | 137 | * |
9fa32496 BH |
138 | * @param message A message to log |
139 | */ | |
140 | public void logError(String message) { | |
141 | getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message)); | |
142 | } | |
11252342 | 143 | |
9fa32496 BH |
144 | /** |
145 | * Logs a message and exception with severity ERROR in the runtime log of the plug-in. | |
11252342 | 146 | * |
9fa32496 BH |
147 | * @param message A message to log |
148 | * @param exception A exception to log | |
149 | */ | |
150 | public void logError(String message, Throwable exception) { | |
151 | getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception)); | |
152 | } | |
79b33284 FC |
153 | |
154 | } |