diff options
author | Stefan Liebig | 2008-02-27 09:58:19 -0500 |
---|---|---|
committer | Stefan Liebig | 2008-02-27 09:58:19 -0500 |
commit | 3c3a2a7e3202e9eb09ea4944f545a03224aea153 (patch) | |
tree | 03cbfbf196e2849b5fb26008d823e4866fd8aac1 | |
parent | 7c76d07102b16fd40d99c09ad4b2161ebaed0316 (diff) | |
download | org.eclipse.riena-3c3a2a7e3202e9eb09ea4944f545a03224aea153.zip org.eclipse.riena-3c3a2a7e3202e9eb09ea4944f545a03224aea153.tar.gz org.eclipse.riena-3c3a2a7e3202e9eb09ea4944f545a03224aea153.tar.xz |
added abstract plugin
-rw-r--r-- | org.eclipse.riena.core/src/org/eclipse/riena/core/RienaPlugin.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/org.eclipse.riena.core/src/org/eclipse/riena/core/RienaPlugin.java b/org.eclipse.riena.core/src/org/eclipse/riena/core/RienaPlugin.java new file mode 100644 index 0000000..f8da4e0 --- /dev/null +++ b/org.eclipse.riena.core/src/org/eclipse/riena/core/RienaPlugin.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 compeople AG and others. + * 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 + * + * Contributors: + * compeople AG - initial API and implementation + *******************************************************************************/ +package org.eclipse.riena.core; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.equinox.log.Logger; +import org.eclipse.riena.core.logging.LogUtil; +import org.osgi.framework.BundleContext; + +/** + * Abstract base class for riena plugins.<br> + * It provides all descendant classes access to the bundle context and the + * logger.<br> + * <b>Note: </b>Derived Activators/Plugins must call <code>super.start()</code> + * and <code>super.stop()</code> within their <code>start()</code> and + * <code>stop()</stop> methods. + */ +public abstract class RienaPlugin extends Plugin { + + // The shared instance + private static BundleContext context; + private LogUtil logUtil; + + /* + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + RienaPlugin.context = context; + } + + /* + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + RienaPlugin.context = null; + + super.stop(context); + } + + /** + * Get the shared context. + * + * @return + */ + public static BundleContext getContext() { + return context; + } + + /** + * Get a logger for the specified name. + * + * @param name + * @return + */ + public synchronized Logger getLogger(String name) { + if (logUtil == null) + logUtil = new LogUtil(context); + return logUtil.getLogger(name); + } +} |