Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
d91063d0 | 2 | * Copyright (c) 2009, 2014 Ericsson |
5500a7f0 | 3 | * |
8c8bf09f ASL |
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 | |
5500a7f0 | 8 | * |
8c8bf09f ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
d91063d0 | 11 | * Bernd Hufmann - Add signal manager disposal |
8c8bf09f ASL |
12 | *******************************************************************************/ |
13 | ||
4918b8f2 | 14 | package org.eclipse.linuxtools.internal.tmf.core; |
8c8bf09f | 15 | |
9fa32496 | 16 | import org.eclipse.core.runtime.IStatus; |
e1ab8984 | 17 | import org.eclipse.core.runtime.Plugin; |
9fa32496 | 18 | import org.eclipse.core.runtime.Status; |
b3b03da0 | 19 | import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager; |
d91063d0 | 20 | import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; |
fc526aef | 21 | import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; |
cbd4ad82 | 22 | import org.osgi.framework.BundleContext; |
8c8bf09f ASL |
23 | |
24 | /** | |
cbd4ad82 FC |
25 | * The activator class controls the plug-in life cycle. No more than one such |
26 | * plug-in can exist at any time. | |
5500a7f0 FC |
27 | * <p> |
28 | * It also provides the plug-in's general logging facility and manages the | |
29 | * internal tracer. | |
8c8bf09f | 30 | */ |
8fd82db5 | 31 | public class Activator extends Plugin { |
8c8bf09f | 32 | |
11252342 | 33 | // ------------------------------------------------------------------------ |
8c8bf09f | 34 | // Attributes |
11252342 | 35 | // ------------------------------------------------------------------------ |
8c8bf09f | 36 | |
9fa32496 | 37 | /** |
5500a7f0 | 38 | * The plug-in ID |
9fa32496 | 39 | */ |
c77a695a | 40 | public static final String PLUGIN_ID = "org.eclipse.tracecompass.tmf.core"; //$NON-NLS-1$ |
8c8bf09f | 41 | |
11252342 | 42 | /** |
9fa32496 BH |
43 | * The shared instance |
44 | */ | |
11252342 | 45 | private static Activator fPlugin; |
5500a7f0 | 46 | |
11252342 | 47 | // ------------------------------------------------------------------------ |
8c8bf09f | 48 | // Constructors |
11252342 | 49 | // ------------------------------------------------------------------------ |
8c8bf09f | 50 | |
11252342 | 51 | /** |
9fa32496 BH |
52 | * Constructor |
53 | */ | |
11252342 AM |
54 | public Activator() { |
55 | setDefault(this); | |
56 | } | |
8c8bf09f | 57 | |
11252342 | 58 | // ------------------------------------------------------------------------ |
8c8bf09f | 59 | // Accessors |
11252342 | 60 | // ------------------------------------------------------------------------ |
8c8bf09f | 61 | |
11252342 | 62 | /** |
5500a7f0 | 63 | * Returns the TMF Core plug-in instance. |
9fa32496 | 64 | * |
5500a7f0 | 65 | * @return the TMF Core plug-in instance. |
9fa32496 | 66 | */ |
8fd82db5 | 67 | public static Activator getDefault() { |
cbd4ad82 | 68 | return fPlugin; |
8c8bf09f ASL |
69 | } |
70 | ||
9fa32496 | 71 | // Sets plug-in instance |
11252342 AM |
72 | private static void setDefault(Activator plugin) { |
73 | fPlugin = plugin; | |
74 | } | |
cbd4ad82 | 75 | |
11252342 | 76 | // ------------------------------------------------------------------------ |
12c155f5 | 77 | // Plugin |
11252342 AM |
78 | // ------------------------------------------------------------------------ |
79 | ||
80 | @Override | |
81 | public void start(BundleContext context) throws Exception { | |
82 | super.start(context); | |
83 | setDefault(this); | |
84 | TmfCoreTracer.init(); | |
fc526aef AM |
85 | /* Initialize the trace manager */ |
86 | TmfTraceManager.getInstance(); | |
b63291e6 GB |
87 | /* Initialize the analysis manager */ |
88 | TmfAnalysisManager.initialize(); | |
11252342 AM |
89 | } |
90 | ||
91 | @Override | |
92 | public void stop(BundleContext context) throws Exception { | |
93 | TmfCoreTracer.stop(); | |
d91063d0 | 94 | TmfSignalManager.dispose(); |
11252342 AM |
95 | setDefault(null); |
96 | super.stop(context); | |
97 | } | |
98 | ||
b22a582a AM |
99 | |
100 | // ------------------------------------------------------------------------ | |
101 | // Log an IStatus | |
102 | // ------------------------------------------------------------------------ | |
103 | ||
104 | /** | |
105 | * Log an IStatus object directly | |
106 | * | |
107 | * @param status | |
108 | * The status to log | |
109 | */ | |
110 | public static void log(IStatus status) { | |
111 | fPlugin.getLog().log(status); | |
112 | } | |
113 | ||
11252342 AM |
114 | // ------------------------------------------------------------------------ |
115 | // Log INFO | |
5500a7f0 FC |
116 | // ------------------------------------------------------------------------ |
117 | ||
9fa32496 BH |
118 | /** |
119 | * Logs a message with severity INFO in the runtime log of the plug-in. | |
5500a7f0 | 120 | * |
11252342 AM |
121 | * @param message |
122 | * A message to log | |
9fa32496 | 123 | */ |
5500a7f0 FC |
124 | public static void logInfo(String message) { |
125 | fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message)); | |
9fa32496 | 126 | } |
5500a7f0 | 127 | |
9fa32496 | 128 | /** |
11252342 AM |
129 | * Logs a message and exception with severity INFO in the runtime log of the |
130 | * plug-in. | |
5500a7f0 | 131 | * |
11252342 AM |
132 | * @param message |
133 | * A message to log | |
134 | * @param exception | |
135 | * The corresponding exception | |
9fa32496 | 136 | */ |
5500a7f0 FC |
137 | public static void logInfo(String message, Throwable exception) { |
138 | fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception)); | |
9fa32496 BH |
139 | } |
140 | ||
5500a7f0 FC |
141 | // ------------------------------------------------------------------------ |
142 | // Log WARNING | |
143 | // ------------------------------------------------------------------------ | |
144 | ||
9fa32496 | 145 | /** |
11252342 AM |
146 | * Logs a message and exception with severity WARNING in the runtime log of |
147 | * the plug-in. | |
5500a7f0 | 148 | * |
11252342 AM |
149 | * @param message |
150 | * A message to log | |
9fa32496 | 151 | */ |
5500a7f0 FC |
152 | public static void logWarning(String message) { |
153 | fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message)); | |
9fa32496 | 154 | } |
5500a7f0 | 155 | |
9fa32496 | 156 | /** |
11252342 AM |
157 | * Logs a message and exception with severity WARNING in the runtime log of |
158 | * the plug-in. | |
5500a7f0 | 159 | * |
11252342 AM |
160 | * @param message |
161 | * A message to log | |
162 | * @param exception | |
163 | * The corresponding exception | |
9fa32496 | 164 | */ |
5500a7f0 FC |
165 | public static void logWarning(String message, Throwable exception) { |
166 | fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception)); | |
9fa32496 BH |
167 | } |
168 | ||
5500a7f0 FC |
169 | // ------------------------------------------------------------------------ |
170 | // Log ERROR | |
171 | // ------------------------------------------------------------------------ | |
172 | ||
9fa32496 | 173 | /** |
11252342 AM |
174 | * Logs a message and exception with severity ERROR in the runtime log of |
175 | * the plug-in. | |
5500a7f0 | 176 | * |
11252342 AM |
177 | * @param message |
178 | * A message to log | |
9fa32496 | 179 | */ |
5500a7f0 FC |
180 | public static void logError(String message) { |
181 | fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message)); | |
9fa32496 | 182 | } |
5500a7f0 | 183 | |
9fa32496 | 184 | /** |
11252342 AM |
185 | * Logs a message and exception with severity ERROR in the runtime log of |
186 | * the plug-in. | |
5500a7f0 | 187 | * |
11252342 AM |
188 | * @param message |
189 | * A message to log | |
190 | * @param exception | |
191 | * The corresponding exception | |
9fa32496 | 192 | */ |
5500a7f0 FC |
193 | public static void logError(String message, Throwable exception) { |
194 | fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception)); | |
9fa32496 | 195 | } |
8c8bf09f | 196 | } |