Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -0700 | [diff] [blame] | 1 | #set( $symbol_pound = '#' ) |
| 2 | #set( $symbol_dollar = '$' ) |
| 3 | #set( $symbol_escape = '\' ) |
| 4 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 5 | * Copyright ${year}-present Open Networking Foundation |
Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -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 | |
| 21 | import com.google.common.collect.ImmutableList; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 22 | import org.osgi.service.component.annotations.Activate; |
| 23 | import org.osgi.service.component.annotations.Component; |
| 24 | import org.osgi.service.component.annotations.Deactivate; |
| 25 | import org.osgi.service.component.annotations.Reference; |
| 26 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -0700 | [diff] [blame] | 27 | import org.onosproject.ui.UiExtension; |
| 28 | import org.onosproject.ui.UiExtensionService; |
| 29 | import org.onosproject.ui.UiMessageHandlerFactory; |
| 30 | import org.onosproject.ui.UiTopoOverlayFactory; |
| 31 | import org.onosproject.ui.UiView; |
| 32 | import org.onosproject.ui.UiViewHidden; |
| 33 | import org.slf4j.Logger; |
| 34 | import org.slf4j.LoggerFactory; |
| 35 | |
| 36 | import java.util.List; |
| 37 | |
| 38 | /** |
| 39 | * Skeletal ONOS UI Topology-Overlay application component. |
| 40 | */ |
| 41 | @Component(immediate = true) |
| 42 | public class AppUiTopovComponent { |
| 43 | |
| 44 | private static final ClassLoader CL = AppUiTopovComponent.class.getClassLoader(); |
Simon Hunt | afce2ae | 2015-10-01 10:38:10 -0700 | [diff] [blame] | 45 | private static final String VIEW_ID = "sampleTopov"; |
Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -0700 | [diff] [blame] | 46 | |
| 47 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 48 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 49 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -0700 | [diff] [blame] | 50 | protected UiExtensionService uiExtensionService; |
| 51 | |
| 52 | // List of application views |
| 53 | private final List<UiView> uiViews = ImmutableList.of( |
Simon Hunt | afce2ae | 2015-10-01 10:38:10 -0700 | [diff] [blame] | 54 | new UiViewHidden(VIEW_ID) |
Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -0700 | [diff] [blame] | 55 | ); |
| 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 Hunt | afce2ae | 2015-10-01 10:38:10 -0700 | [diff] [blame] | 72 | .resourcePath(VIEW_ID) |
Simon Hunt | 1ee0985 | 2015-09-29 12:28:14 -0700 | [diff] [blame] | 73 | .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 | } |