Committed by
Gerrit Code Review
[ONOS-4195] Register sfc gui.
Change-Id: I4923cbe883eb1604c80476780b4c9e553b7ed952
Showing
1 changed file
with
85 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
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 | +package org.onosproject.vtnweb.gui; | ||
17 | + | ||
18 | +import static com.google.common.collect.ImmutableList.of; | ||
19 | +import static org.onosproject.ui.UiView.Category.NETWORK; | ||
20 | +import static org.slf4j.LoggerFactory.getLogger; | ||
21 | + | ||
22 | +import java.util.List; | ||
23 | + | ||
24 | +import org.apache.felix.scr.annotations.Activate; | ||
25 | +import org.apache.felix.scr.annotations.Component; | ||
26 | +import org.apache.felix.scr.annotations.Deactivate; | ||
27 | +import org.apache.felix.scr.annotations.Reference; | ||
28 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
29 | +import org.apache.felix.scr.annotations.Service; | ||
30 | +import org.onosproject.ui.UiExtension; | ||
31 | +import org.onosproject.ui.UiExtensionService; | ||
32 | +import org.onosproject.ui.UiMessageHandlerFactory; | ||
33 | +import org.onosproject.ui.UiView; | ||
34 | +import org.slf4j.Logger; | ||
35 | + | ||
36 | +import com.google.common.collect.ImmutableList; | ||
37 | + | ||
38 | +/** | ||
39 | + * service function chain gui. | ||
40 | + */ | ||
41 | +@Component(immediate = true, enabled = true) | ||
42 | +@Service(value = SfcUiExtensionManager.class) | ||
43 | +public class SfcUiExtensionManager { | ||
44 | + private final Logger log = getLogger(getClass()); | ||
45 | + | ||
46 | + private static final ClassLoader CL = | ||
47 | + SfcUiExtensionManager.class.getClassLoader(); | ||
48 | + private static final String GUI = "gui"; | ||
49 | + | ||
50 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
51 | + protected UiExtensionService uiExtensionService; | ||
52 | + | ||
53 | + // service function chain extension | ||
54 | + private final UiExtension sfc = createSfcExtension(); | ||
55 | + | ||
56 | + // Creates service function chain UI extension | ||
57 | + private UiExtension createSfcExtension() { | ||
58 | + List<UiView> coreViews = of( | ||
59 | + //TODO add a new type of icon for sfc | ||
60 | + new UiView(NETWORK, "sfc", "SFC", "nav_sfcs") | ||
61 | + ); | ||
62 | + | ||
63 | + UiMessageHandlerFactory messageHandlerFactory = | ||
64 | + () -> ImmutableList.of( | ||
65 | + new SfcViewMessageHandler() | ||
66 | + ); | ||
67 | + | ||
68 | + return new UiExtension.Builder(CL, coreViews) | ||
69 | + .messageHandlerFactory(messageHandlerFactory) | ||
70 | + .resourcePath(GUI) | ||
71 | + .build(); | ||
72 | + } | ||
73 | + | ||
74 | + @Activate | ||
75 | + public void activate() { | ||
76 | + uiExtensionService.register(sfc); | ||
77 | + log.info("Started"); | ||
78 | + } | ||
79 | + | ||
80 | + @Deactivate | ||
81 | + public void deactivate() { | ||
82 | + uiExtensionService.unregister(sfc); | ||
83 | + log.info("Stopped"); | ||
84 | + } | ||
85 | +} |
-
Please register or login to post a comment