Split CPMan into api and app submodules

Change-Id: Iacddea67ea0f7189ab918cf9e2a7a414100fc503
diff --git a/apps/cpman/api/pom.xml b/apps/cpman/api/pom.xml
new file mode 100644
index 0000000..09c946a
--- /dev/null
+++ b/apps/cpman/api/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016 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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>onos-cpman</artifactId>
+        <groupId>org.onosproject</groupId>
+        <version>1.5.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-app-cpman-api</artifactId>
+    <packaging>bundle</packaging>
+
+    <url>http://onosproject.org</url>
+
+    <description>Control Plane Management Application API</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-core-serializers</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlLoad.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlLoad.java
similarity index 100%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlLoad.java
rename to apps/cpman/api/src/main/java/org/onosproject/cpman/ControlLoad.java
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetric.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMetric.java
similarity index 100%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlMetric.java
rename to apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMetric.java
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricType.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMetricType.java
similarity index 100%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricType.java
rename to apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMetricType.java
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneMonitorService.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlPlaneMonitorService.java
similarity index 100%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneMonitorService.java
rename to apps/cpman/api/src/main/java/org/onosproject/cpman/ControlPlaneMonitorService.java
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/package-info.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlPlaneService.java
similarity index 82%
copy from apps/cpman/src/main/java/org/onosproject/cpman/package-info.java
copy to apps/cpman/api/src/main/java/org/onosproject/cpman/ControlPlaneService.java
index e2c1dc8..663c2b7 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/package-info.java
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlPlaneService.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2016 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.
@@ -13,8 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.onosproject.cpman;
 
 /**
- * Application for control plane management.
+ * Control Plane Service interface.
  */
-package org.onosproject.cpman;
\ No newline at end of file
+public interface ControlPlaneService {
+}
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/MetricValue.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/MetricValue.java
similarity index 96%
rename from apps/cpman/src/main/java/org/onosproject/cpman/MetricValue.java
rename to apps/cpman/api/src/main/java/org/onosproject/cpman/MetricValue.java
index e0f7342..c853ef1 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/MetricValue.java
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/MetricValue.java
@@ -15,7 +15,7 @@
  */
 package org.onosproject.cpman;
 
-import static com.google.common.base.MoreObjects.toStringHelper;
+import com.google.common.base.MoreObjects;
 
 /**
  * Primitive Metric Value.
@@ -145,7 +145,7 @@
 
     @Override
     public String toString() {
-        return toStringHelper(getClass())
+        return MoreObjects.toStringHelper(getClass())
                 .add("rate", Long.toHexString(rate))
                 .add("load", Long.toHexString(load))
                 .add("count", Long.toHexString(count)).toString();
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/package-info.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/package-info.java
similarity index 86%
copy from apps/cpman/src/main/java/org/onosproject/cpman/package-info.java
copy to apps/cpman/api/src/main/java/org/onosproject/cpman/package-info.java
index e2c1dc8..6ea6835 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/package-info.java
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2016 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.
@@ -15,6 +15,6 @@
  */
 
 /**
- * Application for control plane management.
+ * An application that manages the control plane.
  */
 package org.onosproject.cpman;
