Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.pceweb; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableList; |
| 20 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; |
| 22 | import org.apache.felix.scr.annotations.Deactivate; |
| 23 | import org.apache.felix.scr.annotations.Reference; |
| 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 25 | import org.onosproject.ui.UiExtension; |
| 26 | import org.onosproject.ui.UiExtensionService; |
| 27 | import org.onosproject.ui.UiMessageHandlerFactory; |
| 28 | import org.onosproject.ui.UiTopoOverlayFactory; |
| 29 | import org.onosproject.ui.UiView; |
| 30 | import org.onosproject.ui.UiViewHidden; |
| 31 | import org.slf4j.Logger; |
| 32 | import org.slf4j.LoggerFactory; |
| 33 | |
| 34 | import java.util.List; |
| 35 | |
| 36 | /** |
| 37 | * Skeletal ONOS UI Topology-Overlay application component. |
| 38 | */ |
| 39 | @Component(immediate = true) |
| 40 | public class PceWebTopovComponent { |
| 41 | |
| 42 | private static final ClassLoader CL = PceWebTopovComponent.class.getClassLoader(); |
| 43 | private static final String VIEW_ID = "pcewebTopov"; |
| 44 | |
| 45 | 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( |
| 52 | new UiViewHidden(VIEW_ID) |
| 53 | ); |
| 54 | |
| 55 | // Factory for UI message handlers |
| 56 | private final UiMessageHandlerFactory messageHandlerFactory = |
| 57 | () -> ImmutableList.of( |
| 58 | new PceWebTopovMessageHandler() |
| 59 | ); |
| 60 | |
| 61 | // Factory for UI topology overlays |
| 62 | private final UiTopoOverlayFactory topoOverlayFactory = |
| 63 | () -> ImmutableList.of( |
| 64 | new PceWebTopovOverlay() |
| 65 | ); |
| 66 | |
| 67 | // Application UI extension |
| 68 | protected UiExtension extension = |
| 69 | new UiExtension.Builder(CL, uiViews) |
| 70 | .resourcePath(VIEW_ID) |
| 71 | .messageHandlerFactory(messageHandlerFactory) |
| 72 | .topoOverlayFactory(topoOverlayFactory) |
| 73 | .build(); |
| 74 | |
| 75 | @Activate |
| 76 | protected void activate() { |
| 77 | uiExtensionService.register(extension); |
| 78 | log.info("Started"); |
| 79 | } |
| 80 | |
| 81 | @Deactivate |
| 82 | protected void deactivate() { |
| 83 | uiExtensionService.unregister(extension); |
| 84 | log.info("Stopped"); |
| 85 | } |
| 86 | |
| 87 | } |