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 com.google.common.base.Verify.verifyNotNull;
12 import com.google.common.annotations.VisibleForTesting;
13 import java.util.Dictionary;
15 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
17 import org.osgi.framework.FrameworkUtil;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Deactivate;
23 * A Factory Component which implements {@link EffectiveModelContextListener}. Instances of this component are created
24 * through by {@link OSGiDOMSchemaService} each time a listener is registered.
26 @Component(factory = EffectiveModelContextImpl.FACTORY_NAME, service = EffectiveModelContextListener.class)
27 public final class EffectiveModelContextImpl implements EffectiveModelContextListener {
28 static final String FACTORY_NAME = "org.opendaylight.mdsal.dom.schema.osgi.impl.SchemaSchemaContextListener";
31 static final String DELEGATE = "org.opendaylight.mdsal.dom.schema.osgi.SchemaSchemaContextListener";
33 private EffectiveModelContextListener delegate = null;
36 public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
37 delegate.onModelContextUpdated(newModelContext);
41 void activate(final Map<String, ?> properties) {
42 delegate = (EffectiveModelContextListener) verifyNotNull(properties.get(DELEGATE));
50 static Dictionary<String, ?> props(final EffectiveModelContextListener delegate) {
51 return FrameworkUtil.asDictionary(Map.of(DELEGATE, delegate));