d052ec5755cacef165d26f969d83ecb89cad58a3
[aaa.git] / aaa-filterchain / src / main / java / org / opendaylight / aaa / filterchain / Activator.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.aaa.filterchain;
10
11 import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
12 import org.osgi.framework.BundleActivator;
13 import org.osgi.framework.BundleContext;
14 import org.osgi.framework.ServiceRegistration;
15 import org.osgi.service.cm.ManagedService;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 /**
20  * Activator for <code>aaa-filterchain</code>, a bundle which provides the ability
21  * to inject custom <code>Filter</code>(s) in front of servlets.
22  *
23  * <p>
24  * This class is also responsible for offering contextual <code>DEBUG</code>
25  * level clues concerning the activation of the <code>aaa-filterchain</code> bundle.
26  * To enable these debug messages, issue the following command in the karaf
27  * shell: <code>log:set debug org.opendaylight.aaa.filterchain.Activator</code>
28  *
29  * @author Ryan Goulding (ryandgoulding@gmail.com)
30  */
31 public class Activator implements BundleActivator {
32
33     private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
34
35     private ServiceRegistration<ManagedService> managedServiceServiceRegistration;
36
37     @Override
38     public void stop(BundleContext context) throws Exception {
39         LOG.debug("Destroying the aaa-filterchain bundle");
40         managedServiceServiceRegistration.unregister();
41     }
42
43     @Override
44     public void start(BundleContext context) throws Exception {
45         LOG.debug("Initializing the aaa-filterchain bundle");
46         // Register the CustomFilterAdapterConfiguration ManagedService with the
47         // BundleContext so config values can be loaded from the config admin
48         managedServiceServiceRegistration = context.registerService(ManagedService.class,
49                 CustomFilterAdapterConfiguration.getInstance(),
50                 CustomFilterAdapterConfiguration.getInstance().getDefaultProperties());
51     }
52 }