\ No newline at end of file
diff --git a/apps/cpman/app/app.xml b/apps/cpman/app/app.xml
new file mode 100644
index 0000000..ea82db9
--- /dev/null
+++ b/apps/cpman/app/app.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016 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.
+  -->
+<app name="org.onosproject.cpman" origin="ON.Lab" version="${project.version}"
+     category="default" url="http://onosproject.org"
+     featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
+     features="${project.artifactId}">
+    <description>${project.description}</description>
+    <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
+    <artifact>mvn:${project.groupId}/onos-app-cpman-api/${project.version}</artifact>
+</app>
diff --git a/apps/cpman/app/features.xml b/apps/cpman/app/features.xml
new file mode 100644
index 0000000..81a25cd
--- /dev/null
+++ b/apps/cpman/app/features.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  ~ Copyright 2016 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.
+  -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+    <feature name="${project.artifactId}" version="${project.version}"
+             description="${project.description}">
+        <feature>onos-api</feature>
+        <bundle>mvn:${project.groupId}/onos-app-cpman-api/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/onos-app-cpman/${project.version}</bundle>
+    </feature>
+</features>
diff --git a/apps/cpman/app/pom.xml b/apps/cpman/app/pom.xml
new file mode 100644
index 0000000..b7c76ae
--- /dev/null
+++ b/apps/cpman/app/pom.xml
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2015-2016 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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-cpman</artifactId>
+        <version>1.5.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-app-cpman</artifactId>
+    <packaging>bundle</packaging>
+
+    <url>http://onosproject.org</url>
+
+    <description>Control Plane Management Application</description>
+
+    <properties>
+        <web.context>/onos/cpman</web.context>
+        <api.version>1.0.0</api.version>
+        <api.title>Control Plane Manager REST API</api.title>
+        <api.description>
+            APIs for interacting with the Control Plane Management application.
+        </api.description>
+        <api.package>org.onosproject.cpman.rest</api.package>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-app-cpman-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-core-serializers</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-rest</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-rest</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-servlet</artifactId>
+        </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>com.sun.jersey</groupId>
+            <artifactId>jersey-client</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-grizzly2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </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>
+                        <Include-Resource>
+                            WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
+                            {maven-resources}
+                        </Include-Resource>
+                        <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.fasterxml.jackson.core,
+                            org.apache.karaf.shell.commands,
+                            org.apache.karaf.shell.console,
+                            com.google.common.*,
+                            org.onlab.packet.*,
+                            org.onlab.rest.*,
+                            org.onosproject.*,
+                            org.onlab.util.*,
+                            org.jboss.netty.util.*
+                        </Import-Package>
+                        <Web-ContextPath>${web.context}</Web-ContextPath>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsFactory.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java
similarity index 98%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsFactory.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java
index 8a48d15..3becf63 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsFactory.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsFactory.java
@@ -13,12 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import org.onlab.metrics.MetricsService;
+import org.onosproject.cpman.ControlMetricType;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.device.DeviceService;
 
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsObserver.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java
similarity index 97%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsObserver.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java
index 4cbe4a1..fb0bf8b 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsObserver.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsObserver.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 import org.onosproject.net.DeviceId;
 
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsSystemSpec.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsSystemSpec.java
similarity index 98%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsSystemSpec.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsSystemSpec.java
index bc2c214..a80f43c 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/ControlMetricsSystemSpec.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMetricsSystemSpec.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 /**
  * Control metrics class for storing system specification.
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneManager.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneManager.java
similarity index 90%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneManager.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneManager.java
index 941cc0f..ef11466 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneManager.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneManager.java
@@ -13,12 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 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.Modified;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.onosproject.core.ApplicationId;
@@ -28,7 +27,7 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * Skeletal ONOS application component.
+ * Skeletal control plane management component.
  */
 @Component(immediate = true)
 public class ControlPlaneManager {
@@ -55,8 +54,4 @@
         log.info("Stopped");
     }
 
-    @Modified
-    protected void modified() {
-    }
-
-}
+}
\ No newline at end of file
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneMonitor.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java
similarity index 89%
rename from apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneMonitor.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java
index e69a915..e1cbdad 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/ControlPlaneMonitor.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlPlaneMonitor.java
@@ -13,16 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 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.Modified;
 import org.apache.felix.scr.annotations.Service;
 import org.onosproject.cluster.NodeId;
+import org.onosproject.cpman.ControlLoad;
+import org.onosproject.cpman.ControlMetric;
+import org.onosproject.cpman.ControlMetricType;
+import org.onosproject.cpman.ControlPlaneMonitorService;
 import org.onosproject.net.DeviceId;
-import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 
 import java.util.Optional;
@@ -48,10 +50,6 @@
     public void deactivate() {
     }
 
