2 * Copyright (c) 2014 Cisco Systems, Inc. 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.controller.mdsal;
10 import org.opendaylight.controller.config.yang.messagebus.app.impl.NamespaceToStream;
11 import org.opendaylight.controller.messagebus.app.impl.EventAggregator;
12 import org.opendaylight.controller.messagebus.app.impl.EventSourceManager;
13 import org.opendaylight.controller.messagebus.app.impl.EventSourceTopology;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
15 import org.opendaylight.controller.sal.core.api.Broker;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import java.util.List;
21 public class InitializationContext {
22 private static final Logger LOGGER = LoggerFactory.getLogger(InitializationContext.class);
24 private final MdSAL mdSal;
25 private final DataStore dataStore;
26 private final EventSourceTopology eventSourceTopology;
27 private final EventSourceManager eventSourceManager;
28 private final EventAggregator eventAggregator;
30 public InitializationContext(List<NamespaceToStream> namespaceMapping) {
31 this.mdSal = new MdSAL();
32 this.dataStore = new DataStore(mdSal);
33 this.eventSourceTopology = new EventSourceTopology(dataStore);
34 this.eventSourceManager = new EventSourceManager(dataStore, mdSal, eventSourceTopology, namespaceMapping);
35 this.eventAggregator = new EventAggregator(mdSal, eventSourceTopology);
38 public synchronized void set(BindingAwareBroker.ProviderContext session) {
39 mdSal.setBindingAwareContext(session);
41 if (mdSal.isReady()) {
46 public synchronized void set(Broker.ProviderSession session) {
47 mdSal.setBindingIndependentContext(session);
49 if (mdSal.isReady()) {
54 private void initialize() {
55 eventSourceTopology.mdsalReady();
56 eventSourceManager.mdsalReady();
57 eventAggregator.mdsalReady();
59 LOGGER.info("InitializationContext started.");