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