Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 3 | * |
Simon Hunt | ed804d5 | 2016-03-30 09:51:40 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 7 | * |
Simon Hunt | ed804d5 | 2016-03-30 09:51:40 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 9 | * |
Simon Hunt | ed804d5 | 2016-03-30 09:51:40 -0700 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Simon Hunt | ed804d5 | 2016-03-30 09:51:40 -0700 | [diff] [blame] | 17 | package org.onosproject.ui.impl.topo.util; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 18 | |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 19 | import org.onlab.osgi.ServiceDirectory; |
| 20 | import org.onosproject.cluster.ClusterService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 21 | import org.onosproject.incubator.net.PortStatisticsService; |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 22 | import org.onosproject.incubator.net.tunnel.TunnelService; |
| 23 | import org.onosproject.mastership.MastershipAdminService; |
| 24 | import org.onosproject.mastership.MastershipService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 25 | import org.onosproject.net.device.DeviceService; |
Laszlo Papp | e1579fa | 2018-03-08 09:18:48 +0000 | [diff] [blame^] | 26 | import org.onosproject.net.driver.DriverService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 27 | import org.onosproject.net.flow.FlowRuleService; |
| 28 | import org.onosproject.net.host.HostService; |
| 29 | import org.onosproject.net.intent.IntentService; |
| 30 | import org.onosproject.net.link.LinkService; |
| 31 | import org.onosproject.net.statistic.StatisticService; |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 32 | import org.onosproject.net.topology.TopologyService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 33 | |
| 34 | import static com.google.common.base.Preconditions.checkNotNull; |
| 35 | |
| 36 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 37 | * A bundle of services that the topology view(s) require to get the job done. |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 38 | */ |
| 39 | public class ServicesBundle { |
| 40 | |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 41 | private ClusterService clusterService; |
| 42 | |
| 43 | private TopologyService topologyService; |
| 44 | private DeviceService deviceService; |
Laszlo Papp | e1579fa | 2018-03-08 09:18:48 +0000 | [diff] [blame^] | 45 | private DriverService driverService; |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 46 | private HostService hostService; |
| 47 | private LinkService linkService; |
| 48 | private TunnelService tunnelService; |
| 49 | |
| 50 | private MastershipService mastershipService; |
| 51 | private MastershipAdminService mastershipAdminService; |
| 52 | private IntentService intentService; |
| 53 | private FlowRuleService flowService; |
| 54 | private StatisticService flowStatsService; |
| 55 | private PortStatisticsService portStatsService; |
| 56 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 59 | * Creates the services bundle, from the given directly. |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 60 | * |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 61 | * @param directory service directory |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 62 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 63 | public ServicesBundle(ServiceDirectory directory) { |
| 64 | checkNotNull(directory, "Directory cannot be null"); |
| 65 | |
| 66 | clusterService = directory.get(ClusterService.class); |
| 67 | |
| 68 | topologyService = directory.get(TopologyService.class); |
| 69 | deviceService = directory.get(DeviceService.class); |
| 70 | hostService = directory.get(HostService.class); |
| 71 | linkService = directory.get(LinkService.class); |
| 72 | tunnelService = directory.get(TunnelService.class); |
| 73 | |
| 74 | mastershipService = directory.get(MastershipService.class); |
| 75 | mastershipAdminService = directory.get(MastershipAdminService.class); |
| 76 | intentService = directory.get(IntentService.class); |
| 77 | flowService = directory.get(FlowRuleService.class); |
| 78 | flowStatsService = directory.get(StatisticService.class); |
| 79 | portStatsService = directory.get(PortStatisticsService.class); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 82 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 83 | * Returns a reference to the cluster service. |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 84 | * |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 85 | * @return cluster service reference |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 86 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 87 | public ClusterService cluster() { |
| 88 | return clusterService; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Returns a reference to the topology service. |
| 93 | * |
| 94 | * @return topology service reference |
| 95 | */ |
| 96 | public TopologyService topology() { |
| 97 | return topologyService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 100 | /** |
| 101 | * Returns a reference to the device service. |
| 102 | * |
| 103 | * @return device service reference |
| 104 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 105 | public DeviceService device() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 106 | return deviceService; |
| 107 | } |
| 108 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 109 | /** |
Laszlo Papp | e1579fa | 2018-03-08 09:18:48 +0000 | [diff] [blame^] | 110 | * Returns a reference to the driver service. |
| 111 | * |
| 112 | * @return driver service reference |
| 113 | */ |
| 114 | public DriverService driver() { |
| 115 | return driverService; |
| 116 | } |
| 117 | |
| 118 | /** |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 119 | * Returns a reference to the host service. |
| 120 | * |
| 121 | * @return host service reference |
| 122 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 123 | public HostService host() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 124 | return hostService; |
| 125 | } |
| 126 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 127 | /** |
| 128 | * Returns a reference to the link service. |
| 129 | * |
| 130 | * @return link service reference |
| 131 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 132 | public LinkService link() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 133 | return linkService; |
| 134 | } |
| 135 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 136 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 137 | * Returns a reference to the tunnel service. |
| 138 | * |
| 139 | * @return tunnel service reference |
| 140 | */ |
| 141 | public TunnelService tunnel() { |
| 142 | return tunnelService; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Returns a reference to the mastership service. |
| 147 | * |
| 148 | * @return mastership service reference |
| 149 | */ |
| 150 | public MastershipService mastership() { |
| 151 | return mastershipService; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns a reference to the mastership admin service. |
| 156 | * |
| 157 | * @return mastership admin service reference |
| 158 | */ |
| 159 | public MastershipAdminService mastershipAdmin() { |
| 160 | return mastershipAdminService; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Returns a reference to the intent service. |
| 165 | * |
| 166 | * @return intent service reference |
| 167 | */ |
| 168 | public IntentService intent() { |
| 169 | return intentService; |
| 170 | } |
| 171 | |
| 172 | /** |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 173 | * Returns a reference to the flow rule service. |
| 174 | * |
| 175 | * @return flow service reference |
| 176 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 177 | public FlowRuleService flow() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 178 | return flowService; |
| 179 | } |
| 180 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 181 | /** |
| 182 | * Returns a reference to the flow statistics service. |
| 183 | * |
| 184 | * @return flow statistics service reference |
| 185 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 186 | public StatisticService flowStats() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 187 | return flowStatsService; |
| 188 | } |
| 189 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 190 | /** |
| 191 | * Returns a reference to the port statistics service. |
| 192 | * |
| 193 | * @return port statistics service reference |
| 194 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 195 | public PortStatisticsService portStats() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 196 | return portStatsService; |
| 197 | } |
| 198 | } |