Merge "Adding server-side code for sending device/host details to the client."
diff --git a/apps/demo/pom.xml b/apps/demo/pom.xml
new file mode 100644
index 0000000..fbc7f91
--- /dev/null
+++ b/apps/demo/pom.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2014 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onlab.onos</groupId>
+        <artifactId>onos-apps</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-app-demo</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS demo app bundle</description>
+
+    <properties>
+        <web.context>/onos/demo</web.context>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onlab.onos</groupId>
+            <artifactId>onlab-rest</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onlab.onos</groupId>
+            <artifactId>onos-rest</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-servlet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-core</artifactId>
+            <version>1.18.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-grizzly2</artifactId>
+            <version>1.18.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <_wab>src/main/webapp/</_wab>
+                        <Bundle-SymbolicName>
+                            ${project.groupId}.${project.artifactId}
+                        </Bundle-SymbolicName>
+                        <Import-Package>
+                            org.slf4j,
+                            org.osgi.framework,
+                            javax.ws.rs,javax.ws.rs.core,
+                            com.sun.jersey.api.core,
+                            com.sun.jersey.spi.container.servlet,
+                            com.sun.jersey.server.impl.container.servlet,
+                            com.fasterxml.jackson.databind,
+                            com.fasterxml.jackson.databind.node,
+                            com.google.common.*,
+                            org.onlab.packet.*,
+                            org.onlab.rest.*,
+                            org.onlab.onos.*
+                        </Import-Package>
+                        <Web-ContextPath>${web.context}</Web-ContextPath>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/apps/demo/src/main/java/org/onlab/onos/demo/DemoAPI.java b/apps/demo/src/main/java/org/onlab/onos/demo/DemoAPI.java
new file mode 100644
index 0000000..2a267f3
--- /dev/null
+++ b/apps/demo/src/main/java/org/onlab/onos/demo/DemoAPI.java
@@ -0,0 +1,21 @@
+package org.onlab.onos.demo;
+
+/**
+ * Simple demo api interface.
+ */
+public interface DemoAPI {
+
+    enum InstallType { MESH, RANDOM };
+
+    /**
+     * Installs intents based on the installation type.
+     * @param type the installation type.
+     */
+    void setup(InstallType type);
+
+    /**
+     * Uninstalls all existing intents.
+     */
+    void tearDown();
+
+}
diff --git a/apps/demo/src/main/java/org/onlab/onos/demo/DemoInstaller.java b/apps/demo/src/main/java/org/onlab/onos/demo/DemoInstaller.java
new file mode 100644
index 0000000..ca2d6db
--- /dev/null
+++ b/apps/demo/src/main/java/org/onlab/onos/demo/DemoInstaller.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onlab.onos.demo;
+
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+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.onos.core.ApplicationId;
+import org.onlab.onos.core.CoreService;
+import org.onlab.onos.net.Host;
+import org.onlab.onos.net.flow.DefaultTrafficSelector;
+import org.onlab.onos.net.flow.DefaultTrafficTreatment;
+import org.onlab.onos.net.flow.TrafficSelector;
+import org.onlab.onos.net.flow.TrafficTreatment;
+import org.onlab.onos.net.host.HostService;
+import org.onlab.onos.net.intent.HostToHostIntent;
+import org.onlab.onos.net.intent.Intent;
+import org.onlab.onos.net.intent.IntentService;
+import org.slf4j.Logger;
+
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Application to set up demos.
+ */
+@Component(immediate = true)
+@Service
+public class DemoInstaller implements DemoAPI {
+
+    private final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected IntentService intentService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected HostService hostService;
+
+    private ExecutorService worker;
+
+    private ApplicationId appId;
+
+    private final Set<Intent> existingIntents = new HashSet<>();
+
+
+
+    @Activate
+    public void activate() {
+        appId = coreService.registerApplication("org.onlab.onos.demo.installer");
+        worker = Executors.newFixedThreadPool(1,
+                                              new ThreadFactoryBuilder()
+                                                      .setNameFormat("demo-app-worker")
+                                                      .build());
+        log.info("Started with Application ID {}", appId.id());
+    }
+
+    @Deactivate
+    public void deactivate() {
+        worker.shutdownNow();
+        log.info("Stopped");
+    }
+
+    @Override
+    public void setup(InstallType type) {
+        switch (type) {
+            case MESH:
+                log.debug("Installing mesh intents");
+                worker.execute(new MeshInstaller());
+                break;
+            case RANDOM:
+                throw new IllegalArgumentException("Not yet implemented.");
+            default:
+                throw new IllegalArgumentException("What is it you want exactly?");
+        }
+    }
+
+    @Override
+    public void tearDown() {
+        worker.submit(new UnInstaller());
+    }
+
+
+    private class MeshInstaller implements Runnable {
+
+        @Override
+        public void run() {
+            TrafficSelector selector = DefaultTrafficSelector.builder().build();
+            TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
+
+            List<Host> hosts = Lists.newArrayList(hostService.getHosts());
+            while (!hosts.isEmpty()) {
+                Host src = hosts.remove(0);
+                for (Host dst : hosts) {
+                    HostToHostIntent intent = new HostToHostIntent(appId, src.id(), dst.id(),
+                                                                   selector, treatment,
+                                                                   null);
+                    existingIntents.add(intent);
+                    intentService.submit(intent);
+                }
+            }
+        }
+    }
+
+
+    private class UnInstaller implements Runnable {
+        @Override
+        public void run() {
+            for (Intent i : existingIntents) {
+                intentService.withdraw(i);
+            }
+        }
+    }
+}
+
+
diff --git a/apps/demo/src/main/java/org/onlab/onos/demo/DemoResource.java b/apps/demo/src/main/java/org/onlab/onos/demo/DemoResource.java
new file mode 100644
index 0000000..f533072
--- /dev/null
+++ b/apps/demo/src/main/java/org/onlab/onos/demo/DemoResource.java
@@ -0,0 +1,54 @@
+package org.onlab.onos.demo;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onlab.rest.BaseResource;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Rest API for demos.
+ */
+@Path("intents")
+public class DemoResource extends BaseResource {
+
+
+    @POST
+    @Path("setup")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response setup(InputStream input) throws IOException {
+        ObjectMapper mapper = new ObjectMapper();
+        JsonNode cfg = mapper.readTree(input);
+        if (!cfg.has("type")) {
+            return Response.status(Response.Status.BAD_REQUEST)
+                    .entity("Expected type field containing either mesh or random.").build();
+        }
+
+        DemoAPI.InstallType type = DemoAPI.InstallType.valueOf(
+                cfg.get("type").asText().toUpperCase());
+        DemoAPI demo = get(DemoAPI.class);
+        demo.setup(type);
+
+        return Response.ok(mapper.createObjectNode().toString()).build();
+    }
+
+    @GET
+    @Path("teardown")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response tearDown() throws IOException {
+        ObjectMapper mapper = new ObjectMapper();
+        DemoAPI demo = get(DemoAPI.class);
+        demo.tearDown();
+        return Response.ok(mapper.createObjectNode().toString()).build();
+    }
+
+}
diff --git a/apps/demo/src/main/java/org/onlab/onos/demo/package-info.java b/apps/demo/src/main/java/org/onlab/onos/demo/package-info.java
new file mode 100644
index 0000000..b60eb15
--- /dev/null
+++ b/apps/demo/src/main/java/org/onlab/onos/demo/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *  Demo applications live here.
+ */
+package org.onlab.onos.demo;
diff --git a/apps/demo/src/main/webapp/WEB-INF/web.xml b/apps/demo/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..429287e
--- /dev/null
+++ b/apps/demo/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2014 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         id="ONOS" version="2.5">
+    <display-name>ONOS DEMO APP API v1.0</display-name>
+
+    <servlet>
+        <servlet-name>JAX-RS Service</servlet-name>
+        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+        <init-param>
+            <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
+            <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
+        </init-param>
+        <init-param>
+            <param-name>com.sun.jersey.config.property.classnames</param-name>
+            <param-value>
+                org.onlab.onos.demo.DemoResource
+            </param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>JAX-RS Service</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+
+</web-app>
\ No newline at end of file
diff --git a/apps/pom.xml b/apps/pom.xml
index 3084916..c021ca4 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -44,6 +44,7 @@
         <module>optical</module>
         <module>metrics</module>
         <module>oecfg</module>
