52af5814faa6a9dc05e837e78c9194a5781e25b6
[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 java.util.Hashtable;
11 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
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,
26                 schemaService, new Hashtable<String,String>());
27     }
28
29     @Override
30     public void stop(final BundleContext context) throws Exception {
31         schemaServiceReg.unregister();
32         schemaService.close();
33     }
34 }