blob: 57245366b3dcdb3d992c23603da829e43643de01 [file] [log] [blame]
Simon Hunt1ee09852015-09-29 12:28:14 -07001#set( $symbol_pound = '#' )
2#set( $symbol_dollar = '$' )
3#set( $symbol_escape = '\' )
4/*
5 * Copyright 2014,2015 Open Networking Laboratory
6 *
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();
45
46 private final Logger log = LoggerFactory.getLogger(getClass());
47
48 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
49 protected UiExtensionService uiExtensionService;
50
51 // List of application views
52 private final List<UiView> uiViews = ImmutableList.of(
53 new UiViewHidden("sampleTopov")
54 );
55
56 // Factory for UI message handlers
57 private final UiMessageHandlerFactory messageHandlerFactory =
58 () -> ImmutableList.of(
59 new AppUiTopovMessageHandler()
60 );
61
62 // Factory for UI topology overlays
63 private final UiTopoOverlayFactory topoOverlayFactory =
64 () -> ImmutableList.of(
65 new AppUiTopovOverlay()
66 );
67
68 // Application UI extension
69 protected UiExtension extension =
70 new UiExtension.Builder(CL, uiViews)
71 .resourcePath("sampleTopov")
72 .messageHandlerFactory(messageHandlerFactory)
73 .topoOverlayFactory(topoOverlayFactory)
74 .build();
75
76 @Activate
77 protected void activate() {
78 uiExtensionService.register(extension);
79 log.info("Started");
80 }
81
82 @Deactivate
83 protected void deactivate() {
84 uiExtensionService.unregister(extension);
85 log.info("Stopped");
86 }
87
88}