blob: e58b0f223c133f992b3db7fa82e63c9acee45e43 [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
Simon Hunt1911fe42017-05-02 18:25:58 -070040 private ClusterService clusterService;
41
42 private TopologyService topologyService;
43 private DeviceService deviceService;
Laszlo Pappe1579fa2018-03-08 09:18:48 +000044 private DriverService driverService;
Simon Hunt1911fe42017-05-02 18:25:58 -070045 private HostService hostService;
46 private LinkService linkService;
Simon Hunt1911fe42017-05-02 18:25:58 -070047
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 Hunta17fa672015-08-19 18:42:22 -070055
56 /**
Simon Hunt1911fe42017-05-02 18:25:58 -070057 * Creates the services bundle, from the given directly.
Simon Hunt4fc86852015-08-20 17:57:52 -070058 *
Simon Hunt1911fe42017-05-02 18:25:58 -070059 * @param directory service directory
Simon Hunta17fa672015-08-19 18:42:22 -070060 */
Simon Hunt1911fe42017-05-02 18:25:58 -070061 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);
Thomas Vachuska177ea1b2018-03-13 12:00:49 -070068 driverService = directory.get(DriverService.class);
Simon Hunt1911fe42017-05-02 18:25:58 -070069 hostService = directory.get(HostService.class);
70 linkService = directory.get(LinkService.class);
Simon Hunt1911fe42017-05-02 18:25:58 -070071
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 Hunta17fa672015-08-19 18:42:22 -070078 }
79
Simon Hunt4fc86852015-08-20 17:57:52 -070080 /**
Simon Hunt1911fe42017-05-02 18:25:58 -070081 * Returns a reference to the cluster service.
Simon Hunt4fc86852015-08-20 17:57:52 -070082 *
Simon Hunt1911fe42017-05-02 18:25:58 -070083 * @return cluster service reference
Simon Hunt4fc86852015-08-20 17:57:52 -070084 */
Simon Hunt1911fe42017-05-02 18:25:58 -070085 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 Hunta17fa672015-08-19 18:42:22 -070096 }
97
Simon Hunt4fc86852015-08-20 17:57:52 -070098 /**
99 * Returns a reference to the device service.
100 *
101 * @return device service reference
102 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700103 public DeviceService device() {
Simon Hunta17fa672015-08-19 18:42:22 -0700104 return deviceService;
105 }
106
Simon Hunt4fc86852015-08-20 17:57:52 -0700107 /**
Laszlo Pappe1579fa2018-03-08 09:18:48 +0000108 * Returns a reference to the driver service.
109 *
110 * @return driver service reference
111 */
112 public DriverService driver() {
113 return driverService;
114 }
115
116 /**
Simon Hunt4fc86852015-08-20 17:57:52 -0700117 * Returns a reference to the host service.
118 *
119 * @return host service reference
120 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700121 public HostService host() {
Simon Hunta17fa672015-08-19 18:42:22 -0700122 return hostService;
123 }
124
Simon Hunt4fc86852015-08-20 17:57:52 -0700125 /**
126 * Returns a reference to the link service.
127 *
128 * @return link service reference
129 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700130 public LinkService link() {
Simon Hunta17fa672015-08-19 18:42:22 -0700131 return linkService;
132 }
133
Simon Hunt4fc86852015-08-20 17:57:52 -0700134 /**
Simon Hunt1911fe42017-05-02 18:25:58 -0700135 * 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 Hunt4fc86852015-08-20 17:57:52 -0700162 * Returns a reference to the flow rule service.
163 *
164 * @return flow service reference
165 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700166 public FlowRuleService flow() {
Simon Hunta17fa672015-08-19 18:42:22 -0700167 return flowService;
168 }
169
Simon Hunt4fc86852015-08-20 17:57:52 -0700170 /**
171 * Returns a reference to the flow statistics service.
172 *
173 * @return flow statistics service reference
174 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700175 public StatisticService flowStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700176 return flowStatsService;
177 }
178
Simon Hunt4fc86852015-08-20 17:57:52 -0700179 /**
180 * Returns a reference to the port statistics service.
181 *
182 * @return port statistics service reference
183 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700184 public PortStatisticsService portStats() {
Simon Hunta17fa672015-08-19 18:42:22 -0700185 return portStatsService;
186 }
187}