Merge "Fixed for bug : 1171 - issue while creating subnet"
[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(final BundleContext context) {
26         schemaService = GlobalBundleScanningSchemaServiceImpl.createInstance(context);
27         schemaService.start();
28         schemaServiceReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String,String>());
29     }
30
31     @Override
32     public void stop(final BundleContext context) throws Exception {
33         schemaServiceReg.unregister();
34         schemaService.close();
35     }
36 }