Updated SAL Binding APIs 12/1512/3
authorTony Tkacik <ttkacik@cisco.com>
Mon, 30 Sep 2013 13:33:31 +0000 (15:33 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 1 Oct 2013 13:28:46 +0000 (13:28 +0000)
  Data Services
    - Added DataModification contract which is used to track
      reads and writes regarding configuration change.

    - Updated Transaction APIs to use nwe DataModification object
    - Deprecated old APIs for Data Modification which supported
      only one unsubmitted transaction per consumer / provider

  Rpc Services
    - Added Registration for Routed Rpcs
    - Added Registration for Mounted Rpcs

  Util classes
    - Updated implementation of AbstractBindingAwareConsumer
    - Updated implementation of AbstractBindingAwareProvider

Change-Id: I0adb98ae6faf6d214484e4b276d6c3df930ca4e9
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
26 files changed:
opendaylight/md-sal/model/model-flow-service/pom.xml
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataCommitHandler.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModification.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataProviderService.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationServiceImpl.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/package-info.java [new file with mode: 0644]
opendaylight/md-sal/sal-connector-api/pom.xml
opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java
opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java [new file with mode: 0644]

index 583a7ac..6b8df6a 100644 (file)
@@ -29,7 +29,7 @@
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>opendaylight-l2-types</artifactId>
-            <version>2013.08.27-SNAPSHOT</version>
+            <version>2013.08.27.0</version>
         </dependency>
     </dependencies>
     <packaging>bundle</packaging>
index a176664..ffb39d5 100644 (file)
@@ -16,7 +16,9 @@ public abstract class AbstractBindingAwareConsumer implements BindingAwareConsum
     }
 
     @Deprecated
-    abstract protected void startImpl(BundleContext context);
+    protected void startImpl(BundleContext context) {
+        
+    }
     
     @Override
     public final  void stop(BundleContext context) throws Exception {
index 20a7c0d..994d3f4 100644 (file)
@@ -1,5 +1,9 @@
 package org.opendaylight.controller.sal.binding.api;
 
+import java.util.Collection;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -10,16 +14,53 @@ public abstract class AbstractBindingAwareProvider implements BindingAwareProvid
     public final void start(BundleContext context) throws Exception {
             ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
             BindingAwareBroker broker = context.getService(brokerRef);
-            broker.registerProvider(this, context);
+            
+            ProviderContext ctx = broker.registerProvider(this, context);
+            registerRpcImplementations(ctx);
+            registerFunctionality(ctx);
+            
             startImpl(context);
     }
     
-    @Deprecated
-    abstract protected void startImpl(BundleContext context);
+    private void registerFunctionality(ProviderContext ctx) {
+        Collection<? extends ProviderFunctionality> functionality = this.getFunctionality();
+        if(functionality == null || functionality.isEmpty()) {
+            return;
+        }
+        for (ProviderFunctionality providerFunctionality : functionality) {
+            ctx.registerFunctionality(providerFunctionality);
+        }
+        
+    }
+
+    private void registerRpcImplementations(ProviderContext ctx) {
+        Collection<? extends RpcService> rpcs = this.getImplementations();
+        if(rpcs == null || rpcs.isEmpty()) {
+            return;
+        }
+        for (RpcService rpcService : rpcs) {
+            //ctx.addRpcImplementation(type, implementation);
+        }
+        
+    }
+
+    protected void startImpl(BundleContext context) {
+        // NOOP
+    }
     
     @Override
     public final void stop(BundleContext context) throws Exception {
             
             
     }
+    
+    @Override
+    public Collection<? extends ProviderFunctionality> getFunctionality() {
+        return null;
+    }
+    
+    @Override
+    public Collection<? extends RpcService> getImplementations() {
+        return null;
+    }
 }
index 87008cd..14db6e5 100644 (file)
@@ -7,8 +7,11 @@
  */
 package org.opendaylight.controller.sal.binding.api;
 
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleContext;
 
@@ -161,14 +164,52 @@ public interface BindingAwareBroker {
      * 
      */
     public interface ProviderContext extends ConsumerContext {
+        /**
+         * Registers an global RpcService implementation.
+         * 
+         * @param type
+         * @param implementation
+         * @return
+         */
+        <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
+                throws IllegalStateException;
 
-        <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation);
+        <T extends RpcService> RpcRegistration<T> addMountRpcImplementation(Class<T> type,
+                InstanceIdentifier mount, T implementation) throws IllegalStateException;
+
+        <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
+                throws IllegalStateException;
+        
+        void registerFunctionality(ProviderFunctionality functionality);
+        void unregisterFunctionality(ProviderFunctionality functionality);
     }
 
