blob: 55b1e6fcc816678a139a1a1170492ae864f554e4 [file] [log] [blame]
Simon Hunt1ee09852015-09-29 12:28:14 -07001#set( $symbol_pound = '#' )
2#set( $symbol_dollar = '$' )
3#set( $symbol_escape = '\' )
4/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07005 * Copyright ${year}-present Open Networking Foundation
Simon Hunt1ee09852015-09-29 12:28:14 -07006 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package ${package};
20
21import com.google.common.collect.ImmutableList;
22import org.apache.felix.scr.annotations.Activate;
23import org.apache.felix.scr.annotations.Component;
24import org.apache.felix.scr.annotations.Deactivate;
25import org.apache.felix.scr.annotations.Reference;
26import org.apache.felix.scr.annotations.ReferenceCardinality;
27import org.onosproject.ui.UiExtension;
28import org.onosproject.ui.UiExtensionService;
29import org.onosproject.ui.UiMessageHandlerFactory;
30import org.onosproject.ui.UiTopoOverlayFactory;
31import org.onosproject.ui.UiView;
32import org.onosproject.ui.UiViewHidden;
33import org.slf4j.Logger;
34import org.slf4j.LoggerFactory;
35
36import java.util.List;
37
38/**
39 * Skeletal ONOS UI Topology-Overlay application component.
40 */
41@Component(immediate = true)
42public class AppUiTopovComponent {
43
44 private static final ClassLoader CL = AppUiTopovComponent.class.getClassLoader();
Simon Huntafce2ae2015-10-01 10:38:10 -070045 private static final String VIEW_ID = "sampleTopov";
Simon Hunt1ee09852015-09-29 12:28:14 -070046
47 private final Logger log = LoggerFactory.getLogger(getClass());
48
49 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
50 protected UiExtensionService uiExtensionService;
51
52 // List of application views
53 private final List<UiView> uiViews = ImmutableList.of(
Simon Huntafce2ae2015-10-01 10:38:10 -070054 new UiViewHidden(VIEW_ID)
Simon Hunt1ee09852015-09-29 12:28:14 -070055 );
56
57 // Factory for UI message handlers
58 private final UiMessageHandlerFactory messageHandlerFactory =
59 () -> ImmutableList.of(
60 new AppUiTopovMessageHandler()
61 );
62
63 // Factory for UI topology overlays
64 private final UiTopoOverlayFactory topoOverlayFactory =
65 () -> ImmutableList.of(
66 new AppUiTopovOverlay()
67 );
68
69 // Application UI extension
70 protected UiExtension extension =
71 new UiExtension.Builder(CL, uiViews)
Simon Huntafce2ae2015-10-01 10:38:10 -070072 .resourcePath(VIEW_ID)
Simon Hunt1ee09852015-09-29 12:28:14 -070073 .messageHandlerFactory(messageHandlerFactory)
74 .topoOverlayFactory(topoOverlayFactory)
75 .build();
76
77 @Activate
78 protected void activate() {
79 uiExtensionService.register(extension);
80 log.info("Started");
81 }
82
83 @Deactivate
84 protected void deactivate() {
85 uiExtensionService.unregister(extension);
86 log.info("Stopped");
87 }
88
89}