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