blob: 15677184cdb58aa14f7d329d43a58938092cb14d [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;
Thomas Vachuska52f2cd12018-11-08 21:20:04 -080021import org.onosproject.net.statistic.PortStatisticsService;
Simon Hunt1911fe42017-05-02 18:25:58 -070022import org.onosproject.mastership.MastershipAdminService;
23import org.onosproject.mastership.MastershipService;
Simon Hunta17fa672015-08-19 18:42:22 -070024import org.onosproject.net.device.DeviceService;
Laszlo Pappe1579fa2018-03-08 09:18:48 +000025import org.onosproject.net.driver.DriverService;
Simon Hunta17fa672015-08-19 18:42:22 -070026import org.onosproject.net.flow.FlowRuleService;
27import org.onosproject.net.host.HostService;
28import org.onosproject.net.intent.IntentService;
29import org.onosproject.net.link.LinkService;
30import org.onosproject.net.statistic.StatisticService;
Simon Hunt1911fe42017-05-02 18:25:58 -070031import org.onosproject.net.topology.TopologyService;
Simon Hunta17fa672015-08-19 18:42:22 -070032
33import static com.google.common.base.Preconditions.checkNotNull;
34
35/**
Simon Hunt1911fe42017-05-02 18:25:58 -070036 * A bundle of services that the topology view(s) require to get the job done.
Simon Hunta17fa672015-08-19 18:42:22 -070037 */
38public class ServicesBundle {
39
Thomas Vachuska2b4de872021-03-30 16:31:34 -070040 private ServiceDirectory directory;
41
Simon Hunt1911fe42017-05-02 18:25:58 -070042 private ClusterService clusterService;
43
44 private TopologyService topologyService;
45 private DeviceService deviceService;
Laszlo Pappe1579fa2018-03-08 09:18:48 +000046 private DriverService driverService;
Simon Hunt1911fe42017-05-02 18:25:58 -070047 private HostService hostService;
48 private LinkService linkService;
Simon Hunt1911fe42017-05-02 18:25:58 -070049
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");
Thomas Vachuska2b4de872021-03-30 16:31:34 -070065 this.directory = directory;
Simon Hunt1911fe42017-05-02 18:25:58 -070066
67 clusterService = directory.get(ClusterService.class);
68
69 topologyService = directory.get(TopologyService.class);
70 deviceService = directory.get(DeviceService.class);
Thomas Vachuska177ea1b2018-03-13 12:00:49 -070071 driverService = directory.get(DriverService.class);
Simon Hunt1911fe42017-05-02 18:25:58 -070072 hostService = directory.get(HostService.class);
73 linkService = directory.get(LinkService.class);
Simon Hunt1911fe42017-05-02 18:25:58 -070074
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 mastership service.
139 *
140 * @return mastership service reference
141 */
142 public MastershipService mastership() {
143 return mastershipService;
144 }
145
146 /**
147 * Returns a reference to the mastership admin service.
148 *
149 * @return mastership admin service reference
150 */
151 public MastershipAdminService mastershipAdmin() {
152 return mastershipAdminService;
153 }
154
155 /**
156 * Returns a reference to the intent service.
157 *
158 * @return intent service reference
159 */
160 public IntentService intent() {
161 return intentService;
162 }
163
164 /**
Simon Hunt4fc86852015-08-20 17:57:52 -0700165 * Returns a reference to the flow rule service.
166 *
167 * @return flow service reference
168 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700169 public FlowRuleService flow() {
Simon Hunta17fa672015-08-19 18:42:22 -0700170 return flowService;
171 }
172
Simon Hunt4fc86852015-08-20 17:57:52 -0700173 /**
174 * Returns a reference to the flow statistics service.
175 *
176 * @return flow statistics service reference
177 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700178 public StatisticService flowStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700179 return flowStatsService;
180 }
181
Simon Hunt4fc86852015-08-20 17:57:52 -0700182 /**
183 * Returns a reference to the port statistics service.
184 *
185 * @return port statistics service reference
186 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700187 public PortStatisticsService portStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700188 return portStatsService;
189 }
Thomas Vachuska2b4de872021-03-30 16:31:34 -0700190
191 /**
192 * Returns the implementation of the specified service class.
193 *
194 * @param serviceClass service class
195 * @param <T> class of service
196 * @return implementation of the service class
197 */
198 public <T> T get(Class<T> serviceClass) {
199 return directory.get(serviceClass);
200 }
Simon Hunta17fa672015-08-19 18:42:22 -0700201}