-    @Modified
-    public void modified(ComponentContext context) {
-    }
-
     @Override
     public void updateMetric(ControlMetric cpm, Integer updateInterval,
                              Optional<DeviceId> deviceId) {
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/DefaultControlMetricsObserver.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlMetricsObserver.java
similarity index 91%
rename from apps/cpman/src/main/java/org/onosproject/cpman/DefaultControlMetricsObserver.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlMetricsObserver.java
index 145ea9f..9af5ded 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/DefaultControlMetricsObserver.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/DefaultControlMetricsObserver.java
@@ -13,10 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.cpman.ControlMetric;
+import org.onosproject.cpman.ControlPlaneMonitorService;
+import org.onosproject.cpman.MetricValue;
 import org.onosproject.net.DeviceId;
 
 import java.util.Optional;
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/MetricsAggregator.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java
similarity index 97%
rename from apps/cpman/src/main/java/org/onosproject/cpman/MetricsAggregator.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java
index 3058402..8426cb7 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/MetricsAggregator.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/MetricsAggregator.java
@@ -13,13 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 import com.codahale.metrics.Meter;
 import org.apache.commons.lang3.StringUtils;
 import org.onlab.metrics.MetricsComponent;
 import org.onlab.metrics.MetricsFeature;
 import org.onlab.metrics.MetricsService;
+import org.onosproject.cpman.ControlMetricType;
 import org.onosproject.net.DeviceId;
 
 import java.util.Optional;
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/package-info.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/package-info.java
similarity index 87%
rename from apps/cpman/src/main/java/org/onosproject/cpman/package-info.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/impl/package-info.java
index e2c1dc8..c71d13f 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/package-info.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * Application for control plane management.
+ * Implementation for control plane management.
  */
-package org.onosproject.cpman;
\ No newline at end of file
+package org.onosproject.cpman.impl;
\ No newline at end of file
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/rest/CPManWebApplication.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/CPManWebApplication.java
similarity index 100%
rename from apps/cpman/src/main/java/org/onosproject/cpman/rest/CPManWebApplication.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/rest/CPManWebApplication.java
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
similarity index 99%
rename from apps/cpman/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
index 444d3dc..494b99f 100644
--- a/apps/cpman/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/ControlMetricsCollectorWebResource.java
@@ -19,7 +19,7 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onosproject.cpman.ControlMetric;
 import org.onosproject.cpman.ControlMetricType;
-import org.onosproject.cpman.ControlMetricsSystemSpec;
+import org.onosproject.cpman.impl.ControlMetricsSystemSpec;
 import org.onosproject.cpman.ControlPlaneMonitorService;
 import org.onosproject.cpman.MetricValue;
 import org.onosproject.rest.AbstractWebResource;
diff --git a/apps/cpman/src/main/java/org/onosproject/cpman/rest/package-info.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/rest/package-info.java
similarity index 100%
rename from apps/cpman/src/main/java/org/onosproject/cpman/rest/package-info.java
rename to apps/cpman/app/src/main/java/org/onosproject/cpman/rest/package-info.java
diff --git a/apps/cpman/src/main/resources/definitions/CpuMetricsPost.json b/apps/cpman/app/src/main/resources/definitions/CpuMetricsPost.json
similarity index 100%
rename from apps/cpman/src/main/resources/definitions/CpuMetricsPost.json
rename to apps/cpman/app/src/main/resources/definitions/CpuMetricsPost.json
diff --git a/apps/cpman/src/main/resources/definitions/DiskMetricsPost.json b/apps/cpman/app/src/main/resources/definitions/DiskMetricsPost.json
similarity index 100%
rename from apps/cpman/src/main/resources/definitions/DiskMetricsPost.json
rename to apps/cpman/app/src/main/resources/definitions/DiskMetricsPost.json
diff --git a/apps/cpman/src/main/resources/definitions/MemoryMetricsPost.json b/apps/cpman/app/src/main/resources/definitions/MemoryMetricsPost.json
similarity index 100%
rename from apps/cpman/src/main/resources/definitions/MemoryMetricsPost.json
rename to apps/cpman/app/src/main/resources/definitions/MemoryMetricsPost.json
diff --git a/apps/cpman/src/main/resources/definitions/NetworkMetricsPost.json b/apps/cpman/app/src/main/resources/definitions/NetworkMetricsPost.json
similarity index 100%
rename from apps/cpman/src/main/resources/definitions/NetworkMetricsPost.json
rename to apps/cpman/app/src/main/resources/definitions/NetworkMetricsPost.json
diff --git a/apps/cpman/src/main/resources/definitions/SystemSpecsPost.json b/apps/cpman/app/src/main/resources/definitions/SystemSpecsPost.json
similarity index 100%
rename from apps/cpman/src/main/resources/definitions/SystemSpecsPost.json
rename to apps/cpman/app/src/main/resources/definitions/SystemSpecsPost.json
diff --git a/apps/cpman/src/main/webapp/WEB-INF/web.xml b/apps/cpman/app/src/main/webapp/WEB-INF/web.xml
similarity index 100%
rename from apps/cpman/src/main/webapp/WEB-INF/web.xml
rename to apps/cpman/app/src/main/webapp/WEB-INF/web.xml
diff --git a/apps/cpman/src/test/java/org/onosproject/cpman/ControlPlaneManagerTest.java b/apps/cpman/app/src/test/java/org/onosproject/cpman/impl/ControlPlaneManagerTest.java
similarity index 95%
rename from apps/cpman/src/test/java/org/onosproject/cpman/ControlPlaneManagerTest.java
rename to apps/cpman/app/src/test/java/org/onosproject/cpman/impl/ControlPlaneManagerTest.java
index c7102a5..3fc6675 100644
--- a/apps/cpman/src/test/java/org/onosproject/cpman/ControlPlaneManagerTest.java
+++ b/apps/cpman/app/src/test/java/org/onosproject/cpman/impl/ControlPlaneManagerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2016 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.
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cpman;
+package org.onosproject.cpman.impl;
 
 import org.junit.After;
 import org.junit.Before;
@@ -64,4 +64,4 @@
     @Test
     public void testMetricsCollection() throws Exception {
     }
-}
+}
\ No newline at end of file
diff --git a/apps/cpman/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java b/apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java
similarity index 100%
rename from apps/cpman/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java
rename to apps/cpman/app/src/test/java/org/onosproject/cpman/rest/ControlMetricsCollectorResourceTest.java
diff --git a/apps/cpman/src/test/resources/org/onosproject/cpman/rest/cpu-metrics-post.json b/apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/cpu-metrics-post.json
similarity index 100%
rename from apps/cpman/src/test/resources/org/onosproject/cpman/rest/cpu-metrics-post.json
rename to apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/cpu-metrics-post.json
diff --git a/apps/cpman/src/test/resources/org/onosproject/cpman/rest/disk-metrics-post.json b/apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/disk-metrics-post.json
similarity index 100%
rename from apps/cpman/src/test/resources/org/onosproject/cpman/rest/disk-metrics-post.json
rename to apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/disk-metrics-post.json
diff --git a/apps/cpman/src/test/resources/org/onosproject/cpman/rest/memory-metrics-post.json b/apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/memory-metrics-post.json
similarity index 100%
rename from apps/cpman/src/test/resources/org/onosproject/cpman/rest/memory-metrics-post.json
rename to apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/memory-metrics-post.json
diff --git a/apps/cpman/src/test/resources/org/onosproject/cpman/rest/network-metrics-post.json b/apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/network-metrics-post.json
similarity index 100%
rename from apps/cpman/src/test/resources/org/onosproject/cpman/rest/network-metrics-post.json
rename to apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/network-metrics-post.json
diff --git a/apps/cpman/src/test/resources/org/onosproject/cpman/rest/system-spec-post.json b/apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/system-spec-post.json
similarity index 100%
rename from apps/cpman/src/test/resources/org/onosproject/cpman/rest/system-spec-post.json
rename to apps/cpman/app/src/test/resources/org/onosproject/cpman/rest/system-spec-post.json
diff --git a/apps/cpman/pom.xml b/apps/cpman/pom.xml
index 4b6a4ce..19f7a7c 100644
--- a/apps/cpman/pom.xml
+++ b/apps/cpman/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~ Copyright 2015-2016 Open Networking Laboratory
+  ~ Copyright 2016 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.
@@ -16,8 +16,9 @@
   -->
 <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/xsd/maven-4.0.0.xsd">
