blob: 0369dde55553a49eab7f095ab311742a3e695a8d [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;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.apache.felix.scr.annotations.Service;
25import org.onosproject.ui.UiExtension;
26import org.onosproject.ui.UiExtensionService;
27import org.onosproject.ui.UiMessageHandlerFactory;
28import org.onosproject.ui.UiView;
29import org.slf4j.Logger;
30import org.slf4j.LoggerFactory;
31
32import java.util.List;
33
34import static org.onosproject.ui.UiView.Category.NETWORK;
35
36/**
37 * Mechanism to stream data to the GUI.
38 */
39@Component(immediate = true, enabled = true)
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070040@Service(value = DhcpUi.class)
41public class DhcpUi {
Thomas Vachuska54dc3522015-09-09 00:11:45 -070042
43 private final Logger log = LoggerFactory.getLogger(getClass());
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070044 private static final ClassLoader CL = DhcpUi.class.getClassLoader();
Thomas Vachuska54dc3522015-09-09 00:11:45 -070045
46 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
47 protected UiExtensionService uiExtensionService;
48
49 private final UiMessageHandlerFactory messageHandlerFactory =
50 () -> ImmutableList.of(new DhcpViewMessageHandler());
51
52 private final List<UiView> views = ImmutableList.of(
53 new UiView(NETWORK, "dhcp", "DHCP Server")
54 );
55
56 private final UiExtension uiExtension =
57 new UiExtension.Builder(CL, views)
58 .messageHandlerFactory(messageHandlerFactory)
59 .resourcePath("gui")
60 .build();
61
62 @Activate
63 protected void activate() {
64 uiExtensionService.register(uiExtension);
65 log.info("Started");
66 }
67
68 @Deactivate
69 protected void deactivate() {
70 uiExtensionService.unregister(uiExtension);
71 log.info("Stopped");
72 }
73
74}