aboutsummaryrefslogtreecommitdiffstats
path: root/odl-aaa-moon/aaa/aaa-authn-store/src/main/java/org/opendaylight/aaa/store/Activator.java
blob: f3299723b7bd8c310e107efe3f5544c4d2507865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2014, 2015 Hewlett-Packard Development Company, L.P. 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
 */

package org.opendaylight.aaa.store;

import java.util.Dictionary;
import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.opendaylight.aaa.api.TokenStore;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.service.cm.ManagedService;

/**
 * An activator for the default datastore implementation of {@link TokenStore}.
 *
 * @author liemmn
 */
public class Activator extends DependencyActivatorBase {

    private static final String TOKEN_PID = "org.opendaylight.aaa.tokens";

    @Override
    public void init(BundleContext context, DependencyManager manager) throws Exception {
        DefaultTokenStore ts = new DefaultTokenStore();
        manager.add(createComponent().setInterface(new String[] { TokenStore.class.getName() },
                null).setImplementation(ts));
        context.registerService(ManagedService.class.getName(), ts,
                addPid(DefaultTokenStore.defaults));
    }

    @Override
    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
    }

    private Dictionary<String, ?> addPid(Dictionary<String, String> dict) {
        dict.put(Constants.SERVICE_PID, TOKEN_PID);
        return dict;
    }
}