+        <module>demo</module>
     </modules>
 
     <properties>
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
index 2269aa0..2a4aaeb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
@@ -23,6 +23,7 @@
 import org.onlab.onos.net.flow.TrafficTreatment;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -61,7 +62,7 @@
                                  Collection<NetworkResource> resources,
                                  TrafficSelector selector,
                                  TrafficTreatment treatment) {
-        this(id, appId, resources, selector, treatment, null);
+        this(id, appId, resources, selector, treatment, Collections.emptyList());
     }
 
     /**
@@ -87,7 +88,7 @@
         super(id, appId, resources);
         this.selector = checkNotNull(selector);
         this.treatment = checkNotNull(treatment);
-        this.constraints = constraints;
+        this.constraints = checkNotNull(constraints);
     }
 
     /**
@@ -97,7 +98,7 @@
         super();
         this.selector = null;
         this.treatment = null;
-        this.constraints = null;
+        this.constraints = Collections.emptyList();
     }
 
     /**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
index 893270a..24a3bca 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
@@ -21,6 +21,7 @@
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 
+import java.util.Collections;
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -46,7 +47,7 @@
     public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
                             TrafficSelector selector,
                             TrafficTreatment treatment) {
-        this(appId, one, two, selector, treatment, null);
+        this(appId, one, two, selector, treatment, Collections.emptyList());
     }
 
     /**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
index b4fdcfb..ce1f6b1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
@@ -22,6 +22,7 @@
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -51,7 +52,7 @@
                                 TrafficTreatment treatment,
                                 Set<Link> links,
                                 ConnectPoint egressPoint) {
-        this(appId, selector , treatment, links, egressPoint, null);
+        this(appId, selector , treatment, links, egressPoint, Collections.emptyList());
     }
 
     /**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
index 90907fb..8c8cbb0 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
@@ -22,6 +22,7 @@
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
@@ -55,14 +56,7 @@
                                          TrafficTreatment treatment,
                                          Set<ConnectPoint> ingressPoints,
                                          ConnectPoint egressPoint) {
-        super(id(MultiPointToSinglePointIntent.class, selector, treatment,
-                 ingressPoints, egressPoint), appId, null, selector, treatment);
-
-        checkNotNull(ingressPoints);
-        checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
-
-        this.ingressPoints = Sets.newHashSet(ingressPoints);
-        this.egressPoint = checkNotNull(egressPoint);
+        this(appId, selector, treatment, ingressPoints, egressPoint, Collections.emptyList());
     }
 
     /**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
index 9f8816d..7a0e365 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
@@ -15,6 +15,7 @@
  */
 package org.onlab.onos.net.intent;
 
