2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.dom.schema.osgi.impl;
10 import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
11 import org.osgi.framework.BundleContext;
12 import org.osgi.service.component.ComponentFactory;
13 import org.osgi.service.component.annotations.Activate;
14 import org.osgi.service.component.annotations.Component;
15 import org.osgi.service.component.annotations.Deactivate;
16 import org.osgi.service.component.annotations.Reference;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 @Component(immediate = true)
21 public final class OSGiModelRuntime {
22 private static final Logger LOG = LoggerFactory.getLogger(OSGiModelRuntime.class);
25 YangParserFactory parserFactory = null;
26 @Reference(target = "(component.factory=" + OSGiEffectiveModelImpl.FACTORY_NAME + ")")
27 ComponentFactory contextFactory = null;
29 private YangModuleInfoScanner bundleTracker = null;
30 private YangModuleInfoRegistry moduleRegistry = null;
33 void activate(final BundleContext ctx) {
34 LOG.info("Model Runtime starting");
35 moduleRegistry = new YangModuleInfoRegistry(contextFactory, parserFactory);
36 bundleTracker = new YangModuleInfoScanner(ctx, moduleRegistry);
38 moduleRegistry.enableScannerAndUpdate();
39 LOG.info("Model Runtime started");
44 LOG.info("Model Runtime stopping");
45 moduleRegistry.close();
46 bundleTracker.close();
47 LOG.info("Model Runtime stopped");