Added application ID store; both trivial and distributed variants.
diff --git a/core/api/src/main/java/org/onlab/onos/core/ApplicationId.java b/core/api/src/main/java/org/onlab/onos/core/ApplicationId.java
new file mode 100644
index 0000000..10c0c75
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/core/ApplicationId.java
@@ -0,0 +1,21 @@
+package org.onlab.onos.core;
+
+
+/**
+ * Application identifier.
+ */
+public interface ApplicationId {
+
+ /**
+ * Returns the application id.
+ * @return a short value
+ */
+ short id();
+
+ /**
+ * Returns the applications supplied identifier.
+ * @return a string identifier
+ */
+ String name();
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/core/ApplicationIdStore.java b/core/api/src/main/java/org/onlab/onos/core/ApplicationIdStore.java
new file mode 100644
index 0000000..ccb1414
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/core/ApplicationIdStore.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.core;
+
+import java.util.Set;
+
+/**
+ * Manages application IDs.
+ */
+public interface ApplicationIdStore {
+
+ /**
+ * Returns the set of currently registered application identifiers.
+ *
+ * @return set of application ids
+ */
+ Set<ApplicationId> getAppIds();
+
+ /**
+ * Returns an existing application id from a given id.
+ * @param id the short value of the id
+ * @return an application id
+ */
+ ApplicationId getAppId(Short id);
+
+ /**
+ * Registers a new application by its name, which is expected
+ * to follow the reverse DNS convention, e.g.
+ * {@code org.flying.circus.app}
+ *
+ * @param identifier string identifier
+ * @return the application id
+ */
+ ApplicationId registerApplication(String identifier);
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/core/CoreService.java b/core/api/src/main/java/org/onlab/onos/core/CoreService.java
new file mode 100644
index 0000000..0de33b3
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/core/CoreService.java
@@ -0,0 +1,41 @@
+package org.onlab.onos.core;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the core system of the controller.
+ */
+public interface CoreService {
+
+ /**
+ * Returns the product version.
+ *
+ * @return product version
+ */
+ Version version();
+
+ /**
+ * Returns the set of currently registered application identifiers.
+ *
+ * @return set of application ids
+ */
+ Set<ApplicationId> getAppIds();
+
+ /**
+ * Returns an existing application id from a given id.
+ * @param id the short value of the id
+ * @return an application id
+ */
+ ApplicationId getAppId(Short id);
+
+ /**
+ * Registers a new application by its name, which is expected
+ * to follow the reverse DNS convention, e.g.
+ * {@code org.flying.circus.app}
+ *
+ * @param identifier string identifier
+ * @return the application id
+ */
+ ApplicationId registerApplication(String identifier);
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/core/DefaultApplicationId.java b/core/api/src/main/java/org/onlab/onos/core/DefaultApplicationId.java
new file mode 100644
index 0000000..b5ecccc
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/core/DefaultApplicationId.java
@@ -0,0 +1,64 @@
+package org.onlab.onos.core;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Application identifier.
+ */
+public class DefaultApplicationId implements ApplicationId {
+
+ private final short id;
+ private final String name;
+
+ /**
+ * Creates a new application ID.
+ *
+ * @param id application identifier
+ * @param name application name
+ */
+ public DefaultApplicationId(Short id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ // Constructor for serializers.
+ private DefaultApplicationId() {
+ this.id = 0;
+ this.name = null;
+ }
+
+ @Override
+ public short id() {
+ return id;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultApplicationId) {
+ DefaultApplicationId other = (DefaultApplicationId) obj;
+ return Objects.equals(this.id, other.id);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("name", name).toString();
+ }
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/core/Version.java b/core/api/src/main/java/org/onlab/onos/core/Version.java
new file mode 100644
index 0000000..72fd509
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/core/Version.java
@@ -0,0 +1,113 @@
+package org.onlab.onos.core;
+
+import java.util.Objects;
+
+import static java.lang.Integer.parseInt;
+
+/**
+ * Representation of the product version.
+ */
+public final class Version {
+
+ public static final String FORMAT = "%d.%d.%d.%s";
+
+ private final int major;
+ private final int minor;
+ private final int patch;
+ private final String build;
+
+ private final String format;
+
+ // Creates a new version descriptor
+ private Version(int major, int minor, int patch, String build) {
+ this.major = major;
+ this.minor = minor;
+ this.patch = patch;
+ this.build = build;
+ this.format = String.format(FORMAT, major, minor, patch, build);
+ }
+
+
+ /**
+ * Creates a new version from the specified constituent numbers.
+ *
+ * @param major major version number
+ * @param minor minod version number
+ * @param patch version patch number
+ * @param build build string
+ * @return version descriptor
+ */
+ public static Version version(int major, int minor, int patch, String build) {
+ return new Version(major, minor, patch, build);
+ }
+
+ /**
+ * Creates a new version by parsing the specified string.
+ *
+ * @param string version string
+ * @return version descriptor
+ */
+ public static Version version(String string) {
+ String[] fields = string.split("[.-]");
+ return new Version(parseInt(fields[0]), parseInt(fields[1]),
+ parseInt(fields[2]), fields[3]);
+ }
+
+ /**
+ * Returns the major version number.
+ *
+ * @return major version number
+ */
+ public int major() {
+ return major;
+ }
+
+ /**
+ * Returns the minor version number.
+ *
+ * @return minor version number
+ */
+ public int minor() {
+ return minor;
+ }
+
+ /**
+ * Returns the version patch number.
+ *
+ * @return patch number
+ */
+ public int patch() {
+ return patch;
+ }
+
+ /**
+ * Returns the version build string.
+ *
+ * @return build string
+ */
+ public String build() {
+ return build;
+ }
+
+ @Override
+ public String toString() {
+ return format;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(format);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Version) {
+ final Version other = (Version) obj;
+ return Objects.equals(this.format, other.format);
+ }
+ return false;
+ }
+}
diff --git a/core/api/src/main/java/org/onlab/onos/core/package-info.java b/core/api/src/main/java/org/onlab/onos/core/package-info.java
new file mode 100644
index 0000000..fb97734
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/core/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * ONOS Core API definitions.
+ */
+package org.onlab.onos.core;