View Javadoc

    1   /*
    2    * Copyright (c) 2004-2005 QOS.ch
    3    *
    4    * All rights reserved.
    5    *
    6    * Permission is hereby granted, free of charge, to any person obtaining
    7    * a copy of this software and associated documentation files (the
    8    * "Software"), to  deal in  the Software without  restriction, including
    9    * without limitation  the rights to  use, copy, modify,  merge, publish,
    10   * distribute, and/or sell copies of  the Software, and to permit persons
    11   * to whom  the Software is furnished  to do so, provided  that the above
    12   * copyright notice(s) and this permission notice appear in all copies of
    13   * the  Software and  that both  the above  copyright notice(s)  and this
    14   * permission notice appear in supporting documentation.
    15   *
    16   * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
    17   * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
    18   * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
    19   * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
    20   * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
    21   * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
    22   * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
    23   * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
    24   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    25   *
    26   * Except as  contained in  this notice, the  name of a  copyright holder
    27   * shall not be used in advertising or otherwise to promote the sale, use
    28   * or other dealings in this Software without prior written authorization
    29   * of the copyright holder.
    30   *
    31   */
    32
    33  package org.slf4j.osgi.logservice.impl;
    34
    35  import java.util.Properties;
    36
    37  import org.osgi.framework.BundleActivator;
    38  import org.osgi.framework.BundleContext;
    39  import org.osgi.framework.ServiceFactory;
    40  import org.osgi.service.log.LogService;
    41
    42  /**
    43   * <code>Activator</code> implements a simple bundle that registers a
    44   * {@link LogServiceFactory} for the creation of {@link LogService} implementations.
    45   *
    46   * @author John Conlon
    47   * @author Matt Bishop
    48   **/
    49  public class Activator implements BundleActivator {
    50      /**
    51       *
    52       * Implements <code>BundleActivator.start()</code> to register a
    53       * LogServiceFactory.
    54       *
    55       * @param bundleContext the framework context for the bundle
    56       * @throws Exception
    57       */
    58      public void start(BundleContext bundleContext) throws Exception {
    59
    60          Properties props = new Properties();
    61          props.put("description", "An SLF4J LogService implementation.");
    62          ServiceFactory factory = new LogServiceFactory();
    63          bundleContext.registerService(LogService.class.getName(), factory, props);
    64      }
    65
    66      /**
    67       *
    68       * Implements <code>BundleActivator.stop()</code>.
    69       *
    70       * @param bundleContext the framework context for the bundle
    71       * @throws Exception
    72       */
    73      public void stop(BundleContext bundleContext) throws Exception {
    74
    75          // Note: It is not required that we remove the service here, since
    76          // the framework will do it automatically.
    77      }
    78  }