blob: 3ae7e90dbab6685c60532ddaba8b931b4f59413e [file] [log] [blame]
Simon Hunta17fa672015-08-19 18:42:22 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Simon Hunta17fa672015-08-19 18:42:22 -07003 *
Simon Hunted804d52016-03-30 09:51:40 -07004 * 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 Hunta17fa672015-08-19 18:42:22 -07007 *
Simon Hunted804d52016-03-30 09:51:40 -07008 * http://www.apache.org/licenses/LICENSE-2.0
Simon Hunta17fa672015-08-19 18:42:22 -07009 *
Simon Hunted804d52016-03-30 09:51:40 -070010 * 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 Hunta17fa672015-08-19 18:42:22 -070015 */
16
Simon Hunted804d52016-03-30 09:51:40 -070017package org.onosproject.ui.impl.topo.util;
Simon Hunta17fa672015-08-19 18:42:22 -070018
Simon Hunt1911fe42017-05-02 18:25:58 -070019import org.onlab.osgi.ServiceDirectory;
20import org.onosproject.cluster.ClusterService;
Simon Hunta17fa672015-08-19 18:42:22 -070021import org.onosproject.incubator.net.PortStatisticsService;
Simon Hunt1911fe42017-05-02 18:25:58 -070022import org.onosproject.incubator.net.tunnel.TunnelService;
23import org.onosproject.mastership.MastershipAdminService;
24import org.onosproject.mastership.MastershipService;
Simon Hunta17fa672015-08-19 18:42:22 -070025import org.onosproject.net.device.DeviceService;
Laszlo Pappe1579fa2018-03-08 09:18:48 +000026import org.onosproject.net.driver.DriverService;
Simon Hunta17fa672015-08-19 18:42:22 -070027import org.onosproject.net.flow.FlowRuleService;
28import org.onosproject.net.host.HostService;
29import org.onosproject.net.intent.IntentService;
30import org.onosproject.net.link.LinkService;
31import org.onosproject.net.statistic.StatisticService;
Simon Hunt1911fe42017-05-02 18:25:58 -070032import org.onosproject.net.topology.TopologyService;
Simon Hunta17fa672015-08-19 18:42:22 -070033
34import static com.google.common.base.Preconditions.checkNotNull;
35
36/**
Simon Hunt1911fe42017-05-02 18:25:58 -070037 * A bundle of services that the topology view(s) require to get the job done.
Simon Hunta17fa672015-08-19 18:42:22 -070038 */
39public class ServicesBundle {
40
Simon Hunt1911fe42017-05-02 18:25:58 -070041 private ClusterService clusterService;
42
43 private TopologyService topologyService;
44 private DeviceService deviceService;
Laszlo Pappe1579fa2018-03-08 09:18:48 +000045 private DriverService driverService;
Simon Hunt1911fe42017-05-02 18:25:58 -070046 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 Hunta17fa672015-08-19 18:42:22 -070057
58 /**
Simon Hunt1911fe42017-05-02 18:25:58 -070059 * Creates the services bundle, from the given directly.
Simon Hunt4fc86852015-08-20 17:57:52 -070060 *
Simon Hunt1911fe42017-05-02 18:25:58 -070061 * @param directory service directory
Simon Hunta17fa672015-08-19 18:42:22 -070062 */
Simon Hunt1911fe42017-05-02 18:25:58 -070063 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);
Thomas Vachuska177ea1b2018-03-13 12:00:49 -070070 driverService = directory.get(DriverService.class);
Simon Hunt1911fe42017-05-02 18:25:58 -070071 hostService = directory.get(HostService.class);
72 linkService = directory.get(LinkService.class);
73 tunnelService = directory.get(TunnelService.class);
74
75 mastershipService = directory.get(MastershipService.class);
76 mastershipAdminService = directory.get(MastershipAdminService.class);
77 intentService = directory.get(IntentService.class);
78 flowService = directory.get(FlowRuleService.class);
79 flowStatsService = directory.get(StatisticService.class);
80 portStatsService = directory.get(PortStatisticsService.class);
Simon Hunta17fa672015-08-19 18:42:22 -070081 }
82
Simon Hunt4fc86852015-08-20 17:57:52 -070083 /**
Simon Hunt1911fe42017-05-02 18:25:58 -070084 * Returns a reference to the cluster service.
Simon Hunt4fc86852015-08-20 17:57:52 -070085 *
Simon Hunt1911fe42017-05-02 18:25:58 -070086 * @return cluster service reference
Simon Hunt4fc86852015-08-20 17:57:52 -070087 */
Simon Hunt1911fe42017-05-02 18:25:58 -070088 public ClusterService cluster() {
89 return clusterService;
90 }
91
92 /**
93 * Returns a reference to the topology service.
94 *
95 * @return topology service reference
96 */
97 public TopologyService topology() {
98 return topologyService;
Simon Hunta17fa672015-08-19 18:42:22 -070099 }
100
Simon Hunt4fc86852015-08-20 17:57:52 -0700101 /**
102 * Returns a reference to the device service.
103 *
104 * @return device service reference
105 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700106 public DeviceService device() {
Simon Hunta17fa672015-08-19 18:42:22 -0700107 return deviceService;
108 }
109
Simon Hunt4fc86852015-08-20 17:57:52 -0700110 /**
Laszlo Pappe1579fa2018-03-08 09:18:48 +0000111 * Returns a reference to the driver service.
112 *
113 * @return driver service reference
114 */
115 public DriverService driver() {
116 return driverService;
117 }
118
119 /**
Simon Hunt4fc86852015-08-20 17:57:52 -0700120 * Returns a reference to the host service.
121 *
122 * @return host service reference
123 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700124 public HostService host() {
Simon Hunta17fa672015-08-19 18:42:22 -0700125 return hostService;
126 }
127
Simon Hunt4fc86852015-08-20 17:57:52 -0700128 /**
129 * Returns a reference to the link service.
130 *
131 * @return link service reference
132 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700133 public LinkService link() {
Simon Hunta17fa672015-08-19 18:42:22 -0700134 return linkService;
135 }
136
Simon Hunt4fc86852015-08-20 17:57:52 -0700137 /**
Simon Hunt1911fe42017-05-02 18:25:58 -0700138 * Returns a reference to the tunnel service.
139 *
140 * @return tunnel service reference
141 */
142 public TunnelService tunnel() {
143 return tunnelService;
144 }
145
146 /**
147 * Returns a reference to the mastership service.
148 *
149 * @return mastership service reference
150 */
151 public MastershipService mastership() {
152 return mastershipService;
153 }
154
155 /**
156 * Returns a reference to the mastership admin service.
157 *
158 * @return mastership admin service reference
159 */
160 public MastershipAdminService mastershipAdmin() {
161 return mastershipAdminService;
162 }
163
164 /**
165 * Returns a reference to the intent service.
166 *
167 * @return intent service reference
168 */
169 public IntentService intent() {
170 return intentService;
171 }
172
173 /**
Simon Hunt4fc86852015-08-20 17:57:52 -0700174 * Returns a reference to the flow rule service.
175 *
176 * @return flow service reference
177 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700178 public FlowRuleService flow() {
Simon Hunta17fa672015-08-19 18:42:22 -0700179 return flowService;
180 }
181
Simon Hunt4fc86852015-08-20 17:57:52 -0700182 /**
183 * Returns a reference to the flow statistics service.
184 *
185 * @return flow statistics service reference
186 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700187 public StatisticService flowStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700188 return flowStatsService;
189 }
190
Simon Hunt4fc86852015-08-20 17:57:52 -0700191 /**
192 * Returns a reference to the port statistics service.
193 *
194 * @return port statistics service reference
195 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700196 public PortStatisticsService portStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700197 return portStatsService;
198 }
199}