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;
11 import static java.util.Objects.requireNonNull;
13 import com.google.common.annotations.VisibleForTesting;
14 import java.util.Dictionary;
15 import java.util.Hashtable;
17 import org.gaul.modernizer_maven_annotations.SuppressModernizer;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
25 * A Factory Component which implements {@link SchemaContextListener}. Instances of this component are created through
26 * by {@link OSGiDOMSchemaService} each time a listener is registered.
28 @Component(factory = SchemaSchemaContextListenerImpl.FACTORY_NAME, service = SchemaContextListener.class)
29 public final class SchemaSchemaContextListenerImpl implements SchemaContextListener {
30 static final String FACTORY_NAME = "org.opendaylight.mdsal.dom.schema.osgi.impl.SchemaSchemaContextListener";
33 static final String DELEGATE = "org.opendaylight.mdsal.dom.schema.osgi.SchemaSchemaContextListener";
35 private SchemaContextListener delegate = null;
38 public void onGlobalContextUpdated(final SchemaContext context) {
39 delegate.onGlobalContextUpdated(context);
43 void activate(final Map<String, ?> properties) {
44 delegate = (SchemaContextListener) verifyNotNull(properties.get(DELEGATE));
53 static Dictionary<String, ?> props(final SchemaContextListener delegate) {
54 final Dictionary<String, Object> ret = new Hashtable<>(2);
55 ret.put(DELEGATE, requireNonNull(delegate));