blob: 908099c50ca873c3e3f17f6f0408f76a14e933a5 [file] [log] [blame]
Thomas Vachuska54dc3522015-09-09 00:11:45 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska54dc3522015-09-09 00:11:45 -07003 *
4 * 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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * 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.
15 */
16package org.onosproject.dhcp.impl;
17
18import com.google.common.collect.ImmutableList;
Thomas Vachuska54dc3522015-09-09 00:11:45 -070019import org.onosproject.ui.UiExtension;
20import org.onosproject.ui.UiExtensionService;
21import org.onosproject.ui.UiMessageHandlerFactory;
22import org.onosproject.ui.UiView;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070023import org.osgi.service.component.annotations.Activate;
24import org.osgi.service.component.annotations.Component;
25import org.osgi.service.component.annotations.Deactivate;
26import org.osgi.service.component.annotations.Reference;
27import org.osgi.service.component.annotations.ReferenceCardinality;
Thomas Vachuska54dc3522015-09-09 00:11:45 -070028import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30
31import java.util.List;
32
33import static org.onosproject.ui.UiView.Category.NETWORK;
34
35/**
36 * Mechanism to stream data to the GUI.
37 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070038@Component(immediate = true, service = DhcpUi.class)
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070039public class DhcpUi {
Thomas Vachuska54dc3522015-09-09 00:11:45 -070040
41 private final Logger log = LoggerFactory.getLogger(getClass());
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070042 private static final ClassLoader CL = DhcpUi.class.getClassLoader();
Thomas Vachuska54dc3522015-09-09 00:11:45 -070043
Ray Milkeyd84f89b2018-08-17 14:54:17 -070044 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Thomas Vachuska54dc3522015-09-09 00:11:45 -070045 protected UiExtensionService uiExtensionService;
46
47 private final UiMessageHandlerFactory messageHandlerFactory =
48 () -> ImmutableList.of(new DhcpViewMessageHandler());
49
50 private final List<UiView> views = ImmutableList.of(
51 new UiView(NETWORK, "dhcp", "DHCP Server")
52 );
53
54 private final UiExtension uiExtension =
55 new UiExtension.Builder(CL, views)
56 .messageHandlerFactory(messageHandlerFactory)
57 .resourcePath("gui")
58 .build();
59
60 @Activate
61 protected void activate() {
62 uiExtensionService.register(uiExtension);
63 log.info("Started");
64 }
65
66 @Deactivate
67 protected void deactivate() {
68 uiExtensionService.unregister(uiExtension);
69 log.info("Stopped");
70 }
71
72}