Introduce RESTCONF Client API 62/4062/5
authorTony Tkacik <ttkacik@cisco.com>
Wed, 8 Jan 2014 10:07:34 +0000 (11:07 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 10 Jan 2014 15:46:18 +0000 (16:46 +0100)
Change-Id: Ibc90532eea3f200acf726a7f8eabae4ac6877aa5
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
18 files changed:
pom.xml
restconf/pom.xml
restconf/restconf-client-api/pom.xml [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/RestconfClientContext.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/RestconfClientContextFactory.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/UnsupportedProtocolException.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/ConfigurationDatastore.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/Datastore.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/DefaultRetrievalStrategy.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/LimitedDepthRetrievalStrategy.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/OperationalDatastore.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/RetrievalStrategy.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventReplay.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamContext.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamInfo.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamReplay.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/ListenableEventStreamContext.java [new file with mode: 0644]
restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/rpc/RpcServiceContext.java [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index cff8f35b196b1ad776622589a87ba957b7175073..4aebc8d74600fa844704cde21b1fb8c37774b3e7 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
         <module>yang</module>\r
         <module>code-generator</module>\r
         <module>model</module>\r
+        <module>restconf</module>\r
         <!-- module>third-party</module -->\r
     </modules>\r
 \r
index 141a24020d815df8648652f864fbc02b38de4a2c..e0ea6e9d79a4a4f0f3919f62202fd7238db72aa4 100644 (file)
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yangtools</artifactId>
-        <version>0.5-SNAPSHOT</version>
+        <version>0.1.1-SNAPSHOT</version>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>
@@ -12,9 +12,7 @@
     <packaging>pom</packaging>
 
     <modules>
-        <module>restconf-common</module>
-        <module>restconf-jaxrs-api</module>
-        <module>restconf-util</module>
+        <module>restconf-client-api</module>
     </modules>
 
     <dependencyManagement>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-common</artifactId>
-                <version>${project.version}</version>
+                <version>0.5.9-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-data-api</artifactId>
-                <version>${project.version}</version>
+                <version>0.5.9-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-data-util</artifactId>
-                <version>${project.version}</version>
+                <artifactId>yang-data-impl</artifactId>
+                <version>0.5.9-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-model-api</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-model-util</artifactId>
-                <version>${project.version}</version>
-            </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-binding</artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-parser-api</artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-parser-impl
-                </artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-maven-plugin</artifactId>
-                <version>${project.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-maven-plugin-spi</artifactId>
-                <version>${project.version}</version>
+                <version>0.6.0-SNAPSHOT</version>
             </dependency>
         </dependencies>
     </dependencyManagement>
                     <target>1.7</target>
                 </configuration>
             </plugin>
+            <plugin>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>maven-bundle-plugin</artifactId>
+                </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.9.1</version>
                 <configuration>
                     <stylesheet>maven</stylesheet>
                 </configuration>
                     <artifactId>maven-bundle-plugin</artifactId>
                     <version>${maven.bundle.version}</version>
                     <extensions>true</extensions>
-                    <executions>
-                        <execution>
-                            <id>bundle-manifest</id>
-                            <phase>process-classes</phase>
-                            <goals>
-                                <goal>manifest</goal>
-                            </goals>
-                        </execution>
-                    </executions>
                 </plugin>
                 <plugin>
                     <groupId>org.eclipse.m2e</groupId>
         </plugins>
     </reporting>
 
-    <version>0.1.0-SNAPSHOT</version>
+    <version>0.2.0-SNAPSHOT</version>
 </project>
 
diff --git a/restconf/restconf-client-api/pom.xml b/restconf/restconf-client-api/pom.xml
new file mode 100644 (file)
index 0000000..09b72eb
--- /dev/null
@@ -0,0 +1,18 @@
+<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.opendaylight.yangtools</groupId>
+    <artifactId>restconf-parent</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>restconf-client-api</artifactId>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/RestconfClientContext.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/RestconfClientContext.java
new file mode 100644 (file)
index 0000000..6c7c52c
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api;
+
+import java.util.Set;
+
+import org.opendaylight.yangtools.restconf.client.api.data.ConfigurationDatastore;
+import org.opendaylight.yangtools.restconf.client.api.data.OperationalDatastore;
+import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
+import org.opendaylight.yangtools.restconf.client.api.event.ListenableEventStreamContext;
+import org.opendaylight.yangtools.restconf.client.api.rpc.RpcServiceContext;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public interface RestconfClientContext extends AutoCloseable {
+       /**
+        * Returns a set of {@link RpcServiceContext} which provides invocation
+        * handling for RPCs supported by the backing server.
+        * 
+        * @return Future representing the asynchronous call to fetch the information.
+        */
+       ListenableFuture<Set<Class<? extends RpcService>>> getRpcServices();
+       <T extends RpcService> RpcServiceContext<T> getRpcServiceContext(Class<T> rpcService);
+
+       ListenableFuture<Set<EventStreamInfo>> getAvailableEventStreams();
+       ListenableEventStreamContext getEventStreamContext(EventStreamInfo info);
+
+       ConfigurationDatastore getConfigurationDatastore();
+       OperationalDatastore getOperationalDatastore();
+
+       @Override
+       void close();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/RestconfClientContextFactory.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/RestconfClientContextFactory.java
new file mode 100644 (file)
index 0000000..a3ab105
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api;
+
+import java.net.URL;
+
+/**
+ * An interface for acquiring #{@link RestconfClientContext} instances.
+ */
+public interface RestconfClientContextFactory {
+       /**
+        * Get a #{@link RestconfClientContext} attached to the server pointed to by an URL.
+        * @param baseUrl URL pointer to the backend server
+        * @return RestconfClientContext attached to the backend server.
+        * @throws UnsupportedProtocolException if the factory cannot handle the protocol specified in the URL.
+        */
+       RestconfClientContext getRestconfClientContext(URL baseUrl) throws UnsupportedProtocolException;
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/UnsupportedProtocolException.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/UnsupportedProtocolException.java
new file mode 100644 (file)
index 0000000..383fc72
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api;
+
+public class UnsupportedProtocolException extends Exception {
+       private static final long serialVersionUID = 1L;
+
+       public UnsupportedProtocolException(final String message, final Throwable cause) {
+               super(message, cause);
+       }
+
+       public UnsupportedProtocolException(final String message) {
+               super(message);
+       }
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/ConfigurationDatastore.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/ConfigurationDatastore.java
new file mode 100644 (file)
index 0000000..e87c240
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.data;
+
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public interface ConfigurationDatastore extends Datastore {
+    ListenableFuture<RpcResult<Boolean>> deleteData(InstanceIdentifier<?> path);
+    ListenableFuture<RpcResult<Boolean>> putData(InstanceIdentifier<?> path);
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/Datastore.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/Datastore.java
new file mode 100644 (file)
index 0000000..7041a29
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.data;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public interface Datastore {
+
+    /**
+     * Reads data from data store and return's result in future.
+     * 
+     * This call is equivalent to invocation of {@link #readData(InstanceIdentifier, RetrievalStrategy)}
+     * with {@link DefaultRetrievalStrategy.Default}.
+     * 
+     * @param path InstanceIdentifier representing path in YANG schema to be retrieved.
+     * @return Future promising the data requested. If the requested data are not present returns value of {@link Optional#absent()}.
+     * 
+     */
+    <T extends DataObject> ListenableFuture<Optional<T>> readData(InstanceIdentifier<T> path);
+    
+    /**
+     * Reads data from data store and return's result in future.
+     * 
+     * @param path Representing path in YANG schema to be retrieved.
+     * @param strategy Strategy which should be used to retrieve data
+     * @return Future promising the data requested. If the requested data are not present returns value of {@link Optional#absent()}.
+     * 
+     */
+    <T extends DataObject> ListenableFuture<Optional<T>> readData(InstanceIdentifier<T> path, RetrievalStrategy strategy);
+
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/DefaultRetrievalStrategy.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/DefaultRetrievalStrategy.java
new file mode 100644 (file)
index 0000000..4858a3c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.data;
+
+/**
+ * Default retrieval strategy, letting the server decide what to do exactly.
+ */
+public final class DefaultRetrievalStrategy implements RetrievalStrategy {
+       private static final class Holder {
+               private static final DefaultRetrievalStrategy INSTANCE = new DefaultRetrievalStrategy();
+       }
+
+       private DefaultRetrievalStrategy() {
+
+       }
+
+       public static DefaultRetrievalStrategy getInstance() {
+               return Holder.INSTANCE;
+       }
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/LimitedDepthRetrievalStrategy.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/LimitedDepthRetrievalStrategy.java
new file mode 100644 (file)
index 0000000..21254f2
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.data;
+
+/**
+ * A retrieval strategy which places an upper bound on the depth of the tree
+ * returned by the query.
+ */
+public interface LimitedDepthRetrievalStrategy extends RetrievalStrategy {
+       /**
+        * @return maximum three depth
+        */
+    int getDepthLimit();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/OperationalDatastore.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/OperationalDatastore.java
new file mode 100644 (file)
index 0000000..67c60d1
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.data;
+
+public interface OperationalDatastore extends Datastore {
+
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/RetrievalStrategy.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/data/RetrievalStrategy.java
new file mode 100644 (file)
index 0000000..97b730d
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.data;
+
+/**
+ * Marker interface common to all data retrieval strategies. A retrieval strategy specifies
+ * details how the result of a read operation are to be retrieved from the server.
+ */
+public interface RetrievalStrategy {
+
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventReplay.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventReplay.java
new file mode 100644 (file)
index 0000000..e3a98e9
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.event;
+
+import java.util.Date;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface EventReplay<T extends Notification> {
+    Date getEventTime();
+    Class<T> getEventType();
+    T getEvent();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamContext.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamContext.java
new file mode 100644 (file)
index 0000000..8e7ec31
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.event;
+
+import java.util.Date;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public interface EventStreamContext extends AutoCloseable {
+       ListenableFuture<Optional<EventStreamReplay>> getReplay(Optional<Date> startTime, Optional<Date> endTime);
+
+       @Override
+       void close();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamInfo.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamInfo.java
new file mode 100644 (file)
index 0000000..fe1464b
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.event;
+
+import java.util.Date;
+
+import org.opendaylight.yangtools.concepts.Identifiable;
+
+public interface EventStreamInfo extends Identifiable<String> {
+
+    /**
+     * 
+     * @return name of event stream.
+     */
+    @Override
+    public String getIdentifier();
+
+    public String getDescription();
+
+    boolean isReplaySupported();
+
+    Date getReplayLogCreationTime();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamReplay.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/EventStreamReplay.java
new file mode 100644 (file)
index 0000000..8ae6538
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.event;
+
+import java.util.Date;
+
+import com.google.common.base.Optional;
+
+public interface EventStreamReplay extends Iterable<EventReplay<?>> {
+    String getStreamIdentifier();
+    Optional<Date> getStartTime();
+    Optional<Date> getEndTime();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/ListenableEventStreamContext.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/event/ListenableEventStreamContext.java
new file mode 100644 (file)
index 0000000..bc2b5a7
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.event;
+
+import java.util.Date;
+
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * An #{@link EventStreamContext} which supports dispatching events to one or more listeners.
+ */
+public interface ListenableEventStreamContext extends EventStreamContext {
+       /**
+        * Register a new listener to which events will be delivered until the returned registration is not closed.
+        * 
+        * @param listener New listener
+        * @return Listener registration handle
+        */
+       <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(T listener);
+
+       /**
+        * Subscribe to the underlying event stream. Equivalent to {@link #startListeningWithReplay(Optional, Optional)} with
+        * both arguments being Optional.absent().
+        * 
+        * @return Future representing the asynchronous request for subscription.
+        * @throws IllegalStateException if the event stream is currently being listened on
+        */
+       ListenableFuture<RpcResult<Void>> startListening();
+
+       /**
+        * Subscribe to the underlying event stream and attempt to replay events between startTime.
+        * 
+        * @param startTime Start time. If present, required to be in the past. Omitting this parameter results
+        *                  in the server going as far as possible.
+        * @param endTime End time. If present, required to be later than start time.
+        * @return Future representing the asynchronous request for subscription.
+        * @throws IllegalStateException if the event stream is currently being listened on
+        */
+       ListenableFuture<RpcResult<Void>> startListeningWithReplay(Optional<Date> startTime, Optional<Date> endTime);
+
+       /**
+        * Stop listening to the underlying event stream.
+        * @throws IllegalStateException if the event stream is currently not being listened on
+        */
+       void stopListening();
+}
diff --git a/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/rpc/RpcServiceContext.java b/restconf/restconf-client-api/src/main/java/org/opendaylight/yangtools/restconf/client/api/rpc/RpcServiceContext.java
new file mode 100644 (file)
index 0000000..63d5a0c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.restconf.client.api.rpc;
+
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public interface RpcServiceContext<T extends RpcService> extends AutoCloseable {
+       T getRpcService();
+
+       @Override
+       void close();
+}