001/*
002 * Copyright (c) 2004-2005 QOS.ch
003 *
004 * All rights reserved.
005 *
006 * Permission is hereby granted, free of charge, to any person obtaining
007 * a copy of this software and associated documentation files (the
008 * "Software"), to  deal in  the Software without  restriction, including
009 * without limitation  the rights to  use, copy, modify,  merge, publish,
010 * distribute, and/or sell copies of  the Software, and to permit persons
011 * to whom  the Software is furnished  to do so, provided  that the above
012 * copyright notice(s) and this permission notice appear in all copies of
013 * the  Software and  that both  the above  copyright notice(s)  and this
014 * permission notice appear in supporting documentation.
015 *
016 * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
017 * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
018 * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
019 * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
020 * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
021 * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
022 * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
023 * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
024 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
025 *
026 * Except as  contained in  this notice, the  name of a  copyright holder
027 * shall not be used in advertising or otherwise to promote the sale, use
028 * or other dealings in this Software without prior written authorization
029 * of the copyright holder.
030 *
031 */
032
033package org.slf4j.osgi.logservice.impl;
034
035import java.util.Properties;
036
037import org.osgi.framework.BundleActivator;
038import org.osgi.framework.BundleContext;
039import org.osgi.framework.ServiceFactory;
040import org.osgi.service.log.LogService;
041
042/**
043 * <code>Activator</code> implements a simple bundle that registers a
044 * {@link LogServiceFactory} for the creation of {@link LogService} implementations.
045 *
046 * @author John Conlon
047 * @author Matt Bishop
048 **/
049public class Activator implements BundleActivator {
050    /**
051     *
052     * Implements <code>BundleActivator.start()</code> to register a
053     * LogServiceFactory.
054     *
055     * @param bundleContext the framework context for the bundle
056     * @throws Exception
057     */
058    public void start(BundleContext bundleContext) throws Exception {
059
060        Properties props = new Properties();
061        props.put("description", "An SLF4J LogService implementation.");
062        ServiceFactory factory = new LogServiceFactory();
063        bundleContext.registerService(LogService.class.getName(), factory, props);
064    }
065
066    /**
067     *
068     * Implements <code>BundleActivator.stop()</code>.
069     *
070     * @param bundleContext the framework context for the bundle
071     * @throws Exception
072     */
073    public void stop(BundleContext bundleContext) throws Exception {
074
075        // Note: It is not required that we remove the service here, since
076        // the framework will do it automatically.
077    }
078}