Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 1 | #set( $symbol_pound = '#' ) |
| 2 | #set( $symbol_dollar = '$' ) |
| 3 | #set( $symbol_escape = '\' ) |
| 4 | /* |
Simon Hunt | e11ce5a | 2015-07-21 12:11:04 -0700 | [diff] [blame] | 5 | * Copyright 2014,2015 Open Networking Laboratory |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 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 | */ |
| 19 | package ${package}; |
| 20 | |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 21 | import com.google.common.collect.ImmutableList; |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 22 | import org.apache.felix.scr.annotations.Activate; |
| 23 | import org.apache.felix.scr.annotations.Component; |
| 24 | import org.apache.felix.scr.annotations.Deactivate; |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 25 | import org.apache.felix.scr.annotations.Reference; |
| 26 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 27 | import org.onosproject.ui.UiExtension; |
| 28 | import org.onosproject.ui.UiExtensionService; |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 29 | import org.onosproject.ui.UiMessageHandlerFactory; |
| 30 | import org.onosproject.ui.UiView; |
| 31 | import org.slf4j.Logger; |
| 32 | import org.slf4j.LoggerFactory; |
| 33 | |
| 34 | import java.util.List; |
| 35 | |
| 36 | /** |
| 37 | * Skeletal ONOS UI application component. |
| 38 | */ |
| 39 | @Component(immediate = true) |
| 40 | public class AppUiComponent { |
| 41 | |
| 42 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 43 | |
| 44 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 45 | protected UiExtensionService uiExtensionService; |
| 46 | |
| 47 | // List of application views |
| 48 | private final List<UiView> uiViews = ImmutableList.of( |
| 49 | new UiView(UiView.Category.OTHER, "sample", "Sample") |
| 50 | ); |
| 51 | |
| 52 | // Factory for UI message handlers |
| 53 | private final UiMessageHandlerFactory messageHandlerFactory = |
| 54 | () -> ImmutableList.of( |
| 55 | new AppUiMessageHandler() |
| 56 | ); |
| 57 | |
Thomas Vachuska | 9290053 | 2015-05-20 17:21:44 -0700 | [diff] [blame] | 58 | // Application UI extension |
Simon Hunt | e11ce5a | 2015-07-21 12:11:04 -0700 | [diff] [blame] | 59 | protected UiExtension extension = |
Simon Hunt | e05cae4 | 2015-07-23 17:35:24 -0700 | [diff] [blame] | 60 | new UiExtension.Builder(getClass().getClassLoader(), uiViews) |
| 61 | .messageHandlerFactory(messageHandlerFactory) |
| 62 | .build(); |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 63 | |
| 64 | @Activate |
| 65 | protected void activate() { |
| 66 | uiExtensionService.register(extension); |
| 67 | log.info("Started"); |
| 68 | } |
| 69 | |
| 70 | @Deactivate |
| 71 | protected void deactivate() { |
| 72 | uiExtensionService.unregister(extension); |
| 73 | log.info("Stopped"); |
| 74 | } |
| 75 | |
Thomas Vachuska | a2ae422 | 2015-04-29 18:42:09 -0700 | [diff] [blame] | 76 | } |