blob: 76c72f3016f5aad9a1f57ec2fe83af2f9fb8adaf [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);
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 Hunta17fa672015-08-19 18:42:22 -070080 }
81
Simon Hunt4fc86852015-08-20 17:57:52 -070082 /**
Simon Hunt1911fe42017-05-02 18:25:58 -070083 * Returns a reference to the cluster service.
Simon Hunt4fc86852015-08-20 17:57:52 -070084 *
Simon Hunt1911fe42017-05-02 18:25:58 -070085 * @return cluster service reference
Simon Hunt4fc86852015-08-20 17:57:52 -070086 */
Simon Hunt1911fe42017-05-02 18:25:58 -070087 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 Hunta17fa672015-08-19 18:42:22 -070098 }
99
Simon Hunt4fc86852015-08-20 17:57:52 -0700100 /**
101 * Returns a reference to the device service.
102 *
103 * @return device service reference
104 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700105 public DeviceService device() {
Simon Hunta17fa672015-08-19 18:42:22 -0700106 return deviceService;
107 }
108
Simon Hunt4fc86852015-08-20 17:57:52 -0700109 /**
Laszlo Pappe1579fa2018-03-08 09:18:48 +0000110 * 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 Hunt4fc86852015-08-20 17:57:52 -0700119 * Returns a reference to the host service.
120 *
121 * @return host service reference
122 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700123 public HostService host() {
Simon Hunta17fa672015-08-19 18:42:22 -0700124 return hostService;
125 }
126
Simon Hunt4fc86852015-08-20 17:57:52 -0700127 /**
128 * Returns a reference to the link service.
129 *
130 * @return link service reference
131 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700132 public LinkService link() {
Simon Hunta17fa672015-08-19 18:42:22 -0700133 return linkService;
134 }
135
Simon Hunt4fc86852015-08-20 17:57:52 -0700136 /**
Simon Hunt1911fe42017-05-02 18:25:58 -0700137 * 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 Hunt4fc86852015-08-20 17:57:52 -0700173 * Returns a reference to the flow rule service.
174 *
175 * @return flow service reference
176 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700177 public FlowRuleService flow() {
Simon Hunta17fa672015-08-19 18:42:22 -0700178 return flowService;
179 }
180
Simon Hunt4fc86852015-08-20 17:57:52 -0700181 /**
182 * Returns a reference to the flow statistics service.
183 *
184 * @return flow statistics service reference
185 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700186 public StatisticService flowStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700187 return flowStatsService;
188 }
189
Simon Hunt4fc86852015-08-20 17:57:52 -0700190 /**
191 * Returns a reference to the port statistics service.
192 *
193 * @return port statistics service reference
194 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700195 public PortStatisticsService portStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700196 return portStatsService;
197 }
198}