[WIP] Upgrade ONOS to karaf version 4.2.1

Change-Id: I7cd40c995bdf1c80f94b1895fb3344e32404c7fa
diff --git a/web/gui/BUILD b/web/gui/BUILD
index be8e3f3..8731629 100644
--- a/web/gui/BUILD
+++ b/web/gui/BUILD
@@ -32,9 +32,10 @@
     "@javax_ws_rs_api//jar",
     "@servlet_api//jar",
     "@jetty_websocket//jar",
+    "@jetty_websocket_api//jar",
     "@jetty_util//jar",
     "@jersey_media_multipart//jar",
-    "@org_apache_karaf_shell_console//jar",
+    "@org_apache_karaf_shell_core//jar",
     "@jersey_server//jar",
     "//cli:onos-cli",
     "//incubator/api:onos-incubator-api",
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
index bb24c89..c776fb3 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
@@ -32,12 +32,6 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
 import org.onlab.util.Tools;
 import org.onosproject.mastership.MastershipService;
 import org.onosproject.store.serializers.KryoNamespaces;
@@ -66,6 +60,11 @@
 import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
 import org.onosproject.ui.lion.LionBundle;
 import org.onosproject.ui.lion.LionUtils;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,10 +81,10 @@
 import static com.google.common.collect.ImmutableList.of;
 import static java.util.stream.Collectors.toSet;
 import static org.onosproject.security.AppGuard.checkPermission;
-import static org.onosproject.security.AppPermission.Type.UI_READ;
-import static org.onosproject.security.AppPermission.Type.UI_WRITE;
 import static org.onosproject.security.AppPermission.Type.GLYPH_READ;
 import static org.onosproject.security.AppPermission.Type.GLYPH_WRITE;
+import static org.onosproject.security.AppPermission.Type.UI_READ;
+import static org.onosproject.security.AppPermission.Type.UI_WRITE;
 import static org.onosproject.ui.UiView.Category.NETWORK;
 import static org.onosproject.ui.UiView.Category.PLATFORM;
 import static org.onosproject.ui.impl.lion.BundleStitcher.generateBundles;
@@ -93,8 +92,8 @@
 /**
  * Manages the user interface extensions.
  */
