blob: e44b34d5c7742d47cd4282c6641573f53798f231 [file] [log] [blame]
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -07001#set( $symbol_pound = '#' )
2#set( $symbol_dollar = '$' )
3#set( $symbol_escape = '\' )
4/*
Simon Hunte11ce5a2015-07-21 12:11:04 -07005 * Copyright 2014,2015 Open Networking Laboratory
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -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
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070021import com.google.common.collect.ImmutableList;
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070022import org.apache.felix.scr.annotations.Activate;
23import org.apache.felix.scr.annotations.Component;
24import org.apache.felix.scr.annotations.Deactivate;
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070025import org.apache.felix.scr.annotations.Reference;
26import org.apache.felix.scr.annotations.ReferenceCardinality;
27import org.onosproject.ui.UiExtension;
28import org.onosproject.ui.UiExtensionService;
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070029import org.onosproject.ui.UiMessageHandlerFactory;
30import org.onosproject.ui.UiView;
31import org.slf4j.Logger;
32import org.slf4j.LoggerFactory;
33
34import java.util.List;
35
36/**
Simon Hunt84f4c2a2015-09-23 17:52:45 -070037 * Skeletal ONOS UI Custom-View application component.
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070038 */
39@Component(immediate = true)
40public class AppUiComponent {
41
Simon Huntafce2ae2015-10-01 10:38:10 -070042 private static final String VIEW_ID = "sampleCustom";
43 private static final String VIEW_TEXT = "Sample Custom";
44
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070045 private final Logger log = LoggerFactory.getLogger(getClass());
46
47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 protected UiExtensionService uiExtensionService;
49
50 // List of application views
51 private final List<UiView> uiViews = ImmutableList.of(
Simon Huntafce2ae2015-10-01 10:38:10 -070052 new UiView(UiView.Category.OTHER, VIEW_ID, VIEW_TEXT)
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070053 );
54
55 // Factory for UI message handlers
56 private final UiMessageHandlerFactory messageHandlerFactory =
57 () -> ImmutableList.of(
58 new AppUiMessageHandler()
59 );
60
Thomas Vachuska92900532015-05-20 17:21:44 -070061 // Application UI extension
Simon Hunte11ce5a2015-07-21 12:11:04 -070062 protected UiExtension extension =
Simon Hunte05cae42015-07-23 17:35:24 -070063 new UiExtension.Builder(getClass().getClassLoader(), uiViews)
64 .messageHandlerFactory(messageHandlerFactory)
65 .build();
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070066
67 @Activate
68 protected void activate() {
69 uiExtensionService.register(extension);
70 log.info("Started");
71 }
72
73 @Deactivate
74 protected void deactivate() {
75 uiExtensionService.unregister(extension);
76 log.info("Stopped");
77 }
78
Thomas Vachuskaa2ae4222015-04-29 18:42:09 -070079}