Creating a registry for gRPC services, early version restarts on each modification of the set of services.
Change-Id: Icf1c0cabef2d718cf3728c90cdf30855d54e65df
diff --git a/incubator/api/BUCK b/incubator/api/BUCK
index eb7b036..c606814 100644
--- a/incubator/api/BUCK
+++ b/incubator/api/BUCK
@@ -1,6 +1,7 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//lib:JACKSON',
+ '//lib:grpc-core'
]
TEST_DEPS = [
diff --git a/incubator/api/pom.xml b/incubator/api/pom.xml
index fe86161..391ad3a 100644
--- a/incubator/api/pom.xml
+++ b/incubator/api/pom.xml
@@ -43,6 +43,11 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-core</artifactId>
+ <version>1.2.0</version>
+ </dependency>
</dependencies>
</project>
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/grpc/GrpcServiceRegistry.java b/incubator/api/src/main/java/org/onosproject/incubator/grpc/GrpcServiceRegistry.java
new file mode 100644
index 0000000..0e33f2f
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/grpc/GrpcServiceRegistry.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.onosproject.incubator.grpc;
+
+import io.grpc.BindableService;
+
+/**
+ * A service that allows for de/registration of gRPC services, and determining
+ * whether a service is present.
+ */
+public interface GrpcServiceRegistry {
+ /**
+ * Register a gRPC service with this registry.
+ * @param service the service to be registered
+ * @return true if the service was added and server successfully started,
+ * false otherwise
+ */
+ boolean register(BindableService service);
+
+ /**
+ * Unregister a gRPC service with this registry.
+ * @param service the service to be unregistered
+ * @return true if the service was removed and the server successfully
+ * started, false otherwise
+ */
+ boolean unregister(BindableService service);
+
+ /**
+ * Checks if an instance of the provided serviceClass is currently
+ * registered with this registry.
+ * @param serviceClass the class being queries
+ * @return true if an instance of this specified class has been registered,
+ * false otherwise
+ */
+ boolean containsService(Class<BindableService> serviceClass);
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/grpc/package-info.java b/incubator/api/src/main/java/org/onosproject/incubator/grpc/package-info.java
new file mode 100644
index 0000000..eac386d
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/grpc/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * Abstractions for interacting with the gRPC subsystem.
+ */
+package org.onosproject.incubator.grpc;