Refactoring intent API.
diff --git a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
index 839d2841..5c68a22 100644
--- a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
@@ -2,6 +2,8 @@
 
 import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.onlab.onos.ApplicationId;
+import org.onlab.onos.CoreService;
 import org.onlab.osgi.DefaultServiceDirectory;
 import org.onlab.osgi.ServiceNotFoundException;
 
@@ -27,6 +29,15 @@
     }
 
     /**
+     * Returns application ID for the CLI.
+     *
+     * @return command-line application identifier
+     */
+    protected ApplicationId appId() {
+        return get(CoreService.class).registerApplication("org.onlab.onos.cli");
+    }
+
+    /**
      * Prints the arguments using the specified format.
      *
      * @param format format string; see {@link String#format}
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java
index 837a0a7..5a75a17 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java
@@ -9,7 +9,6 @@
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 import org.onlab.onos.net.intent.HostToHostIntent;
-import org.onlab.onos.net.intent.IntentId;
 import org.onlab.onos.net.intent.IntentService;
 
 /**
@@ -27,8 +26,6 @@
               required = true, multiValued = false)
     String two = null;
 
-    private static long id = 0x7870001;
-
     @Override
     protected void execute() {
         IntentService service = get(IntentService.class);
@@ -39,9 +36,8 @@
         TrafficSelector selector = DefaultTrafficSelector.builder().build();
         TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
 
-        HostToHostIntent intent =
-                new HostToHostIntent(new IntentId(id++), oneId, twoId,
-                                     selector, treatment);
+        HostToHostIntent intent = new HostToHostIntent(appId(), oneId, twoId,
+                                                       selector, treatment);
         service.submit(intent);
     }
 
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/AddMultiPointToSinglePointIntentCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/AddMultiPointToSinglePointIntentCommand.java
index cdae8a6..56bbdaf 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/AddMultiPointToSinglePointIntentCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/AddMultiPointToSinglePointIntentCommand.java
@@ -1,8 +1,5 @@
 package org.onlab.onos.cli.net;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onlab.onos.cli.AbstractShellCommand;
@@ -14,11 +11,16 @@
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 import org.onlab.onos.net.intent.Intent;
-import org.onlab.onos.net.intent.IntentId;
 import org.onlab.onos.net.intent.IntentService;
 import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
 import org.onlab.packet.Ethernet;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.onlab.onos.net.DeviceId.deviceId;
+import static org.onlab.onos.net.PortNumber.portNumber;
+
 /**
  * Installs point-to-point connectivity intents.
  */
@@ -31,8 +33,6 @@
               required = true, multiValued = true)
     String[] deviceStrings = null;
 
-    private static long id = 0x7070001;
-
     @Override
     protected void execute() {
         IntentService service = get(IntentService.class);
@@ -42,33 +42,26 @@
         }
 
         String egressDeviceString = deviceStrings[deviceStrings.length - 1];
-        DeviceId egressDeviceId = DeviceId.deviceId(getDeviceId(egressDeviceString));
-        PortNumber egressPortNumber =
-                PortNumber.portNumber(getPortNumber(egressDeviceString));
+        DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
+        PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
         ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
         Set<ConnectPoint> ingressPoints = new HashSet<>();
 
         for (int index = 0; index < deviceStrings.length - 1; index++) {
             String ingressDeviceString = deviceStrings[index];
-            DeviceId ingressDeviceId = DeviceId.deviceId(getDeviceId(ingressDeviceString));
-            PortNumber ingressPortNumber =
-                    PortNumber.portNumber(getPortNumber(ingressDeviceString));
+            DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
+            PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
             ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
             ingressPoints.add(ingress);
         }
 
-
         TrafficSelector selector = DefaultTrafficSelector.builder()
                 .matchEthType(Ethernet.TYPE_IPV4)
                 .build();
         TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
 
-        Intent intent =
-                new MultiPointToSinglePointIntent(new IntentId(id++),
-                                                  selector,
-                                                  treatment,
-                                                  ingressPoints,
-                                                  egress);
+        Intent intent = new MultiPointToSinglePointIntent(appId(), selector, treatment,
+                                                          ingressPoints, egress);
         service.submit(intent);
     }
 
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/AddPointToPointIntentCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/AddPointToPointIntentCommand.java
index 89ec7f6..bd24366 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/AddPointToPointIntentCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/AddPointToPointIntentCommand.java
@@ -11,11 +11,13 @@
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 import org.onlab.onos.net.intent.Intent;
-import org.onlab.onos.net.intent.IntentId;
 import org.onlab.onos.net.intent.IntentService;
 import org.onlab.onos.net.intent.PointToPointIntent;
 import org.onlab.packet.Ethernet;
 
