tmf: Update copyright headers in tmf.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / Activator.java
CommitLineData
8c8bf09f 1/*******************************************************************************
61759503 2 * Copyright (c) 2009, 2012 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
11 *******************************************************************************/
12
4918b8f2 13package org.eclipse.linuxtools.internal.tmf.core;
8c8bf09f 14
9fa32496 15import org.eclipse.core.runtime.IStatus;
e1ab8984 16import org.eclipse.core.runtime.Plugin;
9fa32496 17import org.eclipse.core.runtime.Status;
cbd4ad82 18import org.osgi.framework.BundleContext;
8c8bf09f
ASL
19
20/**
cbd4ad82
FC
21 * The activator class controls the plug-in life cycle. No more than one such
22 * plug-in can exist at any time.
5500a7f0
FC
23 * <p>
24 * It also provides the plug-in's general logging facility and manages the
25 * internal tracer.
8c8bf09f 26 */
8fd82db5 27public class Activator extends Plugin {
8c8bf09f 28
e31e01e8 29 // ------------------------------------------------------------------------
8c8bf09f 30 // Attributes
e31e01e8 31 // ------------------------------------------------------------------------
8c8bf09f 32
9fa32496 33 /**
5500a7f0 34 * The plug-in ID
9fa32496 35 */
5179fc01 36 public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
8c8bf09f 37
9fa32496
BH
38 /**
39 * The shared instance
40 */
8fd82db5 41 private static Activator fPlugin;
5500a7f0 42
e31e01e8 43 // ------------------------------------------------------------------------
8c8bf09f 44 // Constructors
e31e01e8 45 // ------------------------------------------------------------------------
8c8bf09f 46
9fa32496
BH
47 /**
48 * Constructor
49 */
8fd82db5 50 public Activator() {
cbd4ad82 51 setDefault(this);
8c8bf09f
ASL
52 }
53
e31e01e8 54 // ------------------------------------------------------------------------
8c8bf09f 55 // Accessors
e31e01e8 56 // ------------------------------------------------------------------------
8c8bf09f 57
9fa32496 58 /**
5500a7f0 59 * Returns the TMF Core plug-in instance.
9fa32496 60 *
5500a7f0 61 * @return the TMF Core plug-in instance.
9fa32496 62 */
8fd82db5 63 public static Activator getDefault() {
cbd4ad82 64 return fPlugin;
8c8bf09f
ASL
65 }
66
9fa32496 67 // Sets plug-in instance
8fd82db5 68 private static void setDefault(Activator plugin) {
cbd4ad82
FC
69 fPlugin = plugin;
70 }
71
72 // ------------------------------------------------------------------------
12c155f5 73 // Plugin
cbd4ad82
FC
74 // ------------------------------------------------------------------------
75
9fa32496
BH
76 /*
77 * (non-Javadoc)
78 * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
79 */
cbd4ad82
FC
80 @Override
81 public void start(BundleContext context) throws Exception {
82 super.start(context);
83 setDefault(this);
5500a7f0 84 TmfCoreTracer.init();
cbd4ad82
FC
85 }
86
9fa32496
BH
87 /*
88 * (non-Javadoc)
89 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
90 */
cbd4ad82
FC
91 @Override
92 public void stop(BundleContext context) throws Exception {
5500a7f0 93 TmfCoreTracer.stop();
cbd4ad82
FC
94 setDefault(null);
95 super.stop(context);
96 }
97
5500a7f0
FC
98 // ------------------------------------------------------------------------
99 // Log INFO
100 // ------------------------------------------------------------------------
101
9fa32496
BH
102 /**
103 * Logs a message with severity INFO in the runtime log of the plug-in.
5500a7f0 104 *
9fa32496
BH
105 * @param message A message to log
106 */
5500a7f0
FC
107 public static void logInfo(String message) {
108 fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
9fa32496 109 }
5500a7f0 110
9fa32496
BH
111 /**
112 * Logs a message and exception with severity INFO in the runtime log of the plug-in.
5500a7f0 113 *
9fa32496 114 * @param message A message to log
5500a7f0 115 * @param exception The corresponding exception
9fa32496 116 */
5500a7f0
FC
117 public static void logInfo(String message, Throwable exception) {
118 fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
9fa32496
BH
119 }
120
5500a7f0
FC
121 // ------------------------------------------------------------------------
122 // Log WARNING
123 // ------------------------------------------------------------------------
124
9fa32496
BH
125 /**
126 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
5500a7f0 127 *
9fa32496
BH
128 * @param message A message to log
129 */
5500a7f0
FC
130 public static void logWarning(String message) {
131 fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
9fa32496 132 }
5500a7f0 133
9fa32496
BH
134 /**
135 * Logs a message and exception with severity WARNING in the runtime log of the plug-in.
5500a7f0 136 *
9fa32496 137 * @param message A message to log
5500a7f0 138 * @param exception The corresponding exception
9fa32496 139 */
5500a7f0
FC
140 public static void logWarning(String message, Throwable exception) {
141 fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
9fa32496
BH
142 }
143
5500a7f0
FC
144 // ------------------------------------------------------------------------
145 // Log ERROR
146 // ------------------------------------------------------------------------
147
9fa32496
BH
148 /**
149 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
5500a7f0 150 *
9fa32496
BH
151 * @param message A message to log
152 */
5500a7f0
FC
153 public static void logError(String message) {
154 fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
9fa32496 155 }
5500a7f0 156
9fa32496
BH
157 /**
158 * Logs a message and exception with severity ERROR in the runtime log of the plug-in.
5500a7f0 159 *
9fa32496 160 * @param message A message to log
5500a7f0 161 * @param exception The corresponding exception
9fa32496 162 */
5500a7f0
FC
163 public static void logError(String message, Throwable exception) {
164 fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
9fa32496
BH
165 }
166
8c8bf09f 167}
This page took 0.051587 seconds and 5 git commands to generate.