-    public interface RpcServiceRegistration<T extends RpcService> {
+    public interface RpcRegistration<T extends RpcService> {
 
+        /**
+         * 
+         * @return instance for which registration does exists.
+         */
         T getService();
 
+        /**
+         * Unregister an RpcService from broker.
+         * 
+         */
         void unregister();
     }
+
+    public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T> {
+
+        /**
+         * Register particular instance identifier to be processed by this
+         * RpcService
+         * 
+         * @param context
+         * @param instance
+         */
+        void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier instance);
+
+        void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier instance);
+    }
 }
index 86c9eeb..7052ab0 100644 (file)
@@ -7,9 +7,13 @@
  */
 package org.opendaylight.controller.sal.binding.api;
 
+import java.util.concurrent.ExecutorService;
+
 import org.opendaylight.yangtools.yang.binding.Notification;
 
 public interface NotificationProviderService extends NotificationService {
 
     void notify(Notification notification);
+    
+    void notify(Notification notification, ExecutorService service);
 }
index 3723c70..38bf7a1 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 public interface NotificationService extends BindingAwareService {
 
     <T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
-
+    void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener);
+    void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener);
     <T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
 }
index dd055aa..cd04d35 100644 (file)
@@ -11,7 +11,9 @@ import java.util.concurrent.Future;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareService;
 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 /**
@@ -56,6 +58,7 @@ public interface DataBrokerService extends BindingAwareService {
      *            Data tree filter similar to the NETCONF filter
      * @return
      */
+    @Deprecated
     <T extends DataRoot> T getData(DataStoreIdentifier store, T filter);
 
     /**
@@ -68,6 +71,7 @@ public interface DataBrokerService extends BindingAwareService {
      *            Identifier of the store, from which will be data retrieved
      * @return
      */
+    @Deprecated
     <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType);
 
     /**
@@ -90,6 +94,7 @@ public interface DataBrokerService extends BindingAwareService {
      *            A filter data root
      * @return
      */
+    @Deprecated
     <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter);
 
     /**
@@ -104,6 +109,7 @@ public interface DataBrokerService extends BindingAwareService {
      * @return Result object containing the modified data tree if the operation
      *         was successful, otherwise list of the encountered errors.
      */
+    @Deprecated
     RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet);
 
     /**
@@ -130,5 +136,17 @@ public interface DataBrokerService extends BindingAwareService {
      * @return Result of the commit, containing success information or list of
      *         encountered errors, if commit was not successful.
      */
+    @Deprecated
     Future<RpcResult<Void>> commit(DataStoreIdentifier store);
+    
+    
+    DataObject getData(InstanceIdentifier data);
+    DataObject getConfigurationData(InstanceIdentifier data);
+    
+    /**
+     * Creates a data modification transaction.
+     * 
+     * @return new blank data modification transaction.
+     */
+    DataModification beginTransaction();
 }