+import static org.onlab.onos.net.DeviceId.deviceId;
+import static org.onlab.onos.net.PortNumber.portNumber;
+
 /**
  * Installs point-to-point connectivity intents.
  */
@@ -33,20 +35,16 @@
               required = true, multiValued = false)
     String egressDeviceString = null;
 
-    private static long id = 0x7470001;
-
     @Override
     protected void execute() {
         IntentService service = get(IntentService.class);
 
-        DeviceId ingressDeviceId = DeviceId.deviceId(getDeviceId(ingressDeviceString));
-        PortNumber ingressPortNumber =
-                PortNumber.portNumber(getPortNumber(ingressDeviceString));
+        DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
+        PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
         ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
 
-        DeviceId egressDeviceId = DeviceId.deviceId(getDeviceId(egressDeviceString));
-        PortNumber egressPortNumber =
-                PortNumber.portNumber(getPortNumber(egressDeviceString));
+        DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
+        PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
         ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
 
         TrafficSelector selector = DefaultTrafficSelector.builder()
@@ -54,12 +52,8 @@
                 .build();
         TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
 
-        Intent intent =
-                new PointToPointIntent(new IntentId(id++),
-                                                 selector,
-                                                 treatment,
-                                                 ingress,
-                                                 egress);
+        Intent intent = new PointToPointIntent(appId(), selector, treatment,
+                                               ingress, egress);
         service.submit(intent);
     }
 
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/IntentPushTestCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/IntentPushTestCommand.java
index 4c3ed8e..bd010ae 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/IntentPushTestCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/IntentPushTestCommand.java
@@ -1,8 +1,5 @@
 package org.onlab.onos.cli.net;
 
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onlab.onos.cli.AbstractShellCommand;
@@ -16,20 +13,25 @@
 import org.onlab.onos.net.intent.Intent;
 import org.onlab.onos.net.intent.IntentEvent;
 import org.onlab.onos.net.intent.IntentEvent.Type;
-import org.onlab.onos.net.intent.IntentId;
 import org.onlab.onos.net.intent.IntentListener;
 import org.onlab.onos.net.intent.IntentService;
 import org.onlab.onos.net.intent.PointToPointIntent;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.MacAddress;
 
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.onlab.onos.net.DeviceId.deviceId;
+import static org.onlab.onos.net.PortNumber.portNumber;
+
 /**
  * Installs point-to-point connectivity intents.
  */
 @Command(scope = "onos", name = "push-test-intents",
          description = "Installs random intents to test throughput")
 public class IntentPushTestCommand extends AbstractShellCommand
-    implements IntentListener {
+        implements IntentListener {
 
     @Argument(index = 0, name = "ingressDevice",
               description = "Ingress Device/Port Description",
@@ -42,8 +44,8 @@
     String egressDeviceString = null;
 
     @Argument(index = 2, name = "count",
-            description = "Number of intents to push",
-            required = true, multiValued = false)
+              description = "Number of intents to push",
+              required = true, multiValued = false)
     String countString = null;
 
 
@@ -57,14 +59,12 @@
     protected void execute() {
         service = get(IntentService.class);
 
-        DeviceId ingressDeviceId = DeviceId.deviceId(getDeviceId(ingressDeviceString));
-        PortNumber ingressPortNumber =
-                PortNumber.portNumber(getPortNumber(ingressDeviceString));
+        DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
+        PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
         ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
 
-        DeviceId egressDeviceId = DeviceId.deviceId(getDeviceId(egressDeviceString));
-        PortNumber egressPortNumber =
-                PortNumber.portNumber(getPortNumber(egressDeviceString));
+        DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
+        PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
         ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
 
         TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
@@ -79,14 +79,10 @@
         start = System.currentTimeMillis();
         for (int i = 0; i < count; i++) {
             TrafficSelector s = selector
-                                .matchEthSrc(MacAddress.valueOf(i))
-                                .build();
-            Intent intent =
-                    new PointToPointIntent(new IntentId(id++),
-                                                     s,
-                                                     treatment,
-                                                     ingress,
-                                                     egress);
+                    .matchEthSrc(MacAddress.valueOf(i))
+                    .build();
+            Intent intent = new PointToPointIntent(appId(), s, treatment,
+                                                   ingress, egress);
             service.submit(intent);
         }
         try {
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/IntentRemoveCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/IntentRemoveCommand.java
index 7684da4..b2cef88 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/IntentRemoveCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/IntentRemoveCommand.java
@@ -26,9 +26,8 @@
         if (radix == 16) {
             id = id.replaceFirst("0x", "");
         }
-        IntentId intentId = new IntentId(Long.parseLong(id, radix));
 
-
+        IntentId intentId = IntentId.valueOf(Long.parseLong(id, radix));
         Intent intent = service.getIntent(intentId);
         if (intent != null) {
             service.withdraw(intent);