blob: 7997d4ad42a1bb087ba1712c0ed97bdbb28f53d3 [file] [log] [blame]
lishuai10de6db2016-03-22 16:45:44 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
lishuai10de6db2016-03-22 16:45:44 +08003 *
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 */
16package org.onosproject.vtnweb.gui;
17
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import com.google.common.collect.ImmutableList;
lishuai10de6db2016-03-22 16:45:44 +080019import org.onosproject.ui.UiExtension;
20import org.onosproject.ui.UiExtensionService;
21import org.onosproject.ui.UiMessageHandlerFactory;
22import org.onosproject.ui.UiView;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070023import org.osgi.service.component.annotations.Activate;
24import org.osgi.service.component.annotations.Component;
25import org.osgi.service.component.annotations.Deactivate;
26import org.osgi.service.component.annotations.Reference;
27import org.osgi.service.component.annotations.ReferenceCardinality;
lishuai10de6db2016-03-22 16:45:44 +080028import org.slf4j.Logger;
29
Ray Milkeyd84f89b2018-08-17 14:54:17 -070030import java.util.List;
31
32import static com.google.common.collect.ImmutableList.of;
33import static org.onosproject.ui.UiView.Category.NETWORK;
34import static org.slf4j.LoggerFactory.getLogger;
lishuai10de6db2016-03-22 16:45:44 +080035
36/**
37 * service function chain gui.
38 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070039@Component(immediate = true, service = SfcUiExtensionManager.class)
lishuai10de6db2016-03-22 16:45:44 +080040public class SfcUiExtensionManager {
41 private final Logger log = getLogger(getClass());
42
43 private static final ClassLoader CL =
44 SfcUiExtensionManager.class.getClassLoader();
45 private static final String GUI = "gui";
46
Ray Milkeyd84f89b2018-08-17 14:54:17 -070047 @Reference(cardinality = ReferenceCardinality.MANDATORY)
lishuai10de6db2016-03-22 16:45:44 +080048 protected UiExtensionService uiExtensionService;
49
50 // service function chain extension
51 private final UiExtension sfc = createSfcExtension();
52
53 // Creates service function chain UI extension
54 private UiExtension createSfcExtension() {
55 List<UiView> coreViews = of(
56 //TODO add a new type of icon for sfc
57 new UiView(NETWORK, "sfc", "SFC", "nav_sfcs")
58 );
59
60 UiMessageHandlerFactory messageHandlerFactory =
61 () -> ImmutableList.of(
62 new SfcViewMessageHandler()
63 );
64
65 return new UiExtension.Builder(CL, coreViews)
66 .messageHandlerFactory(messageHandlerFactory)
67 .resourcePath(GUI)
68 .build();
69 }
70
71 @Activate
72 public void activate() {
73 uiExtensionService.register(sfc);
74 log.info("Started");
75 }
76
77 @Deactivate
78 public void deactivate() {
79 uiExtensionService.unregister(sfc);
80 log.info("Stopped");
81 }
82}