-@Component(immediate = true)
-@Service
+@Component(immediate = true, service = { UiExtensionService.class, UiPreferencesService.class, SpriteService.class,
+        UiTokenService.class })
 public class UiExtensionManager
         implements UiExtensionService, UiPreferencesService, SpriteService,
         UiTokenService {
@@ -148,13 +147,13 @@
     // Core views & core extension
     private final UiExtension core = createCoreExtension();
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected MastershipService mastershipService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected StorageService storageService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private UiSharedTopologyModel sharedModel;
 
     // User preferences
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
index e53a007..bb07de1 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
@@ -18,7 +18,11 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.eclipse.jetty.websocket.WebSocket;
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
 import org.onlab.osgi.ServiceDirectory;
 import org.onlab.osgi.ServiceNotFoundException;
 import org.onosproject.cluster.ClusterService;
@@ -54,8 +58,10 @@
 /**
  * Web socket capable of interacting with the Web UI.
  */
+
+@WebSocket
 public class UiWebSocket
-        implements UiConnection, WebSocket.OnTextMessage, WebSocket.OnControl {
+        implements UiConnection {
 
     private static final Logger log = LoggerFactory.getLogger(UiWebSocket.class);
 
@@ -90,8 +96,8 @@
     private final ServiceDirectory directory;
     private final UiTopoSession topoSession;
 
-    private Connection connection;
-    private FrameConnection control;
+    private Session session;
+    //private FrameConnection control;
     private String userName;
     private String currentView;
 
@@ -173,8 +179,8 @@
      */
     synchronized void close() {
         destroyHandlersAndOverlays();
-        if (connection.isOpen()) {
-            connection.close();
+        if (session.isOpen()) {
+            session.close();
         }
     }
 
@@ -186,23 +192,23 @@
     synchronized boolean isIdle() {
         long quietFor = System.currentTimeMillis() - lastActive;
         boolean idle = quietFor > MAX_AGE_MS;
-        if (idle || (connection != null && !connection.isOpen())) {
+        if (idle || (session != null && !session.isOpen())) {
             log.debug("IDLE (or closed) websocket [{} ms]", quietFor);
             return true;
-        } else if (connection != null) {
-            try {
-                control.sendControl(PING, PING_DATA, 0, PING_DATA.length);
-            } catch (IOException e) {
-                log.warn("Unable to send ping message due to: ", e);
-            }
+        //} else if (session != null) {
+        //    try {
+        //        control.sendControl(PING, PING_DATA, 0, PING_DATA.length);
+        //    } catch (IOException e) {
+        //        log.warn("Unable to send ping message due to: ", e);
+        //    }
         }
         return false;
     }
 
-    @Override
-    public synchronized void onOpen(Connection connection) {
-        this.connection = connection;
-        this.control = (FrameConnection) connection;
+    @OnWebSocketConnect
+    public synchronized void onOpen(Session session) {
+        this.session = session;
+        //this.control = (FrameConnection) connection;
         try {
             topoSession.init();
             createHandlersAndOverlays();
@@ -212,13 +218,13 @@
 
         } catch (ServiceNotFoundException e) {
             log.warn("Unable to open GUI connection; services have been shut-down", e);
-            this.connection.close();
-            this.connection = null;
-            this.control = null;
+            this.session.close();
+            this.session = null;
+            //this.control = null;
         }
     }
 
-    @Override
+    @OnWebSocketClose
     public synchronized void onClose(int closeCode, String message) {
         try {
             try {
@@ -238,13 +244,7 @@
                  closeCode, message);
     }
 
-    @Override
-    public boolean onControl(byte controlCode, byte[] data, int offset, int length) {
-        lastActive = System.currentTimeMillis();
-        return true;
-    }
-
-    @Override
+    @OnWebSocketMessage
     public void onMessage(String data) {
         lastActive = System.currentTimeMillis();
         try {
@@ -272,8 +272,8 @@
     @Override
     public synchronized void sendMessage(ObjectNode message) {
         try {
-            if (connection.isOpen()) {
-                connection.sendMessage(message.toString());
+            if (session.isOpen()) {
+                session.getRemote().sendString(message.toString());
                 log.debug("TX message: {}", message);
             }
         } catch (IOException e) {
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocketServlet.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocketServlet.java
index 650f727..4faae28 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocketServlet.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocketServlet.java
@@ -18,13 +18,15 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
-import org.eclipse.jetty.websocket.WebSocket;
-import org.eclipse.jetty.websocket.WebSocketServlet;
+import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
+import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
 import org.onlab.osgi.DefaultServiceDirectory;
 import org.onlab.osgi.ServiceDirectory;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.security.Principal;
 import java.util.Set;
 import java.util.Timer;
@@ -47,6 +49,11 @@
     private final TimerTask pruner = new Pruner();
     private static boolean isStopped = false;
 
+    @Override
+    public void configure(WebSocketServletFactory webSocketServletFactory) {
+
+    }
+
     /**
      * Closes all currently open UI web-sockets.
      */
@@ -72,9 +79,11 @@
     }
 
     @Override
-    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
+    public void service(HttpServletRequest request, HttpServletResponse response)
+           throws ServletException, IOException {
+        super.service(request, response);
         if (isStopped) {
-            return null;
+            return;
         }
 
         // FIXME: Replace this with globally shared opaque token to allow secure failover
@@ -83,7 +92,6 @@
 
         UiWebSocket socket = new UiWebSocket(directory, userName);
         sockets.add(socket);
-        return socket;
     }
 
     // FIXME: This should not be necessary
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiPreferencesListCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiPreferencesListCommand.java
index b79a116..eea1348 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiPreferencesListCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiPreferencesListCommand.java
@@ -17,7 +17,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.ui.UiPreferencesService;
 
@@ -29,7 +29,7 @@
 public class UiPreferencesListCommand extends AbstractShellCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiPreferencesService service = get(UiPreferencesService.class);
         ObjectMapper mapper = new ObjectMapper();
         ObjectNode root = mapper.createObjectNode();
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiViewListCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiViewListCommand.java
index cea67a0..b72210c 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiViewListCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/cli/UiViewListCommand.java
@@ -18,7 +18,7 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.ui.UiExtension;
 import org.onosproject.ui.UiExtensionService;
@@ -35,7 +35,7 @@
     private static final String FMT = "id=%s, category=%s, label=%s, icon=%s";
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiExtensionService service = get(UiExtensionService.class);
         if (outputJson()) {
             print("%s", json(service.getExtensions()));
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoLayoutManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoLayoutManager.java
index d2ab2a7..7441672 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoLayoutManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/UiTopoLayoutManager.java
@@ -17,12 +17,6 @@
 package org.onosproject.ui.impl.topo;
 
 import com.google.common.collect.ImmutableSet;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
 import org.onosproject.net.config.NetworkConfigEvent;
 import org.onosproject.net.config.NetworkConfigListener;
 import org.onosproject.net.config.NetworkConfigRegistry;
@@ -32,6 +26,11 @@
 import org.onosproject.ui.model.topo.UiRegion;
 import org.onosproject.ui.model.topo.UiTopoLayout;
 import org.onosproject.ui.model.topo.UiTopoLayoutId;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,8 +49,7 @@
  * Manages the user interface topology layouts.
  * Note that these layouts are persisted and distributed across the cluster.
  */
-@Component(immediate = true)
-@Service
+@Component(immediate = true, service = UiTopoLayoutService.class)
 public class UiTopoLayoutManager implements UiTopoLayoutService {
 
     private static final String ID_NULL = "Layout ID cannot be null";
@@ -62,7 +60,7 @@
     private final InternalConfigListener cfgListener = new InternalConfigListener();
     private final Map<UiTopoLayoutId, UiTopoLayout> layoutMap = new HashMap<>();
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected NetworkConfigRegistry cfgService;
 
 
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheDevicesCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheDevicesCommand.java
index 612dfac..138a979 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheDevicesCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheDevicesCommand.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
 
 /**
@@ -27,7 +27,7 @@
 public class UiCacheDevicesCommand extends AbstractUiCacheElementCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiSharedTopologyModel model = get(UiSharedTopologyModel.class);
         sorted(model.getDevices()).forEach(d -> print("%s", d));
     }
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheHostsCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheHostsCommand.java
index f2ec711..99a0360 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheHostsCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheHostsCommand.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
 
 /**
@@ -27,7 +27,7 @@
 public class UiCacheHostsCommand extends AbstractUiCacheElementCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiSharedTopologyModel model = get(UiSharedTopologyModel.class);
         sorted(model.getHosts()).forEach(h -> print("%s", h));
     }
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheLinksCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheLinksCommand.java
index 30fbe4b..929da23 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheLinksCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheLinksCommand.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
 
 /**
@@ -27,7 +27,7 @@
 public class UiCacheLinksCommand extends AbstractUiCacheElementCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiSharedTopologyModel model = get(UiSharedTopologyModel.class);
         sorted(model.getDeviceLinks()).forEach(l -> print("%s", l));
     }
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheMembersCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheMembersCommand.java
index d54a750..6db4e25 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheMembersCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheMembersCommand.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
 
 /**
@@ -27,7 +27,7 @@
 public class UiCacheMembersCommand extends AbstractUiCacheElementCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiSharedTopologyModel model = get(UiSharedTopologyModel.class);
         // note: getClusterMembers() returns an already sorted list...
         model.getClusterMembers().forEach(m -> print("%s", m));
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheRegionsCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheRegionsCommand.java
index 5fef5ff..c35af78 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheRegionsCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiCacheRegionsCommand.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
 
 /**
@@ -27,7 +27,7 @@
 public class UiCacheRegionsCommand extends AbstractUiCacheElementCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiSharedTopologyModel model = get(UiSharedTopologyModel.class);
         print("%s", model.getNullRegion());
         sorted(model.getRegions()).forEach(r -> print("%s", r));
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiClearMetaCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiClearMetaCommand.java
index ecbd82a..22b096a 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiClearMetaCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiClearMetaCommand.java
@@ -17,7 +17,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.ui.impl.TopologyViewMessageHandlerBase;
 
@@ -29,7 +29,7 @@
 public class UiClearMetaCommand extends AbstractShellCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         TopologyViewMessageHandlerBase.clearMetaUi();
     }
 }
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiGeoMapListCommand.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiGeoMapListCommand.java
index 8134a62..107a7da 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiGeoMapListCommand.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/UiGeoMapListCommand.java
@@ -17,7 +17,7 @@
 
 package org.onosproject.ui.impl.topo.cli;
 
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.ui.UiExtensionService;
 import org.onosproject.ui.UiTopoMapFactory;
@@ -31,7 +31,7 @@
 public class UiGeoMapListCommand extends AbstractShellCommand {
 
     @Override
-    protected void execute() {
+    protected void doExecute() {
         UiExtensionService uxs = get(UiExtensionService.class);
         uxs.getExtensions().forEach(ext -> {
             UiTopoMapFactory mapFactory = ext.topoMapFactory();
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
index 14d29ac..d70ecf6 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
@@ -16,12 +16,6 @@
 
 package org.onosproject.ui.impl.topo.model;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
 import org.onosproject.cluster.ClusterEvent;
 import org.onosproject.cluster.ClusterEventListener;
 import org.onosproject.cluster.ClusterService;
@@ -71,6 +65,11 @@
 import org.onosproject.ui.model.topo.UiModelEvent;
 import org.onosproject.ui.model.topo.UiRegion;
 import org.onosproject.ui.model.topo.UiSynthLink;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -85,41 +84,40 @@
 /**
  * Service that creates and maintains the UI-model of the network topology.
  */
-@Component(immediate = true, enabled = true)
-@Service(value = UiSharedTopologyModel.class)
+@Component(immediate = true, service = UiSharedTopologyModel.class)
 public final class UiSharedTopologyModel
         extends AbstractListenerManager<UiModelEvent, UiModelListener> {
 
     private static final Logger log =
             LoggerFactory.getLogger(UiSharedTopologyModel.class);
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private UiTopoLayoutService layoutService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private ClusterService clusterService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private MastershipService mastershipService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private RegionService regionService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private DeviceService deviceService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private LinkService linkService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private HostService hostService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private IntentService intentService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private FlowRuleService flowService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private StatisticService flowStatsService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private PortStatisticsService portStatsService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private TopologyService topologyService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private TunnelService tunnelService;
 
     private final ClusterEventListener clusterListener =