+import java.util.Collections;
 import java.util.List;
 
 import com.google.common.base.MoreObjects;
@@ -42,9 +43,7 @@
      */
     public PathIntent(ApplicationId appId, TrafficSelector selector,
                       TrafficTreatment treatment, Path path) {
-        super(id(PathIntent.class, selector, treatment, path), appId,
-              resources(path.links()), selector, treatment);
-        this.path = path;
+        this(appId, selector, treatment, path, Collections.emptyList());
     }
 
     /**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/AnnotationConstraint.java b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/AnnotationConstraint.java
index a093be9..1767a41 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/AnnotationConstraint.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/AnnotationConstraint.java
@@ -43,6 +43,12 @@
         this.threshold = threshold;
     }
 
+    // Constructor for serialization
+    private AnnotationConstraint() {
+        this.key = "";
+        this.threshold = 0;
+    }
+
     /**
      * Returns the key of link annotation this constraint designates.
      * @return key of link annotation
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
index 7b1411a..e4b4432 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/LatencyConstraint.java
@@ -43,6 +43,11 @@
         this.latency = latency;
     }
 
+    // Constructor for serialization
+    private LatencyConstraint() {
+        this.latency = Duration.ZERO;
+    }
+
     public Duration latency() {
         return latency;
     }
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/ObstacleConstraint.java b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/ObstacleConstraint.java
index 6d73fc2..8472f3c 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/ObstacleConstraint.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/ObstacleConstraint.java
@@ -21,6 +21,7 @@
 import org.onlab.onos.net.Link;
 import org.onlab.onos.net.resource.LinkResourceService;
 
+import java.util.Collections;
 import java.util.Objects;
 import java.util.Set;
 
@@ -39,6 +40,11 @@
         this.obstacles = ImmutableSet.copyOf(obstacles);
     }
 
+    // Constructor for serialization
+    private ObstacleConstraint() {
+        this.obstacles = Collections.emptySet();
+    }
+
     @Override
     public boolean isValid(Link link, LinkResourceService resourceService) {
         DeviceId src = link.src().deviceId();
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/WaypointConstraint.java b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/WaypointConstraint.java
index 3a132f0..9e3cc20 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/constraint/WaypointConstraint.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/constraint/WaypointConstraint.java
@@ -23,6 +23,7 @@
 import org.onlab.onos.net.intent.Constraint;
 import org.onlab.onos.net.resource.LinkResourceService;
 
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
@@ -48,6 +49,11 @@
         this.waypoints = ImmutableList.copyOf(waypoints);
     }
 
+    // Constructor for serialization
+    private WaypointConstraint() {
+        this.waypoints = Collections.emptyList();
+    }
+
     public List<DeviceId> waypoints() {
         return waypoints;
     }
diff --git a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
index 4cba9f0..5d689a3 100644
--- a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
@@ -75,10 +75,14 @@
 import org.onlab.onos.net.intent.OpticalPathIntent;
 import org.onlab.onos.net.intent.PathIntent;
 import org.onlab.onos.net.intent.PointToPointIntent;
+import org.onlab.onos.net.intent.constraint.AnnotationConstraint;
 import org.onlab.onos.net.intent.constraint.BandwidthConstraint;
 import org.onlab.onos.net.intent.constraint.BooleanConstraint;
 import org.onlab.onos.net.intent.constraint.LambdaConstraint;
+import org.onlab.onos.net.intent.constraint.LatencyConstraint;
 import org.onlab.onos.net.intent.constraint.LinkTypeConstraint;
+import org.onlab.onos.net.intent.constraint.ObstacleConstraint;
+import org.onlab.onos.net.intent.constraint.WaypointConstraint;
 import org.onlab.onos.net.link.DefaultLinkDescription;
 import org.onlab.onos.net.packet.DefaultOutboundPacket;
 import org.onlab.onos.net.provider.ProviderId;
@@ -208,9 +212,14 @@
                     LinkResourceRequest.class,
                     Lambda.class,
                     Bandwidth.class,
+                    // Constraints
                     LambdaConstraint.class,
                     BandwidthConstraint.class,
                     LinkTypeConstraint.class,
+                    LatencyConstraint.class,
+                    WaypointConstraint.class,
+                    ObstacleConstraint.class,
+                    AnnotationConstraint.class,
                     BooleanConstraint.class
                     )
             .register(DefaultApplicationId.class, new DefaultApplicationIdSerializer())
diff --git a/features/features.xml b/features/features.xml
index 551c4de..5ede89c 100644
--- a/features/features.xml
+++ b/features/features.xml
@@ -227,4 +227,12 @@
         <bundle>mvn:org.onlab.onos/onos-app-metrics-topology/1.0.0-SNAPSHOT</bundle>
     </feature>
 
+    <feature name="onos-app-demo" version="1.0.0"
+             description="ONOS demo applications">
+        <feature>onos-api</feature>
+        <bundle>mvn:org.onlab.onos/onos-app-demo/1.0.0-SNAPSHOT</bundle>
+    </feature>
+
+
+
 </features>