X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Futil%2FAbstractBindingSalConsumerInstance.java;fp=opendaylight%2Fmd-sal%2Fsal-binding-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Futil%2FAbstractBindingSalConsumerInstance.java;h=ff6f6185eaa28cdd50c8cc70570b3ddf39312e7f;hb=696c988be117c8aa1afa39502ff2e56c9b72e834;hp=0000000000000000000000000000000000000000;hpb=43a4eb1e085754c92a88b0d9740610fe382298f8;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java new file mode 100644 index 0000000000..ff6f6185ea --- /dev/null +++ b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java @@ -0,0 +1,178 @@ +package org.opendaylight.controller.md.sal.binding.util; + +import java.util.concurrent.Future; +import java.util.zip.Checksum; + +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; +import org.opendaylight.controller.sal.binding.api.NotificationListener; +import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.binding.api.mount.MountInstance; +import org.opendaylight.controller.sal.common.DataStoreIdentifier; +import org.opendaylight.yangtools.concepts.Identifiable; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.concepts.Registration; +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.binding.Notification; +import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.base.Preconditions; + +public abstract class AbstractBindingSalConsumerInstance // + implements // + RpcConsumerRegistry, // + NotificationService, // + DataBrokerService { + + private final R rpcRegistry; + private final N notificationBroker; + private final D dataBroker; + + protected final R getRpcRegistry() { + return rpcRegistry; + } + + protected final N getNotificationBroker() { + return notificationBroker; + } + + protected final D getDataBroker() { + return dataBroker; + } + + protected final R getRpcRegistryChecked() { + Preconditions.checkState(rpcRegistry != null,"Rpc Registry is not available."); + return rpcRegistry; + } + + protected final N getNotificationBrokerChecked() { + Preconditions.checkState(notificationBroker != null,"Notification Broker is not available."); + return notificationBroker; + } + + protected final D getDataBrokerChecked() { + Preconditions.checkState(dataBroker != null, "Data Broker is not available"); + return dataBroker; + } + + + protected AbstractBindingSalConsumerInstance(R rpcRegistry, N notificationBroker, D dataBroker) { + this.rpcRegistry = rpcRegistry; + this.notificationBroker = notificationBroker; + this.dataBroker = dataBroker; + } + + public T getRpcService(Class module) { + return getRpcRegistryChecked().getRpcService(module); + } + + @Deprecated + public void addNotificationListener(Class notificationType, + NotificationListener listener) { + getNotificationBrokerChecked().addNotificationListener(notificationType, listener); + } + + @Deprecated + public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { + getNotificationBrokerChecked().addNotificationListener(listener); + } + + @Deprecated + public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { + getNotificationBrokerChecked().removeNotificationListener(listener); + } + + @Deprecated + public void removeNotificationListener(Class notificationType, + NotificationListener listener) { + getNotificationBrokerChecked().removeNotificationListener(notificationType, listener); + } + + public Registration> registerNotificationListener( + Class notificationType, NotificationListener listener) { + return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener); + } + + public Registration registerNotificationListener( + org.opendaylight.yangtools.yang.binding.NotificationListener listener) { + return getNotificationBrokerChecked().registerNotificationListener(listener); + } + + @Deprecated + public T getData(DataStoreIdentifier store, Class rootType) { + return getDataBrokerChecked().getData(store, rootType); + } + + @Deprecated + public T getData(DataStoreIdentifier store, T filter) { + return getDataBrokerChecked().getData(store, filter); + } + + @Deprecated + public T getCandidateData(DataStoreIdentifier store, Class rootType) { + return getDataBrokerChecked().getCandidateData(store, rootType); + } + + @Deprecated + public T getCandidateData(DataStoreIdentifier store, T filter) { + return getDataBrokerChecked().getCandidateData(store, filter); + } + + @Deprecated + public RpcResult editCandidateData(DataStoreIdentifier store, DataRoot changeSet) { + return getDataBrokerChecked().editCandidateData(store, changeSet); + } + + @Deprecated + public Future> commit(DataStoreIdentifier store) { + return getDataBrokerChecked().commit(store); + } + + @Deprecated + public DataObject getData(InstanceIdentifier data) { + return getDataBrokerChecked().getData(data); + } + + @Deprecated + public DataObject getConfigurationData(InstanceIdentifier data) { + return getDataBrokerChecked().getConfigurationData(data); + } + + public DataModificationTransaction beginTransaction() { + return getDataBrokerChecked().beginTransaction(); + } + + @Deprecated + public void registerChangeListener(InstanceIdentifier path, DataChangeListener changeListener) { + getDataBrokerChecked().registerChangeListener(path, changeListener); + } + + @Deprecated + public void unregisterChangeListener(InstanceIdentifier path, + DataChangeListener changeListener) { + getDataBrokerChecked().unregisterChangeListener(path, changeListener); + } + + @Deprecated + public DataObject readConfigurationData(InstanceIdentifier path) { + return getDataBrokerChecked().readConfigurationData(path); + } + + public DataObject readOperationalData(InstanceIdentifier path) { + return getDataBrokerChecked().readOperationalData(path); + } + + @Deprecated + public ListenerRegistration registerDataChangeListener( + InstanceIdentifier path, DataChangeListener listener) { + return getDataBrokerChecked().registerDataChangeListener(path, listener); + } +}