+         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.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
@@ -25,169 +26,14 @@
         <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>onos-app-cpman</artifactId>
-    <packaging>bundle</packaging>
+    <artifactId>onos-cpman</artifactId>
+    <packaging>pom</packaging>
 
-    <url>http://onosproject.org</url>
+    <description>ONOS CPMan applications</description>
 
-    <description>Control Plane Management Application</description>
+    <modules>
+        <module>api</module>
+        <module>app</module>
+    </modules>
 
-    <properties>
-        <onos.app.name>org.onosproject.cpman</onos.app.name>
-        <onos.app.category>default</onos.app.category>
-        <onos.app.url>http://onosproject.org</onos.app.url>
-        <onos.app.readme>Control plane management application.</onos.app.readme>
-        <web.context>/onos/cpman</web.context>
-        <api.version>1.0.0</api.version>
-        <api.title>Control Plane Manager REST API</api.title>
-        <api.description>
-            APIs for interacting with the Control Plane Management application.
-        </api.description>
-        <api.package>org.onosproject.cpman.rest</api.package>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-cli</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-core-serializers</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onlab-junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-rest</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onlab-rest</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-api</artifactId>
-            <version>${project.version}</version>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onlab-misc</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>javax.ws.rs</groupId>
-            <artifactId>jsr311-api</artifactId>
-            <version>1.1.1</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-servlet</artifactId>
-        </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>com.sun.jersey</groupId>
-            <artifactId>jersey-client</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey.jersey-test-framework</groupId>
-            <artifactId>jersey-test-framework-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey.jersey-test-framework</groupId>
-            <artifactId>jersey-test-framework-grizzly2</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onlab-osgi</artifactId>
-            <version>${project.version}</version>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </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>
-                        <Include-Resource>
-                            WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
-                            {maven-resources}
-                        </Include-Resource>
-                        <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.fasterxml.jackson.core,
-                            org.apache.karaf.shell.commands,
-                            org.apache.karaf.shell.console,
-                            com.google.common.*,
-                            org.onlab.packet.*,
-                            org.onlab.rest.*,
-                            org.onosproject.*,
-                            org.onlab.util.*,
-                            org.jboss.netty.util.*
-                        </Import-Package>
-                        <Web-ContextPath>${web.context}</Web-ContextPath>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>
\ No newline at end of file
+</project>