438ad76ac0d9238e7e06e67786c67f7e70fa8b05
[mdsal.git] / dom / mdsal-dom-broker / src / main / java / org / opendaylight / mdsal / dom / broker / osgi / SchemaServiceActivator.java
1 /*
2  * Copyright (c) 2014 Cisco 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 package org.opendaylight.mdsal.dom.broker.osgi;
9
10 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
11 import java.util.Hashtable;
12 import org.osgi.framework.BundleActivator;
13 import org.osgi.framework.BundleContext;
14 import org.osgi.framework.ServiceRegistration;
15
16 public class SchemaServiceActivator implements BundleActivator {
17
18
19     private ServiceRegistration<DOMSchemaService> schemaServiceReg;
20     private OsgiBundleScanningSchemaService schemaService;
21
22     @Override
23     public void start(final BundleContext context) {
24         schemaService = OsgiBundleScanningSchemaService.createInstance(context);
25         schemaServiceReg = context.registerService(DOMSchemaService.class, schemaService, new Hashtable<String,String>());
26     }
27
28     @Override
29     public void stop(final BundleContext context) throws Exception {
30         schemaServiceReg.unregister();
31         schemaService.close();
32     }
33 }