344b3f32763c2fcb9c45047ae7c4e34f0b6e087d
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / 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.controller.sal.dom.broker.osgi;
9
10 import java.util.Hashtable;
11
12 import org.opendaylight.controller.sal.core.api.model.SchemaService;
13 import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl;
14 import org.osgi.framework.BundleActivator;
15 import org.osgi.framework.BundleContext;
16 import org.osgi.framework.ServiceRegistration;
17
18 public class SchemaServiceActivator implements BundleActivator {
19
20     
21     private ServiceRegistration<SchemaService> schemaServiceReg;
22     private GlobalBundleScanningSchemaServiceImpl schemaService;
23
24     @Override
25     public void start(BundleContext context) throws Exception {
26         schemaService = new GlobalBundleScanningSchemaServiceImpl();
27         schemaService.setContext(context);
28         schemaService.start();
29         schemaServiceReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String,String>());
30     }
31     
32     @Override
33     public void stop(BundleContext context) throws Exception {
34         schemaServiceReg.unregister();
35         schemaService.close();
36     }
37 }