2 * Copyright (c) 2013 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
9 package org.opendaylight.openflowplugin.openflow.internal;
11 import java.util.Dictionary;
12 import java.util.List;
13 import org.apache.felix.dm.Component;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
18 import org.opendaylight.controller.sal.core.Edge;
19 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
20 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
21 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
22 import org.opendaylight.openflowplugin.openflow.IRefreshInternalProvider;
23 import org.opendaylight.openflowplugin.openflow.ITopologyServiceShimListener;
25 public class TopologyServices implements ITopologyServiceShimListener,
26 IPluginInTopologyService {
27 protected static final Logger logger = LoggerFactory
28 .getLogger(TopologyServices.class);
29 private IPluginOutTopologyService salTopoService = null;
30 private IRefreshInternalProvider topoRefreshService = null;
31 private IPluginOutConnectionService connectionOutService;
32 private String containerName;
35 * Function called by the dependency manager when all the required
36 * dependencies are satisfied
39 @SuppressWarnings("unchecked")
40 void init(Component c) {
41 logger.trace("INIT called!");
42 Dictionary<Object, Object> props = c.getServiceProperties();
43 containerName = (props != null) ? (String) props.get("containerName")
48 * Function called by the dependency manager when at least one dependency
49 * become unsatisfied or when the component is shutting down because for
50 * example bundle is being stopped.
54 logger.trace("DESTROY called!");
58 * Function called by dependency manager after "init ()" is called and after
59 * the services provided by the class are registered in the service registry
63 logger.trace("START called!");
67 * Function called by the dependency manager before the services exported by
68 * the component are unregistered, this will be followed by a "destroy ()"
73 logger.trace("STOP called!");
77 * Retrieve SAL service IPluginOutTopologyService
80 * Called by Dependency Manager as soon as the SAL service is
83 public void setPluginOutTopologyService(IPluginOutTopologyService s) {
84 logger.trace("Setting IPluginOutTopologyService to: {}", s);
85 this.salTopoService = s;
89 * called when SAL service IPluginOutTopologyService is no longer available
92 * Called by Dependency Manager as soon as the SAL service is
95 public void unsetPluginOutTopologyService(IPluginOutTopologyService s) {
96 if (this.salTopoService == s) {
97 logger.trace("UNSetting IPluginOutTopologyService from: {}", s);
98 this.salTopoService = null;
103 * Retrieve OF protocol_plugin service IRefreshInternalProvider
106 * Called by Dependency Manager as soon as the SAL service is
109 public void setRefreshInternalProvider(IRefreshInternalProvider s) {
110 logger.trace("Setting IRefreshInternalProvider to: {}", s);
111 this.topoRefreshService = s;
115 * called when OF protocol_plugin service IRefreshInternalProvider is no
119 * Called by Dependency Manager as soon as the SAL service is
122 public void unsetRefreshInternalProvider(IRefreshInternalProvider s) {
123 if (this.topoRefreshService == s) {
124 logger.trace("UNSetting IRefreshInternalProvider from: {}", s);
125 this.topoRefreshService = null;
130 public void edgeUpdate(List<TopoEdgeUpdate> topoedgeupdateList) {
131 if (this.salTopoService != null) {
132 this.salTopoService.edgeUpdate(topoedgeupdateList);
137 public void sollicitRefresh() {
138 logger.debug("Got a request to refresh topology");
139 topoRefreshService.requestRefresh(containerName);
143 public void edgeOverUtilized(Edge edge) {
144 if (this.salTopoService != null) {
145 this.salTopoService.edgeOverUtilized(edge);
150 public void edgeUtilBackToNormal(Edge edge) {
151 if (this.salTopoService != null) {
152 this.salTopoService.edgeUtilBackToNormal(edge);
156 void setIPluginOutConnectionService(IPluginOutConnectionService s) {
157 connectionOutService = s;
160 void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
161 if (connectionOutService == s) {
162 connectionOutService = null;