index ea5a16e..b12dce6 100644 (file)
@@ -77,107 +77,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
  * <li>For each <code>CommitTransaction</code> from Commit Request phase
  * <ol>
  * <li><code>Broker</code>
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
- * 
  * broker invokes a {@link CommitTransaction#finish()}
  * <li>The provider rollbacks a commit and returns an {@link RpcResult} of
  * rollback. </ol>
@@ -234,6 +133,13 @@ public interface DataCommitHandler extends ProviderFunctionality {
          */
         DataStoreIdentifier getDataStore();
 
+        /**
+         * Returns a modification transaction which is the source of this
+         * commit transaction.
+         * 
+         */
+        DataModification getModification();
+        
         /**
          * Returns the handler associated with this transaction.
          * 
diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModification.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModification.java
new file mode 100644 (file)
index 0000000..4506caf
--- /dev/null
@@ -0,0 +1,77 @@
+package org.opendaylight.controller.sal.binding.api.data;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public interface DataModification {
+    
+    /**
+     * Returns transaction identifier
+     * 
+     * @return Transaction identifier
+     */
+    Object getIdentifier();
+    
+    TransactionStatus getStatus();
+    
+    /**
+     * Reads data from overal data storage which includes
+     * runtime and configuration data.
+     * 
+     * @param path
+     * @return
+     */
+    DataObject read(InstanceIdentifier path);
+    
+    /**
+     * Reads data from configuration data storage.
+     * 
+     * @param path Instance identifier which 
+     * @return
+     */
+    DataObject readConfiguration(InstanceIdentifier path);
+    
+    void putRuntimeData(InstanceIdentifier path,DataObject data);
+    void putConfigurationData(InstanceIdentifier path,DataObject data);
+    void removeRuntimeData(InstanceIdentifier path);
+    void removeConfigurationData(InstanceIdentifier path);
+
+
+    Map<InstanceIdentifier,DataObject> getRuntimeDataUpdates();
+    Map<InstanceIdentifier,DataObject> getConfigurationDataUpdates();
+    Set<InstanceIdentifier> getRemovals();
+    Set<InstanceIdentifier> getConfigurationRemovals();
+    
+    /**
+     * Commits transaction to be stored in global data repository.
+     * 
+     * 
+     * @return  Future object which returns RpcResult with TransactionStatus 
+     *          when transaction is processed by store.
+     */
+    Future<RpcResult<TransactionStatus>> commit();
+    
+    void registerListener(DataTransactionListener listener);
+    void unregisterListener(DataTransactionListener listener);
+    
+    public enum TransactionStatus {
+        
+        UNSUBMITTED,
+        COMMITING,
+        COMMITED,
+        FAILED,
+        CANCELED
+    }
+    
+    public interface DataTransactionListener {
+        
+        void onStatusUpdated(DataModification transaction,TransactionStatus status);
+        
+    }
+}
index 857b07b..801a1c0 100644 (file)
@@ -7,7 +7,12 @@
  */
 package org.opendaylight.controller.sal.binding.api.data;
 
+import java.util.Map;
+import java.util.Set;
+
 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public interface DataProviderService extends DataBrokerService {
 
@@ -61,5 +66,4 @@ public interface DataProviderService extends DataBrokerService {
      * @param refresher
      */
     void removeRefresher(DataStoreIdentifier store, DataRefresher refresher);
-
 }
index 4b01aed..68a2b29 100644 (file)
@@ -2,11 +2,13 @@ package org.opendaylight.controller.sal.binding.api.data;
 
 import java.util.Set;
 
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public interface RuntimeDataProvider {
+public interface RuntimeDataProvider extends ProviderFunctionality {
 
     Set<DataStoreIdentifier> getSupportedStores();
     
@@ -48,4 +50,7 @@ public interface RuntimeDataProvider {
      * @return
      */
     <T extends DataRoot> T getData(DataStoreIdentifier store, T filter);
+    
+    
+     <T extends DataObject> T getData(Class<T> dataType, InstanceIdentifier identifier);
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java
new file mode 100644 (file)
index 0000000..9f7e05c
--- /dev/null
@@ -0,0 +1,81 @@
+package org.opendaylight.controller.sal.binding.codegen;
+
+import org.opendaylight.controller.sal.binding.spi.DelegateProxy;
+import org.opendaylight.controller.sal.binding.spi.RpcRouter;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
+
+public interface RuntimeCodeGenerator {
+
+    /**
+     * Returns an instance of provided RpcService type which delegates all calls
+     * to the delegate.
+     * 
+     * <p>
+     * Returned instance:
+     * <ul>
+     * <li>implements provided subclass of RpcService type and
+     * {@link DelegateProxy} interface.
+     * <li>
+     * <p>
+     * delegates all invocations of methods, which are defined in RpcService
+     * subtype to delegate which is defined by
+     * {@link DelegateProxy#setDelegate(Object)}.
+     * <p>
+     * If delegate is not defined (<code>getDelegate() == null</code>)
+     * implementation throws {@link IllegalStateException}
+     * <li>{@link DelegateProxy#getDelegate()} - returns the delegate to which
+     * all calls are delegated.
+     * <li>{@link DelegateProxy#setDelegate(Object)} - sets the delegate for
+     * particular instance
+     * 
+     * </ul>
+     * 
+     * @param serviceType
+     *            - Subclass of RpcService for which direct proxy is to be
+     *            generated.
+     * @return Instance of RpcService of provided serviceType which implements
+     *         and {@link DelegateProxy}
+     * @throws IllegalArgumentException
+     * 
+     */
+    <T extends RpcService> T getDirectProxyFor(Class<T> serviceType) throws IllegalArgumentException;
+
+    /**
+     * Returns an instance of provided RpcService type which routes all calls to
+     * other instances selected on particular input field.
+     * 
+     * <p>
+     * Returned instance:
+     * <ul><li>Implements:
+     *     <ul><li>{@link DelegateProxy}
+     *         <li>{@link RpcRouter}
+     *     </ul>
+     *     <li>
+     *     routes all invocations of methods, which are defined in RpcService
+     *     subtype based on method arguments and routing information defined in the
+     *     RpcRoutingTables for this instance
+     *     {@link RpcRouter#getRoutingTable(Class)}.
+     *     <ul>
+     *     <li>
+     *     Implementation uses
+     *     {@link RpcRouter#getService(Class, InstanceIdentifier)} method to
+     *     retrieve particular instance to which call will be routed.
+     *    <li>
+     *    Instance of {@link InstanceIdentifier} is determined by first argument of
+     *    method and is retrieved via method which is annotated with
+     *    {@link RoutingContext}. Class representing Routing Context Identifier is
+     *    retrieved by {@link RoutingContext}.
+     *    <li>If first argument is not defined / {@link RoutingContext} annotation
+     *    is not present on any field invocation will be delegated to default
+     *    service {@link RpcRouter#getDefaultService()}.
+     * </ul>
+     * 
+     * @param serviceType
+     *            - Subclass of RpcService for which Router is to be generated.
+     * @return Instance of RpcService of provided serviceType which implements
+     *         also {@link RpcRouter}<T> and {@link DelegateProxy}
+     */
+    <T extends RpcService> T getRouterFor(Class<T> serviceType) throws IllegalArgumentException;
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend
new file mode 100644 (file)
index 0000000..522102b
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.controller.sal.binding.codegen.impl
+
+import java.lang.ClassLoader
+
+class BrokerImplClassLoader extends ClassLoader {
+
+    val ClassLoader spiClassLoader
+    
+    public new(ClassLoader model, ClassLoader spi) {
+        super(model)
+        spiClassLoader = spi;
+    }
+
+    override public loadClass(String name) throws ClassNotFoundException {
+        try {
+            return super.loadClass(name);
+        } catch (ClassNotFoundException e) {
+            return spiClassLoader.loadClass(name);
+        }
+    }
+
+}
index 298a74e..8a3d2c0 100644 (file)
@@ -28,16 +28,19 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo
 
 import org.slf4j.LoggerFactory
 import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration
 
 class BindingAwareBrokerImpl implements BindingAwareBroker {
     private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
-    
+
     private val clsPool = ClassPool.getDefault()
     private var RuntimeCodeGenerator generator;
     private Map<Class<? extends RpcService>, RpcProxyContext> managedProxies = new HashMap();
     private var NotificationBrokerImpl notifyBroker
     private var ServiceRegistration<NotificationProviderService> notifyBrokerRegistration
-    
+
     @Property
     var BundleContext brokerBundleContext
 
@@ -92,9 +95,9 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
      * If proxy class does not exist for supplied service class it will be generated automatically.
      */
     def <T extends RpcService> getManagedDirectProxy(Class<T> service) {
-        
+
         var RpcProxyContext existing = null
-        if ((existing = managedProxies.get(service)) != null) {
+        if((existing = managedProxies.get(service)) != null) {
             return existing.proxy
         }
         val proxyClass = generator.generateDirectProxy(service)
@@ -107,6 +110,7 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         managedProxies.put(service, rpcProxyCtx)
         return rpcProxyCtx.proxy
     }
+
     /**
      * Registers RPC Implementation
      * 
@@ -121,4 +125,15 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         proxy.delegate = service;
         return new RpcServiceRegistrationImpl<T>(type, service, osgiReg);
     }
+
+    def <T extends RpcService> RpcRegistration<T> registerMountedRpcImplementation(Class<T> tyoe, T service, InstanceIdentifier identifier,
+        OsgiProviderContext context, Hashtable<String, String> properties) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    def <T extends RpcService> RoutedRpcRegistration<T> registerRoutedRpcImplementation(Class<T> type, T service, OsgiProviderContext context,
+        Hashtable<String, String> properties) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
 }
index 22db735..8b0400f 100644 (file)
@@ -49,4 +49,17 @@ class NotificationBrokerImpl implements NotificationProviderService {
     def notifyAll(Collection<NotificationListener<?>> listeners, Notification notification) {
         listeners.forEach[(it as NotificationListener).onNotification(notification)]
     }
+    
+    override addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+        
+    }
+    
+    override removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+    
+    override notify(Notification notification, ExecutorService service) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationServiceImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationServiceImpl.xtend
deleted file mode 100644 (file)
index fb35ee3..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2013 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.controller.sal.binding.impl
-
-import org.opendaylight.controller.sal.binding.api.NotificationService
-import org.opendaylight.controller.sal.binding.api.NotificationListener
-import org.opendaylight.yangtools.yang.binding.Notification
-import com.google.common.collect.Multimap
-import com.google.common.collect.HashMultimap
-
-class NotificationServiceImpl implements NotificationService {
-    val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;
-
-    new() {
-        listeners = HashMultimap.create()
-    }
-
-    override <T extends Notification> addNotificationListener(Class<T> notificationType,
-        NotificationListener<T> listener) {
-        listeners.put(notificationType, listener)
-    }
-
-    override <T extends Notification> removeNotificationListener(Class<T> notificationType,
-        NotificationListener<T> listener) {
-        listeners.remove(notificationType, listener)
-    }
-
-}
index c769ca1..494118b 100644 (file)
@@ -12,24 +12,26 @@ import java.util.Hashtable;
 import java.util.Map;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcServiceRegistration;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleContext;
 
 import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*;
 import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality
 
 class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
 
     @Property
-    val Map<Class<? extends RpcService>, RpcServiceRegistrationImpl<? extends RpcService>> registeredServices
+    val Map<Class<? extends RpcService>, RpcRegistration<? extends RpcService>> registeredServices
 
     new(BundleContext ctx, BindingAwareBrokerImpl broker) {
         super(ctx, broker);
         _registeredServices = new HashMap();
     }
 
-    override def <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation) {
+    override <T extends RpcService> addRpcImplementation(Class<T> type, T implementation) {
 
         // TODO Auto-generated method stub
         val properties = new Hashtable<String, String>();
@@ -40,4 +42,32 @@ class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext
         registeredServices.put(type, salReg)
         return salReg;
     }
+
+    override <T extends RpcService> addMountRpcImplementation(Class<T> type, InstanceIdentifier mount, T implementation) throws IllegalStateException {
+
+        val properties = new Hashtable<String, String>();
+        properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER
+
+        // Fill requirements
+        val salReg = broker.registerMountedRpcImplementation(type, implementation, mount, this, properties)
+        registeredServices.put(type, salReg)
+        return salReg;
+    }
+
+    override <T extends RpcService> addRoutedRpcImplementation(Class<T> type, T implementation) throws IllegalStateException {
+        val properties = new Hashtable<String, String>();
+        properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER
+
+        // Fill requirements
+        val salReg = broker.registerRoutedRpcImplementation(type, implementation, this, properties)
+        registeredServices.put(type, salReg)
+        return salReg;
+    }
+
+    override registerFunctionality(ProviderFunctionality functionality) {
+    
+    }
+
+    override unregisterFunctionality(ProviderFunctionality functionality) {
+    }
 }
index afb27b4..5b31b5f 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.sal.binding.impl
 
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcServiceRegistration
 import org.osgi.framework.ServiceRegistration
 import org.opendaylight.yangtools.yang.binding.RpcService
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration
 
-class RpcServiceRegistrationImpl<T extends RpcService> implements RpcServiceRegistration<T> {
+class RpcServiceRegistrationImpl<T extends RpcService> implements RpcRegistration<T> {
 
     val ServiceRegistration<T> osgiRegistration;
     private val T service;
index b278df5..794e028 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.sal.binding.api.data.DataValidator
 import org.opendaylight.yangtools.yang.common.RpcResult
 import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider
 import java.util.Map
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 
 class _DataBrokerImpl implements DataProviderService {
 
@@ -74,5 +75,17 @@ class _DataBrokerImpl implements DataProviderService {
 
     def DataProviderContext resolveProvider(DataStoreIdentifier store, Class<? extends DataRoot> root) {
     }
+    
+    override beginTransaction() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+    
+    override getConfigurationData(InstanceIdentifier data) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+    
+    override getData(InstanceIdentifier data) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
 
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java
new file mode 100644 (file)
index 0000000..085228c
--- /dev/null
@@ -0,0 +1,7 @@
+package org.opendaylight.controller.sal.binding.spi;
+
+public interface DelegateProxy<T> {
+    
+    void setDelegate(T delegate);
+    T getDelegate();
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java
new file mode 100644 (file)
index 0000000..360f039
--- /dev/null
@@ -0,0 +1,62 @@
+package org.opendaylight.controller.sal.binding.spi;
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+/**
+ * RpcRouter is responsible for selecting RpcService based on provided routing
+ * context identifier {@link RpcRoutingTable#getContextIdentifier()} and path in
+ * overal data tree (@link {@link InstanceIdentifier}.
+ * 
+ * 
+ * @author Tony Tkacik <ttkacik@cisco.com>
+ * 
+ * @param <T>
+ *            Type of RpcService for which router provides routing information
+ *            and route selection.
+ */
+public interface RpcRouter<T extends RpcService> {
+
+    /**
+     * Returns a type of RpcService which is served by this instance of router.
+     * 
+     * @return type of RpcService which is served by this instance of router.
+     */
+    Class<T> getRpcServiceType();
+
+    /**
+     * Returns a routing table for particular route context
+     * 
+     * @param routeContext
+     * @return Routing Table for particular route context.
+     */
+    <C extends BaseIdentity> RpcRoutingTable<C, T> getRoutingTable(Class<C> routeContext);
+
+    /**
+     * Returns an instance of RpcService which is responsible for processing
+     * particular path.
+     * 
+     * @param context
+     *            Rpc Routing Context
+     * @param path
+     *            Instance Identifier which is used as a selector of instance.
+     * @return instance of RpcService which is responsible for processing
+     *         particular path.
+     */
+    T getService(Class<? extends BaseIdentity> context, InstanceIdentifier path);
+
+    /**
+     * Returns a default fallback instance of RpcService which is responsible
+     * for handling all unknown imports.
+     * 
+     * @return default instance responsible for processing RPCs.
+     */
+    T getDefaultService();
+    
+    /**
+     * 
+     */
+    void setDefaultService();
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java
new file mode 100644 (file)
index 0000000..f2d3825
--- /dev/null
@@ -0,0 +1,38 @@
+package org.opendaylight.controller.sal.binding.spi;
+
+import java.util.Map;
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public interface RpcRoutingTable<C extends BaseIdentity,S extends RpcService> {
+
+    Class<C> getContextIdentifier();
+    
+    /**
+     * Updates route for particular path to specified instance of {@link RpcService}. 
+     * 
+     * @param path Path for which RpcService routing is to be updated
+     * @param service Instance of RpcService which is responsible for processing Rpc Requests.
+     */
+    void updateRoute(InstanceIdentifier path,S service);
+    
+    /**
+     * Deletes a route for particular path
+     * 
+     * @param path Path for which 
+     */
+    void deleteRoute(InstanceIdentifier path);
+    
+    /**
+     * 
+     */
+    S getService(InstanceIdentifier nodeInstance);
+    
+    /**
+     * 
+     * @return
+     */
+    Map<InstanceIdentifier,S> getRoutes();
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/package-info.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/package-info.java
new file mode 100644 (file)
index 0000000..774571b
--- /dev/null
@@ -0,0 +1,8 @@
+/**
+ * 
+ */
+/**
+ * @author ttkacik
+ *
+ */
+package org.opendaylight.controller.sal.binding.spi;
\ No newline at end of file
index 68c8756..3be5b82 100644 (file)
     </scm>
 
     <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-core-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-api</artifactId>
index e47d67e..55f8b8c 100644 (file)
@@ -2,8 +2,18 @@ package org.opendaylight.controller.sal.connector.api;
 
 import java.util.Set;
 
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 
-public interface Connector {
+public interface Connector extends RpcImplementation, NotificationListener {
 
+    
+    
+    Set<InstanceIdentifier> getConfigurationPrefixes();
+    Set<InstanceIdentifier> getRuntimePrefixes();
+    
+    void registerListener(ConnectorListener listener);
+    void unregisterListener(ConnectorListener listener);
 }
diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/ConnectorListener.java
new file mode 100644 (file)
index 0000000..ac9c893
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2013 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.controller.sal.connector.api;
+
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public interface ConnectorListener {
+
+    void onPrefixesAnnounced(Set<InstanceIdentifier> prefixes);
+    void onPrefixesWithdrawn(Set<InstanceIdentifier> prefixes);
+
+}

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.