blob: aa20990e76134cea3132f9cf68c3e8b066f1a14e [file] [log] [blame]
Simon Hunta17fa672015-08-19 18:42:22 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
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;
26import 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;
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 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);
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 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 /**
108 * Returns a reference to the host service.
109 *
110 * @return host service reference
111 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700112 public HostService host() {
Simon Hunta17fa672015-08-19 18:42:22 -0700113 return hostService;
114 }
115
Simon Hunt4fc86852015-08-20 17:57:52 -0700116 /**
117 * Returns a reference to the link service.
118 *
119 * @return link service reference
120 */
Simon Hunt1911fe42017-05-02 18:25:58 -0700121 public LinkService link() {
Simon Hunta17fa672015-08-19 18:42:22 -0700122 return linkService;
123 }
124
Simon Hunt4fc86852015-08-20 17:57:52 -0700125 /**
Simon Hunt1911fe42017-05-02 18:25:58 -0700126 * 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 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}