Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
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; |
| 26 | import org.onosproject.net.flow.FlowRuleService; |
| 27 | import org.onosproject.net.host.HostService; |
| 28 | import org.onosproject.net.intent.IntentService; |
| 29 | import org.onosproject.net.link.LinkService; |
| 30 | import org.onosproject.net.statistic.StatisticService; |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 31 | import org.onosproject.net.topology.TopologyService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 32 | |
| 33 | import static com.google.common.base.Preconditions.checkNotNull; |
| 34 | |
| 35 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 36 | * 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] | 37 | */ |
| 38 | public class ServicesBundle { |
| 39 | |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 40 | private ClusterService clusterService; |
| 41 | |
| 42 | private TopologyService topologyService; |
| 43 | private DeviceService deviceService; |
| 44 | private HostService hostService; |
| 45 | private LinkService linkService; |
| 46 | private TunnelService tunnelService; |
| 47 | |
| 48 | private MastershipService mastershipService; |
| 49 | private MastershipAdminService mastershipAdminService; |
| 50 | private IntentService intentService; |
| 51 | private FlowRuleService flowService; |
| 52 | private StatisticService flowStatsService; |
| 53 | private PortStatisticsService portStatsService; |
| 54 | |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 57 | * Creates the services bundle, from the given directly. |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 58 | * |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 59 | * @param directory service directory |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 60 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 61 | public ServicesBundle(ServiceDirectory directory) { |
| 62 | checkNotNull(directory, "Directory cannot be null"); |
| 63 | |
| 64 | clusterService = directory.get(ClusterService.class); |
| 65 | |
| 66 | topologyService = directory.get(TopologyService.class); |
| 67 | deviceService = directory.get(DeviceService.class); |
| 68 | hostService = directory.get(HostService.class); |
| 69 | linkService = directory.get(LinkService.class); |
| 70 | tunnelService = directory.get(TunnelService.class); |
| 71 | |
| 72 | mastershipService = directory.get(MastershipService.class); |
| 73 | mastershipAdminService = directory.get(MastershipAdminService.class); |
| 74 | intentService = directory.get(IntentService.class); |
| 75 | flowService = directory.get(FlowRuleService.class); |
| 76 | flowStatsService = directory.get(StatisticService.class); |
| 77 | portStatsService = directory.get(PortStatisticsService.class); |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 80 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 81 | * Returns a reference to the cluster service. |
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 | * @return cluster service reference |
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 | public ClusterService cluster() { |
| 86 | return clusterService; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Returns a reference to the topology service. |
| 91 | * |
| 92 | * @return topology service reference |
| 93 | */ |
| 94 | public TopologyService topology() { |
| 95 | return topologyService; |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 98 | /** |
| 99 | * Returns a reference to the device service. |
| 100 | * |
| 101 | * @return device service reference |
| 102 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 103 | public DeviceService device() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 104 | return deviceService; |
| 105 | } |
| 106 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 107 | /** |
| 108 | * Returns a reference to the host service. |
| 109 | * |
| 110 | * @return host service reference |
| 111 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 112 | public HostService host() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 113 | return hostService; |
| 114 | } |
| 115 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 116 | /** |
| 117 | * Returns a reference to the link service. |
| 118 | * |
| 119 | * @return link service reference |
| 120 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 121 | public LinkService link() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 122 | return linkService; |
| 123 | } |
| 124 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 125 | /** |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 126 | * Returns a reference to the tunnel service. |
| 127 | * |
| 128 | * @return tunnel service reference |
| 129 | */ |
| 130 | public TunnelService tunnel() { |
| 131 | return tunnelService; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Returns a reference to the mastership service. |
| 136 | * |
| 137 | * @return mastership service reference |
| 138 | */ |
| 139 | public MastershipService mastership() { |
| 140 | return mastershipService; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Returns a reference to the mastership admin service. |
| 145 | * |
| 146 | * @return mastership admin service reference |
| 147 | */ |
| 148 | public MastershipAdminService mastershipAdmin() { |
| 149 | return mastershipAdminService; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Returns a reference to the intent service. |
| 154 | * |
| 155 | * @return intent service reference |
| 156 | */ |
| 157 | public IntentService intent() { |
| 158 | return intentService; |
| 159 | } |
| 160 | |
| 161 | /** |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 162 | * Returns a reference to the flow rule service. |
| 163 | * |
| 164 | * @return flow service reference |
| 165 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 166 | public FlowRuleService flow() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 167 | return flowService; |
| 168 | } |
| 169 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 170 | /** |
| 171 | * Returns a reference to the flow statistics service. |
| 172 | * |
| 173 | * @return flow statistics service reference |
| 174 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 175 | public StatisticService flowStats() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 176 | return flowStatsService; |
| 177 | } |
| 178 | |
Simon Hunt | 4fc8685 | 2015-08-20 17:57:52 -0700 | [diff] [blame] | 179 | /** |
| 180 | * Returns a reference to the port statistics service. |
| 181 | * |
| 182 | * @return port statistics service reference |
| 183 | */ |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 184 | public PortStatisticsService portStats() { |
Simon Hunt | a17fa67 | 2015-08-19 18:42:22 -0700 | [diff] [blame] | 185 | return portStatsService; |
| 186 | } |
| 187 | } |