blob: a98e8b086805842fef094722ae333b7354f943df [file] [log] [blame]
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05303 *
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 */
16
17package org.onosproject.pceweb;
18
19import com.google.common.collect.ImmutableList;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070020import org.osgi.service.component.annotations.Activate;
21import org.osgi.service.component.annotations.Component;
22import org.osgi.service.component.annotations.Deactivate;
23import org.osgi.service.component.annotations.Reference;
24import org.osgi.service.component.annotations.ReferenceCardinality;
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053025import org.onosproject.ui.UiExtension;
26import org.onosproject.ui.UiExtensionService;
27import org.onosproject.ui.UiMessageHandlerFactory;
28import org.onosproject.ui.UiTopoOverlayFactory;
29import org.onosproject.ui.UiView;
30import org.onosproject.ui.UiViewHidden;
31import org.slf4j.Logger;
32import org.slf4j.LoggerFactory;
33
34import java.util.List;
35
36/**
37 * Skeletal ONOS UI Topology-Overlay application component.
38 */
39@Component(immediate = true)
40public class PceWebTopovComponent {
41
42 private static final ClassLoader CL = PceWebTopovComponent.class.getClassLoader();
43 private static final String VIEW_ID = "pcewebTopov";
44
45 private final Logger log = LoggerFactory.getLogger(getClass());
46
Ray Milkeyd84f89b2018-08-17 14:54:17 -070047 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053048 protected UiExtensionService uiExtensionService;
49
50 // List of application views
51 private final List<UiView> uiViews = ImmutableList.of(
52 new UiViewHidden(VIEW_ID)
53 );
54
55 // Factory for UI message handlers
56 private final UiMessageHandlerFactory messageHandlerFactory =
57 () -> ImmutableList.of(
58 new PceWebTopovMessageHandler()
59 );
60
61 // Factory for UI topology overlays
62 private final UiTopoOverlayFactory topoOverlayFactory =
63 () -> ImmutableList.of(
64 new PceWebTopovOverlay()
65 );
66
67 // Application UI extension
68 protected UiExtension extension =
69 new UiExtension.Builder(CL, uiViews)
70 .resourcePath(VIEW_ID)
71 .messageHandlerFactory(messageHandlerFactory)
72 .topoOverlayFactory(topoOverlayFactory)
73 .build();
74
75 @Activate
76 protected void activate() {
77 uiExtensionService.register(extension);
78 log.info("Started");
79 }
80
81 @Deactivate
82 protected void deactivate() {
83 uiExtensionService.unregister(extension);
84 log.info("Stopped");
85 }
86
87}