3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.implementation.internal;
14 import java.util.concurrent.ConcurrentMap;
16 import org.opendaylight.controller.sal.core.Node;
17 import org.opendaylight.controller.sal.core.NodeConnector;
18 import org.opendaylight.controller.sal.core.Property;
19 import org.opendaylight.controller.sal.core.UpdateType;
20 import org.opendaylight.controller.sal.inventory.IInventoryService;
21 import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
22 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
23 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * The class describes SAL service to bridge inventory protocol plugin and upper
29 * applications. One instance per container of the network.
31 public class Inventory implements IPluginOutInventoryService, IInventoryService {
32 protected static final Logger logger = LoggerFactory
33 .getLogger(Inventory.class);
34 private IListenInventoryUpdates updateService = null;
35 private IPluginInInventoryService pluginService = null;
38 * Function called by the dependency manager when all the required
39 * dependencies are satisfied
43 logger.trace("INIT called!");
47 * Function called by the dependency manager when at least one
48 * dependency become unsatisfied or when the component is shutting
49 * down because for example bundle is being stopped.
53 logger.trace("DESTROY called!");
57 * Function called by dependency manager after "init ()" is called
58 * and after the services provided by the class are registered in
59 * the service registry
63 logger.trace("START called!");
65 if (pluginService == null) {
66 logger.debug("plugin service not avaiable");
72 * Function called by the dependency manager before the services
73 * exported by the component are unregistered, this will be
74 * followed by a "destroy ()" calls
78 logger.trace("STOP called!");
81 public void setPluginService(IPluginInInventoryService service) {
82 logger.trace("Got plugin service set request {}", service);
83 this.pluginService = service;
86 public void unsetPluginService(IPluginInInventoryService service) {
87 logger.trace("Got plugin service UNset request");
88 this.pluginService = null;
91 public void setUpdateService(IListenInventoryUpdates service) {
92 logger.trace("Got update service set request {}", service);
93 this.updateService = service;
96 public void unsetUpdateService(IListenInventoryUpdates service) {
97 logger.trace("Got a service UNset request");
98 this.updateService = null;
102 public void updateNode(Node node, UpdateType type, Set<Property> props) {
103 logger.trace("{} {}", node, type);
104 if (updateService != null) {
105 updateService.updateNode(node, type, props);
110 public void updateNodeConnector(NodeConnector nodeConnector,
111 UpdateType type, Set<Property> props) {
112 logger.trace("{} {}", nodeConnector, type);
114 if ((updateService != null) && (type != null)) {
115 updateService.updateNodeConnector(nodeConnector, type, props);
120 public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
121 if (pluginService != null)
122 return pluginService.getNodeProps();
128 public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps() {
129 if (pluginService != null)
130 return pluginService.getNodeConnectorProps(true);