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 static java.util.Objects.requireNonNull;
12 import java.util.List;
13 import org.apache.karaf.features.DeploymentEvent;
14 import org.apache.karaf.features.DeploymentListener;
15 import org.apache.karaf.features.FeaturesService;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.concepts.ObjectRegistration;
18 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 final class KarafYangModuleInfoRegistry extends YangModuleInfoRegistry implements DeploymentListener {
23 private static final Logger LOG = LoggerFactory.getLogger(KarafYangModuleInfoRegistry.class);
25 private final RegularYangModuleInfoRegistry delegate;
27 private boolean scannerEnabled = false;
28 private boolean updatesEnabled = false;
30 private KarafYangModuleInfoRegistry(final RegularYangModuleInfoRegistry delegate) {
31 this.delegate = requireNonNull(delegate);
34 static @NonNull KarafYangModuleInfoRegistry create(final FeaturesService features,
35 final RegularYangModuleInfoRegistry delegate) {
36 final KarafYangModuleInfoRegistry ret = new KarafYangModuleInfoRegistry(delegate);
37 features.registerListener(ret);
42 public synchronized void deploymentEvent(final DeploymentEvent event) {
43 LOG.debug("Features service indicates {}", event);
45 case DEPLOYMENT_STARTED:
46 case BUNDLES_INSTALLED:
47 updatesEnabled = false;
48 LOG.debug("BindingRuntimeContext updates disabled");
50 case BUNDLES_RESOLVED:
51 case DEPLOYMENT_FINISHED:
53 updatesEnabled = true;
54 LOG.debug("BindingRuntimeContext updates enabled");
56 delegate.enableScannerAndUpdate();
62 synchronized void scannerUpdate() {
64 delegate.scannerUpdate();
69 synchronized void enableScannerAndUpdate() {
70 scannerEnabled = true;
72 delegate.enableScannerAndUpdate();
78 List<ObjectRegistration<YangModuleInfo>> registerInfos(final List<YangModuleInfo> infos) {
79 return delegate.registerInfos(infos);
83 synchronized void close() {
88 synchronized void scannerShutdown() {
89 scannerEnabled = false;
90 delegate.scannerShutdown();