<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.controller</groupId>
- <artifactId>sal-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
</parent>
- <artifactId>sal-binding-api</artifactId>
+ <artifactId>mdsal-binding-api</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-common-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.yangtools</groupId>
+ <groupId>org.opendaylight.mdsal</groupId>
<artifactId>yang-binding</artifactId>
</dependency>
<dependency>
@Nonnull ModificationType getModificationType();
/**
- * Returns before-state of top level container. Implementations are encouraged,
- * but not required to provide this state.
+ * Returns before-state of top level container. Implementations are encouraged, but not required
+ * to provide this state.
*
- * @param root Class representing data container
- * @return State of object before modification. Null if subtree was not present,
- * or the implementation cannot provide the state.
+ *
+ * @return State of object before modification. Null if subtree was not present, or the
+ * implementation cannot provide the state.
*/
@Nullable T getDataBefore();
/**
* Returns after-state of top level container.
*
- * @param root Class representing data container
* @return State of object after modification. Null if subtree is not present.
*/
@Nullable T getDataAfter();
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
- * A {@link DOMService} which allows users to register for changes to a
- * subtree.
+ * A {@link BindingService} which allows users to register for changes to a subtree.
*/
public interface DataTreeChangeService extends BindingService {
/**
}
/**
- * Return the {@link YangInstanceIdentifier} of the root node.
+ * Return the {@link InstanceIdentifier} of the root node.
*
* @return Instance identifier corresponding to the root node.
*/
void putNotification(Notification notification) throws InterruptedException;
/**
- * Publishes a notification to subscribed listeners. This initiates
- * the process of sending the notification, but delivery to the
- * listeners can happen asynchronously, potentially after a call to
- * this method returns.
+ * Publishes a notification to subscribed listeners. This initiates the process of sending the
+ * notification, but delivery to the listeners can happen asynchronously, potentially after a
+ * call to this method returns.
*
* Still guaranteed not to block. Returns Listenable Future which will complete once.
*
- * @param notification
- * the notification to publish.
+ * @param notification the notification to publish.
* @return A listenable future which will report completion when the service has finished
- * propagating the notification to its immediate registrants, or {@value #REJECTED} if resource
- * constraints prevent
+ * propagating the notification to its immediate registrants, or {@link #REJECTED} if
+ * resource constraints prevent
* @throws NullPointerException if the notification is null
*/
ListenableFuture<? extends Object> offerNotification(Notification notification);
/**
- * Publishes a notification to subscribed listeners. This initiates
- * the process of sending the notification, but delivery to the
- * listeners can happen asynchronously, potentially after a call to
- * this method returns. This method is guaranteed not to block more
- * than the specified timeout.
+ * Publishes a notification to subscribed listeners. This initiates the process of sending the
+ * notification, but delivery to the listeners can happen asynchronously, potentially after a
+ * call to this method returns. This method is guaranteed not to block more than the specified
+ * timeout.
*
- * @param notification
- * the notification to publish.
+ * @param notification the notification to publish.
* @param timeout how long to wait before giving up, in units of unit
- * @param unit a TimeUnit determining how to interpret the
- * timeout parameter
+ * @param unit a TimeUnit determining how to interpret the timeout parameter
* @return A listenable future which will report completion when the service has finished
- * propagating the notification to its immediate registrants, or {@value #REJECTED} if resource
- * constraints prevent
+ * propagating the notification to its immediate registrants, or {@link #REJECTED} if
+ * resource constraints prevent
* @throws InterruptedException if interrupted while waiting
* @throws NullPointerException if the notification or unit is null
* @throws IllegalArgumentException if timeout is negative.
/**
* Notification broker which allows clients to subscribe for and publish YANG-modeled notifications.
*
- * Each YANG module which defines notifications results in a generated interface <code>{ModuleName}Listener</code>
- * which handles all the notifications defined in the YANG model. Each notification type translates to
- * a specific method of the form <code>on{NotificationType}</code> on the generated interface.
- * The generated interface also extends the
- * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations
- * are registered using {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)}
+ * Each YANG module which defines notifications results in a generated interface
+ * <code>{ModuleName}Listener</code> which handles all the notifications defined in the YANG model.
+ * Each notification type translates to a specific method of the form
+ * <code>on{NotificationType}</code> on the generated interface. The generated interface also
+ * extends the {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and
+ * implementations are registered using
+ * {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)}
* method.
*
- * <h5>Dispatch Listener Example</h5>
+ * <b>Dispatch Listener Example</b>
* <p>
* Lets assume we have following YANG model:
*
* <pre>
* module example {
* ...
- *
+ *
* notification start {
* ...
* }
- *
+ *
* notification stop {
* ...
* }
* </pre>
*
* The generated interface will be:
+ *
* <pre>
- * public interface ExampleListener extends NotificationListener {
- * void onStart(Start notification);
- * void onStop(Stop notification);
- * }
+ * public interface ExampleListener extends NotificationListener {
+ * void onStart(Start notification);
+ *
+ * void onStop(Stop notification);
+ * }
* </pre>
+ *
* The following defines an implementation of the generated interface:
+ *
* <pre>
- * public class MyExampleListener implements ExampleListener {
- * public void onStart(Start notification) {
- * // do something
- * }
- *
- * public void onStop(Stop notification) {
- * // do something
- * }
- * }
+ * public class MyExampleListener implements ExampleListener {
+ * public void onStart(Start notification) {
+ * // do something
+ * }
+ *
+ * public void onStop(Stop notification) {
+ * // do something
+ * }
+ * }
* </pre>
+ *
* The implementation is registered as follows:
+ *
* <pre>
- * MyExampleListener listener = new MyExampleListener();
- * ListenerRegistration<NotificationListener> reg = service.registerNotificationListener( listener );
+ * MyExampleListener listener = new MyExampleListener();
+ * ListenerRegistration<NotificationListener> reg = service.registerNotificationListener(listener);
* </pre>
- * The <code>onStart</code> method will be invoked when someone publishes a <code>Start</code> notification and
- * the <code>onStop</code> method will be invoked when someone publishes a <code>Stop</code> notification.
+ *
+ * The <code>onStart</code> method will be invoked when someone publishes a <code>Start</code>
+ * notification and the <code>onStop</code> method will be invoked when someone publishes a
+ * <code>Stop</code> notification.
*/
public interface NotificationService extends BindingService {
/**
--- /dev/null
+/*
+ * 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.api;
+
+import org.osgi.framework.BundleContext;
+
+@Deprecated
+public abstract class AbstractBindingAwareConsumer extends AbstractBrokerAwareActivator implements BindingAwareConsumer {
+
+ @Override
+ protected final void onBrokerAvailable(final BindingAwareBroker broker, final BundleContext context) {
+ broker.registerConsumer(this);
+ }
+
+ /**
+ * Called when this bundle is started (before
+ * {@link #onSessionInitialized(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext)}
+ * so the Framework can perform the bundle-specific activities necessary to start this bundle.
+ * This method can be used to register services or to allocate any resources that this bundle
+ * needs.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param context The execution context of the bundle being started.
+ * @throws Exception If this method throws an exception, this bundle is marked as stopped and
+ * the Framework will remove this bundle's listeners, unregister all services registered
+ * by this bundle, and release all services used by this bundle.
+ */
+ @Override
+ protected void startImpl(final BundleContext context) throws Exception {
+ // NOOP
+ }
+}
--- /dev/null
+/*
+ * 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.api;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.osgi.framework.BundleContext;
+
+@Deprecated
+public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator implements BindingAwareProvider {
+
+ @Override
+ protected final void onBrokerAvailable(final BindingAwareBroker broker, final BundleContext context) {
+ final ProviderContext ctx = broker.registerProvider(this);
+ }
+
+ /**
+ * Called when this bundle is started (before {@link #onSessionInitiated(ProviderContext)} so
+ * the Framework can perform the bundle-specific activities necessary to start this bundle. This
+ * method can be used to register services or to allocate any resources that this bundle needs.
+ *
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ *
+ * @param context The execution context of the bundle being started.
+ * @throws Exception If this method throws an exception, this bundle is marked as stopped and
+ * the Framework will remove this bundle's listeners, unregister all services registered
+ * by this bundle, and release all services used by this bundle.
+ */
+ @Override
+ protected void startImpl(final BundleContext context) throws Exception {
+ // NOOP
+ }
+}
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
private BundleContext context;
private ServiceTracker<BindingAwareBroker, BindingAwareBroker> tracker;
private BindingAwareBroker broker;
- private ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker> customizer = new ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker>() {
+ private final ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker> customizer = new ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker>() {
@Override
- public BindingAwareBroker addingService(ServiceReference<BindingAwareBroker> reference) {
+ public BindingAwareBroker addingService(final ServiceReference<BindingAwareBroker> reference) {
broker = context.getService(reference);
mdActivationPool.execute(new Runnable() {
}
@Override
- public void modifiedService(ServiceReference<BindingAwareBroker> reference, BindingAwareBroker service) {
+ public void modifiedService(final ServiceReference<BindingAwareBroker> reference, final BindingAwareBroker service) {
removedService(reference, service);
addingService(reference);
}
@Override
- public void removedService(ServiceReference<BindingAwareBroker> reference, BindingAwareBroker service) {
+ public void removedService(final ServiceReference<BindingAwareBroker> reference, final BindingAwareBroker service) {
broker = context.getService(reference);
mdActivationPool.execute(new Runnable() {
@Override
- public final void start(BundleContext context) throws Exception {
+ public final void start(final BundleContext context) throws Exception {
this.context = context;
startImpl(context);
tracker = new ServiceTracker<>(context, BindingAwareBroker.class, customizer);
@Override
- public final void stop(BundleContext context) throws Exception {
+ public final void stop(final BundleContext context) throws Exception {
tracker.close();
stopImpl(context);
}
-
- /**
- * Called when this bundle is started (before
- * {@link #onSessionInitiated(ProviderContext)} so the Framework can perform
- * the bundle-specific activities necessary to start this bundle. This
- * method can be used to register services or to allocate any resources that
- * this bundle needs.
- *
- * <p>
- * This method must complete and return to its caller in a timely manner.
- *
- * @param context
- * The execution context of the bundle being started.
- * @throws Exception
- * If this method throws an exception, this bundle is marked as
- * stopped and the Framework will remove this bundle's
- * listeners, unregister all services registered by this bundle,
- * and release all services used by this bundle.
- */
- protected void startImpl(BundleContext context) {
+ protected void startImpl(final BundleContext context) throws Exception {
// NOOP
}
* This method must complete and return to its caller in a timely manner.
*
* @param context The execution context of the bundle being stopped.
- * @throws Exception If this method throws an exception, the bundle is still
- * marked as stopped, and the Framework will remove the bundle's
- * listeners, unregister all services registered by the bundle, and
- * release all services used by the bundle.
*/
- protected void stopImpl(BundleContext context) {
+ protected void stopImpl(final BundleContext context) {
// NOOP
}
protected abstract void onBrokerAvailable(BindingAwareBroker broker, BundleContext context);
- protected void onBrokerRemoved(BindingAwareBroker broker, BundleContext context) {
+ protected void onBrokerRemoved(final BindingAwareBroker broker, final BundleContext context) {
stopImpl(context);
}
}
*/
package org.opendaylight.controller.sal.binding.api;
-import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration;
+
+
import org.opendaylight.yangtools.concepts.ObjectRegistration;
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;
/**
* Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
*
- * The responsibility of the broker is to maintain registration of SAL
- * functionality {@link Consumer}s and {@link Provider}s, store provider and
- * consumer specific context and functionality registration via
- * {@link ConsumerContext} and provide access to infrastructure services, which
- * removes direct dependencies between providers and consumers.
+ * The responsibility of the broker is to maintain registration of SAL functionality
+ * {@link BindingAwareConsumer}s and {@link BindingAwareProvider}s, store provider and consumer
+ * specific context and functionality registration via
+ * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} and
+ * provide access to infrastructure services, which removes direct dependencies between providers
+ * and consumers.
*
- * The Binding-aware broker is also responsible for translation from Java
- * classes modeling the functionality and data to binding-independent form which
- * is used in SAL Core.
+ * The Binding-aware broker is also responsible for translation from Java classes modeling the
+ * functionality and data to binding-independent form which is used in SAL Core.
*
*
- * <h3>Infrastructure services</h3> Some examples of infrastructure services:
- *
- * <ul>
- * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
- * {@link ProviderContext}
- * <li>Notification Service - see {@link NotificationService} and
- * {@link NotificationProviderService}
- * <li>Functionality and Data model
- * <li>Data Store access and modification - see {@link org.opendaylight.controller.sal.binding.api.data.DataBrokerService} and
- * {@link org.opendaylight.controller.sal.binding.api.data.DataProviderService}
- * </ul>
- *
- * The services are exposed via session.
+ * <h3>Infrastructure services</h3> Some examples of infrastructure services: The services are
+ * exposed via session.
*
* <h3>Session-based access</h3>
*
- * The providers and consumers needs to register in order to use the
- * binding-independent SAL layer and to expose functionality via SAL layer.
+ * The providers and consumers needs to register in order to use the binding-independent SAL layer
+ * and to expose functionality via SAL layer.
*
- * For more information about session-based access see {@link ConsumerContext}
- * and {@link ProviderContext}
+ * For more information about session-based access see
+ * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} and
+ * {@link ProviderContext}
*/
public interface BindingAwareBroker {
- /*
- * @deprecated Use registerConsumer(BindingAwareConsumer cons) instead (BundleContext is no longer used)
- */
- @Deprecated
- ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
/**
* Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
*
* <p>
- * Note that consumer could register additional functionality at later point
- * by using service and functionality specific APIs.
+ * Note that consumer could register additional functionality at later point by using service
+ * and functionality specific APIs.
*
* <p>
- * The consumer is required to use returned session for all communication
- * with broker or one of the broker services. The session is announced to
- * the consumer by invoking
- * {@link Consumer#onSessionInitiated(ConsumerContext)}.
+ * The consumer is required to use returned session for all communication with broker or one of
+ * the broker services. The session is announced to the consumer by invoking
+ * {@link BindingAwareConsumer#onSessionInitialized(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext)}.
*
- * @param cons
- * Consumer to be registered.
+ * @param consumer Consumer to be registered.
* @return a session specific to consumer registration
- * @throws IllegalArgumentException
- * If the consumer is <code>null</code>.
- * @throws IllegalStateException
- * If the consumer is already registered.
+ * @throws IllegalArgumentException If the consumer is <code>null</code>.
+ * @throws IllegalStateException If the consumer is already registered.
*/
ConsumerContext registerConsumer(BindingAwareConsumer consumer);
- /*
- * @deprecated Use registerProvider(BindingAwareProvider prov) instead (BundleContext is no longer used)
- */
- @Deprecated
- ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
-
/**
* Registers the {@link BindingAwareProvider}, which will use the SAL layer.
*
* <p>
- * During the registration, the broker obtains the initial functionality
- * from consumer, using the
- * {@link BindingAwareProvider#getImplementations()}, and register that
- * functionality into system and concrete infrastructure services.
- *
- * <p>
- * Note that provider could register additional functionality at later point
- * by using service and functionality specific APIs.
+ * Note that provider could register additional functionality at later point by using service
+ * and functionality specific APIs.
*
* <p>
- * The consumer is <b>required to use</b> returned session for all
- * communication with broker or one of the broker services. The session is
- * announced to the consumer by invoking
+ * The consumer is <b>required to use</b> returned session for all communication with broker or
+ * one of the broker services. The session is announced to the consumer by invoking
* {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
*
*
- * @param prov
- * Provider to be registered.
+ * @param provider Provider to be registered.
* @return a session unique to the provider registration.
- * @throws IllegalArgumentException
- * If the provider is <code>null</code>.
- * @throws IllegalStateException
- * If the consumer is already registered.
+ * @throws IllegalArgumentException If the provider is <code>null</code>.
+ * @throws IllegalStateException If the consumer is already registered.
*/
ProviderContext registerProvider(BindingAwareProvider provider);
* {@link BindingAwareConsumer} specific access to the SAL functionality.
*
* <p>
- * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
- * SAL functionality and infrastructure services.
+ * ConsumerSession is {@link BindingAwareConsumer}-specific access to the SAL functionality and
+ * infrastructure services.
*
* <p>
- * The session serves to store SAL context (e.g. registration of
- * functionality) for the consumer and provides access to the SAL
- * infrastructure services and other functionality provided by
- * {@link Provider}s.
+ * The session serves to store SAL context (e.g. registration of functionality) for the consumer
+ * and provides access to the SAL infrastructure services and other functionality provided by
+ * providers.
*/
public interface ConsumerContext extends RpcConsumerRegistry {
/**
* Represents a routed RPC implementation registration. Users should call the
- * {@link RoutedRegistration#close close} method when the registration is no longer needed.
+ * {@link RpcRegistration#close() close} method when the registration is no longer needed.
*
* @param <T> the implemented RPC service interface
*/
- public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
- RoutedRegistration<Class<? extends BaseIdentity>, InstanceIdentifier<?>, T> {
+ public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T> {
/**
* Register particular instance identifier to be processed by this
* RpcService
*
- * Deprecated in favor of {@link RoutedRegistration#registerPath(Object, Object)}.
- *
* @param context
* @param instance
*/
- @Deprecated
- void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
+ void registerPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
/**
* Unregister particular instance identifier to be processed by this
* RpcService
*
- * Deprecated in favor of {@link RoutedRegistration#unregisterPath(Object, Object)}.
- *
* @param context
* @param instance
*/
- @Deprecated
- void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
+ void unregisterPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
}
}
--- /dev/null
+/*
+ * 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.api;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+
+/**
+*
+* A developer implemented component that gets registered with the Broker.
+*
+*/
+public interface BindingAwareConsumer {
+
+ /**
+ * Callback signaling initialization of the consumer session to the SAL.
+ *
+ * The consumer MUST use the session for all communication with SAL or
+ * retrieving SAL infrastructure services.
+ *
+ * This method is invoked by
+ * {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
+ *
+ * @param session
+ * Unique session between consumer and SAL.
+ */
+ void onSessionInitialized(ConsumerContext session);
+
+}
--- /dev/null
+/*
+ * 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.api;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+
+/**
+ *
+ * A developer implemented component that gets registered with the Broker.
+ *
+ * Semantically, a provider may:
+ *
+ * <ol>
+ * <li>Emit Notifications</li>
+ * <li>Provide the implementation of RPCs</li>
+ * <li>Write to the operational data tree</li>
+ * </ol>
+ *
+ *
+ * <p>
+ *
+ * In addition, a BindingAwareProvider can in pursuit of its goals:
+ *
+ * <ol>
+ * <li>Subscribe for Notifications</li>
+ * <li>Invoke RPCs</li>
+ * <li>Read from either the operational or config data tree</li>
+ * <li>Write to the config data tree</li>
+ * </ol>
+ * (All of the above are things a Consumer can also do).
+ *
+ * <p>
+ *
+ * Examples:
+ *
+ * <p>
+ *
+ * To get a NotificationService:
+ *
+ * <pre>
+ * {code
+ * public void onSessionInitiated(ProviderContext session) {
+ * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
+ * }
+ * }
+ * </pre>
+ *
+ *
+ *
+ * To register an RPC implementation:
+ *
+ * <pre>
+ * {code
+ * public void onSessionInitiated(ProviderContext session) {
+ * RpcRegistration<MyService> registration = session.addRpcImplementation(MyService.class, myImplementationInstance);
+ * }
+ * }
+ * </pre>
+ *
+ * <p>
+ *
+ * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it
+ * and myImplementationInstance is an instance of a class that implements MyService.
+ *
+ * To register a Routed RPC Implementation:
+ *
+ * <pre>
+ * {code
+ * public void onSessionInitiated(ProviderContext session) {
+ * RoutedRpcRegistration<SalFlowService> flowRegistration = session.addRoutedRpcImplementation(SalFlowService.class, salFlowServiceImplementationInstance);
+ * flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
+ * }
+ * }
+ * </pre>
+ *
+ * Where SalFlowService.class is a Service interface generated from a yang model with RPCs modeled
+ * in it and salFlowServiceImplementationInstance is an instance of a class that implements
+ * SalFlowService.
+ * <p>
+ * The line:
+ *
+ * <pre>
+ * {code
+ * flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
+ * }
+ * </pre>
+ *
+ * Is indicating that the RPC implementation is registered to handle RPC invocations that have their
+ * NodeContext pointing to the node with instance id nodeInstanceId. This bears a bit of further
+ * explanation. RoutedRPCs can be 'routed' to an implementation based upon 'context'. 'context' is a
+ * pointer (instanceId) to some place in the data tree. In this example, the 'context' is a pointer
+ * to a Node. In this way, a provider can register its ability to provide a service for a particular
+ * Node, but not *all* Nodes. The Broker routes the RPC by 'context' to the correct implementation,
+ * without the caller having to do extra work. Because of this when a RoutedRPC is registered, it
+ * needs to also be able to indicate for which 'contexts' it is providing an implementation.
+ *
+ * An example of a Routed RPC would be an updateFlow(node, flow) that would be routed based on node
+ * to the provider which had registered to provide it *for that node*.
+ *
+ * <p>
+ *
+ * To get a DataBroker to allow access to the data tree:
+ *
+ * <pre>
+ * {code
+ * public void onSessionInitiated(final ProviderContext session) {
+ * DataBroker databroker = session.getSALService(BindingDataBroker.class);
+ * }
+ * }
+ * </pre>
+ *
+ *
+ */
+public interface BindingAwareProvider {
+
+ /**
+ * Callback signaling initialization of the consumer session to the SAL.
+ *
+ * The consumer MUST use the session for all communication with SAL or retrieving SAL
+ * infrastructure services.
+ *
+ * This method is invoked by {@link BindingAwareBroker#registerProvider(BindingAwareProvider)}
+ *
+ * @param session Unique session between consumer and SAL.
+ */
+ void onSessionInitiated(ProviderContext session);
+}
* Returns an implementation of a requested RPC service.
*
* <p>
- * The returned instance is not an actual implementation of the RPC service
- * interface, but a proxy implementation of the interface that forwards to
- * an actual implementation, if any.
+ * The returned instance is not an actual implementation of the RPC service interface, but a
+ * proxy implementation of the interface that forwards to an actual implementation, if any.
* <p>
*
* The following describes the behavior of the proxy when invoking RPC methods:
* <ul>
- * <li>If an actual implementation is registered with the MD-SAL, all invocations are
- * forwarded to the registered implementation.</li>
- * <li>If no actual implementation is registered, all invocations will fail by
- * throwing {@link IllegalStateException}.</li>
- * <li>Prior to invoking the actual implementation, the method arguments are are validated.
- * If any are invalid, an {@link IllegalArgumentException} is thrown.
+ * <li>If an actual implementation is registered with the MD-SAL, all invocations are forwarded
+ * to the registered implementation.</li>
+ * <li>If no actual implementation is registered, all invocations will fail by throwing
+ * {@link IllegalStateException}.</li>
+ * <li>Prior to invoking the actual implementation, the method arguments are are validated. If
+ * any are invalid, an {@link IllegalArgumentException} is thrown.
* </ul>
*
- * The returned proxy is automatically updated with the most recent
- * registered implementation.
+ * The returned proxy is automatically updated with the most recent registered implementation.
* <p>
- * The generated RPC method APIs require implementors to return a {@link java.util.concurrent.Future Future}
- * instance that wraps the {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}. Since
- * RPC methods may be implemented asynchronously, callers should avoid blocking on the
+ * The generated RPC method APIs require implementors to return a
+ * {@link java.util.concurrent.Future Future} instance that wraps the
+ * {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}. Since RPC methods may be
+ * implemented asynchronously, callers should avoid blocking on the
* {@link java.util.concurrent.Future Future} result. Instead, it is recommended to use
* {@link com.google.common.util.concurrent.JdkFutureAdapters#listenInPoolThread(java.util.concurrent.Future)}
- * or {@link com.google.common.util.concurrent.JdkFutureAdapters#listenInPoolThread(java.util.concurrent.Future, java.util.concurrent.Executor)}
+ * or
+ * {@link com.google.common.util.concurrent.JdkFutureAdapters#listenInPoolThread(java.util.concurrent.Future, java.util.concurrent.Executor)}
* to listen for Rpc Result. This will asynchronously listen for future result in executor and
* will not block current thread.
*
* <pre>
- * final Future<RpcResult<SomeRpcOutput>> future = someRpcService.someRpc( ... );
- * Futures.addCallback(JdkFutureAdapters.listenInThreadPool(future), new FutureCallback<RpcResult<SomeRpcOutput>>() {
- *
- * public void onSuccess(RpcResult<SomeRpcOutput> result) {
+ * final Future<RpcResult<SomeRpcOutput>> future = someRpcService.someRpc( ... );
+ * Futures.addCallback(JdkFutureAdapters.listenInThreadPool(future), new FutureCallback<RpcResult<SomeRpcOutput>>() {
+ *
+ * public void onSuccess(RpcResult<SomeRpcOutput> result) {
* // process result ...
* }
- *
+ *
* public void onFailure(Throwable t) {
* // RPC failed
* }
* );
* </pre>
- * @param serviceInterface the interface of the RPC Service. Typically this is an interface generated
- * from a YANG model.
+ *
+ * @param serviceInterface the interface of the RPC Service. Typically this is an interface
+ * generated from a YANG model.
* @return the proxy for the requested RPC service. This method never returns null.
*/
<T extends RpcService> T getRpcService(Class<T> serviceInterface);
*/
package org.opendaylight.controller.sal.binding.api;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
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.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
/**
- * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are
- * defined in YANG models.
+ * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are defined
+ * in YANG models.
* <p>
* There are 2 types of RPCs:
* <ul>
* <h2>Global RPC</h2>
* <p>
* An RPC is global if there is intended to be only 1 registered implementation. A global RPC is not
- * explicitly declared as such, essentially any RPC that is not defined to be routed is considered global.
+ * explicitly declared as such, essentially any RPC that is not defined to be routed is considered
+ * global.
* <p>
- * Global RPCs are registered using the
- * {@link #addRpcImplementation(Class, RpcService)} method.
+ * Global RPCs are registered using the {@link #addRpcImplementation(Class, RpcService)} method.
*
* <h2>Routed RPC</h2>
* <p>
* <p>
* RPC routing is based on:
* <ul>
- * <li><b>Route identifier</b> -
- * An {@link org.opendaylight.yangtools.yang.binding.InstanceIdentifier InstanceIdentifier} value
- * which is part of the RPC input. This value is used to select the correct
- * implementation at run time.</li>
- * <li><b>Context Type</b> - A YANG-defined construct which constrains the subset of
- * valid route identifiers for a particular RPC.</li>
+ * <li><b>Route identifier</b> - An
+ * {@link org.opendaylight.yangtools.yang.binding.InstanceIdentifier InstanceIdentifier} value which
+ * is part of the RPC input. This value is used to select the correct implementation at run time.</li>
+ * <li><b>Context Type</b> - A YANG-defined construct which constrains the subset of valid route
+ * identifiers for a particular RPC.</li>
* </ul>
*
* <h3>Context type</h3>
* <p>
- * A context type is modeled in YANG using a combination of a YANG <code>identity</code>
- * and Opendaylight specific extensions from <code>yang-ext</code> module. These extensions are:
+ * A context type is modeled in YANG using a combination of a YANG <code>identity</code> and
+ * Opendaylight specific extensions from <code>yang-ext</code> module. These extensions are:
* <ul>
- * <li><b>context-instance</b> - This is used in the data tree part of a YANG model to
- * define a context type that associates nodes with a specified context <code>identity</code>.
- * Instance identifiers that reference these nodes are valid route identifiers for RPCs that
- * reference this context type.</li>
+ * <li><b>context-instance</b> - This is used in the data tree part of a YANG model to define a
+ * context type that associates nodes with a specified context <code>identity</code>. Instance
+ * identifiers that reference these nodes are valid route identifiers for RPCs that reference this
+ * context type.</li>
* <li><b>context-reference</b> - This is used in RPC input to mark a leaf of type
* <code>instance-identifier</code> as a reference to the particular context type defined by the
- * specified context <code>identity</code>. The value of this
- * leaf is used by the RPC broker at run time to route the RPC request to the correct implementation.
- * Note that <code>context-reference</code> may only be used on leaf elements of type
+ * specified context <code>identity</code>. The value of this leaf is used by the RPC broker at run
+ * time to route the RPC request to the correct implementation. Note that
+ * <code>context-reference</code> may only be used on leaf elements of type
* <code>instance-identifier</code> or a type derived from <code>instance-identifier</code>.</li>
* </ul>
*
*
* <h3>Routed RPC example</h3>
* <p>
- * <h5>1. Defining a Context Type</h5>
+ * <h4>1. Defining a Context Type</h4>
* <p>
- * The following snippet declares a simple YANG <code>identity</code> named <code>example-context</code>:
+ * The following snippet declares a simple YANG <code>identity</code> named
+ * <code>example-context</code>:
*
* <pre>
* module example {
* }
* </pre>
* <p>
- * We then use the declared identity to define a context type by using it in combination
- * with the <code>context-instance</code> YANG extension. We'll associate the context type
- * with a list element in the data tree. This defines the set of nodes whose instance
- * identifiers are valid for the <code>example-context</code> context type.
+ * We then use the declared identity to define a context type by using it in combination with the
+ * <code>context-instance</code> YANG extension. We'll associate the context type with a list
+ * element in the data tree. This defines the set of nodes whose instance identifiers are valid for
+ * the <code>example-context</code> context type.
* <p>
- * The following YANG snippet imports the <code>yang-ext</code> module and defines the list
- * element named <code>item</code> inside a container named <code>foo</code>:
+ * The following YANG snippet imports the <code>yang-ext</code> module and defines the list element
+ * named <code>item</code> inside a container named <code>foo</code>:
*
* <pre>
* module foo {
* </pre>
* <p>
* The statement <code>ext:context-instance "example-context";</code> inside the list element
- * declares that any instance identifier referencing <code>item</code> in the data
- * tree is valid for <code>example-context</code>. For example, the following instance
- * identifier:
+ * declares that any instance identifier referencing <code>item</code> in the data tree is valid for
+ * <code>example-context</code>. For example, the following instance identifier:
+ *
* <pre>
- * InstanceIdentifier.create(Foo.class).child(Item.class,new ItemKey("Foo"))
+ * InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("Foo"))
* </pre>
+ *
* is valid for <code>example-context</code>. However the following:
+ *
* <pre>
- * InstanceIdentifier.create(Example.class)
+ * InstanceIdentifier.create(Example.class)
* </pre>
+ *
* is not valid.
* <p>
- * So using an <code>identity</code> in combination with <code>context-instance</code> we
- * have effectively defined a context type that can be referenced in a YANG RPC input.
+ * So using an <code>identity</code> in combination with <code>context-instance</code> we have
+ * effectively defined a context type that can be referenced in a YANG RPC input.
*
* <h5>2. Defining an RPC to use the Context Type</h5>
* <p>
- * To define an RPC to be routed based on the context type we need to add an input leaf element
- * that references the context type which will hold an instance identifier value to be
- * used to route the RPC.
+ * To define an RPC to be routed based on the context type we need to add an input leaf element that
+ * references the context type which will hold an instance identifier value to be used to route the
+ * RPC.
* <p>
- * The following snippet defines an RPC named <code>show-item</code> with 2 leaf elements
- * as input: <code>item</code> of type <code>instance-identifier</code> and <code>description</code>:
+ * The following snippet defines an RPC named <code>show-item</code> with 2 leaf elements as input:
+ * <code>item</code> of type <code>instance-identifier</code> and <code>description</code>:
*
* <pre>
* module foo {
* </pre>
* <p>
* We mark the <code>item</code> leaf with a <code>context-reference</code> statement that
- * references the <code>example-context</code> context type. RPC calls will then be routed
- * based on the instance identifier value contained in <code>item</code>. Only instance
- * identifiers that point to a <code>foo/item</code> node are valid as input.
+ * references the <code>example-context</code> context type. RPC calls will then be routed based on
+ * the instance identifier value contained in <code>item</code>. Only instance identifiers that
+ * point to a <code>foo/item</code> node are valid as input.
* <p>
* The generated RPC Service interface for the module is:
*
* }
* </pre>
* <p>
- * For constructing the RPC input, there are generated classes ShowItemInput and ShowItemInputBuilder.
+ * For constructing the RPC input, there are generated classes ShowItemInput and
+ * ShowItemInputBuilder.
*
* <h5>3. Registering a routed RPC implementation</h5>
* <p>
* To register a routed implementation for the <code>show-item</code> RPC, we must use the
- * {@link #addRoutedRpcImplementation(Class, RpcService)} method. This
- * will return a {@link RoutedRpcRegistration} instance which can then be used to register /
- * unregister routed paths associated with the registered implementation.
+ * {@link #addRoutedRpcImplementation(Class, RpcService)} method. This will return a
+ * {@link RoutedRpcRegistration} instance which can then be used to register / unregister routed
+ * paths associated with the registered implementation.
* <p>
* The following snippet registers <code>myImpl</code> as the RPC implementation for an
* <code>item</code> with key <code>"foo"</code>:
+ *
* <pre>
- * // Create the instance identifier path for item "foo"
+ * // Create the instance identifier path for item "foo"
* InstanceIdentifier path = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("foo"));
- *
+ *
* // Register myImpl as the implementation for the FooService RPC interface
* RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(FooService.class, myImpl);
- *
+ *
* // Now register for the context type and specific path ID. The context type is specified by the
* // YANG-generated class for the example-context identity.
* reg.registerPath(ExampleContext.class, path);
* <pre>
* InstanceIdentifier one = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("One"));
* InstanceIdentifier two = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("Two"));
- *
+ *
* RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(FooService.class, myImpl);
* reg.registerPath(ExampleContext.class, one);
* reg.registerPath(ExampleContext.class, two);
* <p>
* When another client invokes the <code>showItem(ShowItemInput)</code> method on the proxy instance
* retrieved via {@link RpcConsumerRegistry#getRpcService(Class)}, the proxy will inspect the
- * arguments in ShowItemInput, extract the InstanceIdentifier value of the <code>item</code> leaf and select
- * the implementation whose registered path matches the InstanceIdentifier value of the <code>item</code> leaf.
+ * arguments in ShowItemInput, extract the InstanceIdentifier value of the <code>item</code> leaf
+ * and select the implementation whose registered path matches the InstanceIdentifier value of the
+ * <code>item</code> leaf.
*
* <h2>Notes for RPC Implementations</h2>
*
* <h3>RpcResult</h3>
* <p>
- * The generated interfaces require implementors to return
- * {@link java.util.concurrent.Future Future}<{@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}<{RpcName}Output>> instances.
+ * The generated interfaces require implementors to return {@link java.util.concurrent.Future
+ * Future}<{@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}
+ * <{RpcName}Output>> instances.
*
- * Implementations should do processing of RPC calls asynchronously and update the
- * returned {@link java.util.concurrent.Future Future} instance when processing is complete.
- * However using {@link com.google.common.util.concurrent.Futures#immediateFuture(Object) Futures.immediateFuture}
- * is valid only if the result is immediately available and asynchronous processing is unnecessary and
- * would only introduce additional complexity.
+ * Implementations should do processing of RPC calls asynchronously and update the returned
+ * {@link java.util.concurrent.Future Future} instance when processing is complete. However using
+ * {@link com.google.common.util.concurrent.Futures#immediateFuture(Object) Futures.immediateFuture}
+ * is valid only if the result is immediately available and asynchronous processing is unnecessary
+ * and would only introduce additional complexity.
*
* <p>
- * The {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult} is a generic
- * wrapper for the RPC output payload, if any, and also allows for attaching error or
- * warning information (possibly along with the payload) should the RPC processing partially
- * or completely fail. This is intended to provide additional human readable information
- * for users of the API and to transfer warning / error information across the system
- * so it may be visible via other external APIs such as Restconf.
+ * The {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult} is a generic wrapper for
+ * the RPC output payload, if any, and also allows for attaching error or warning information
+ * (possibly along with the payload) should the RPC processing partially or completely fail. This is
+ * intended to provide additional human readable information for users of the API and to transfer
+ * warning / error information across the system so it may be visible via other external APIs such
+ * as Restconf.
* <p>
* It is recommended to use the {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}
- * for conveying appropriate error information
- * on failure rather than purposely throwing unchecked exceptions if at all possible.
- * While unchecked exceptions will fail the returned {@link java.util.concurrent.Future Future},
- * using the intended RpcResult to convey the error information is more user-friendly.
+ * for conveying appropriate error information on failure rather than purposely throwing unchecked
+ * exceptions if at all possible. While unchecked exceptions will fail the returned
+ * {@link java.util.concurrent.Future Future}, using the intended RpcResult to convey the error
+ * information is more user-friendly.
*/
-public interface RpcProviderRegistry extends //
- RpcConsumerRegistry, //
- RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
+public interface RpcProviderRegistry extends RpcConsumerRegistry {
/**
* Registers a global implementation of the provided RPC service interface.
* All methods of the interface are required to be implemented.
/**
* Registers an implementation of the given routed RPC service interface.
* <p>
- * See the {@link RpcProviderRegistry class} documentation for information and example on
- * how to use routed RPCs.
+ * See the {@link RpcProviderRegistry class} documentation for information and example on how to
+ * use routed RPCs.
*
- * @param serviceInterface the YANG-generated interface of the RPC Service for which to register.
+ * @param serviceInterface the YANG-generated interface of the RPC Service for which to
+ * register.
* @param implementation the implementation instance to register.
* @return a RoutedRpcRegistration instance which can be used to register paths for the RPC
- * implementation via invoking {@link RoutedRpcRegistration#registerPath(....).
- * {@link RoutedRpcRegistration#close()} should be called to unregister the implementation
- * and all previously registered paths when no longer needed.
+ * implementation via invoking
+ * {@link RoutedRpcRegistration#registerPath(Class, org.opendaylight.yangtools.yang.binding.InstanceIdentifier)}
+ * . {@link RoutedRpcRegistration#close()} should be called to unregister the
+ * implementation and all previously registered paths when no longer needed.
*
- * @throws IllegalStateException
- * if the supplied RPC interface is not a routed RPC type.
+ * @throws IllegalStateException if the supplied RPC interface is not a routed RPC type.
*/
<T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface,
T implementation)
<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.controller</groupId>
- <artifactId>sal-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
</parent>
- <artifactId>sal-binding-broker-impl</artifactId>
+ <artifactId>mdsal-binding-dom-adapter</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-util</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-util</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-broker-impl</artifactId>
- <scope>compile</scope>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-dom-broker</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-dom-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-dom-spi</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-generator-impl</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>binding-generator-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>binding-data-codec</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-dom-codec</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-util</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools.model</groupId>
- <artifactId>ietf-inet-types</artifactId>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.yangtools.model</groupId>
- <artifactId>ietf-topology-l3-unicast-igp</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-test-model</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Export-Package>
- org.opendaylight.controller.sal.binding.impl,
- org.opendaylight.controller.md.sal.binding.impl,
- org.opendaylight.controller.md.sal.binding.compat,
- org.opendaylight.controller.md.sal.binding.spi,
- org.opendaylight.controller.sal.binding.codegen.impl,
+ org.opendaylight.mdsal.sal.binding.impl,
+ org.opendaylight.mdsal.md.sal.binding.impl,
+ org.opendaylight.mdsal.md.sal.binding.compat,
+ org.opendaylight.mdsal.md.sal.binding.spi,
+ org.opendaylight.mdsal.sal.binding.codegen.impl,
</Export-Package>
</instructions>
</configuration>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<includes>
- <include>org.opendaylight.controller.*</include>
+ <include>org.opendaylight.mdsal.*</include>
</includes>
</configuration>
<executions>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <codeGenerators>
- <generator>
- <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
- <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
- <additionalConfiguration>
- <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
- </additionalConfiguration>
- </generator>
-
- <generator>
- <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
- <outputBaseDir>${salGeneratorPath}</outputBaseDir>
- </generator>
-
- <generator>
- <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
- <outputBaseDir>target/site/models</outputBaseDir>
- </generator>
- </codeGenerators>
- <inspectDependencies>true</inspectDependencies>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
<scm>
--- /dev/null
+/*
+ * 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.controller.md.sal.binding.impl;
+
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AbstractReadWriteTransaction extends AbstractWriteTransaction<DOMDataReadWriteTransaction> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractReadWriteTransaction.class);
+
+ public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate, final BindingToNormalizedNodeCodec codec) {
+ super(delegate, codec);
+ }
+
+}
private void ensureListParentIfNeeded(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized) {
if (Identifiable.class.isAssignableFrom(path.getTargetType())) {
- YangInstanceIdentifier parentMapPath = normalized.getKey().getParent();
+ final YangInstanceIdentifier parentMapPath = normalized.getKey().getParent();
Preconditions.checkArgument(parentMapPath != null, "Map path %s does not have a parent", path);
- NormalizedNode<?, ?> emptyParent = getCodec().getDefaultNodeFor(parentMapPath);
+ final NormalizedNode<?, ?> emptyParent = getCodec().getDefaultNodeFor(parentMapPath);
getDelegate().merge(store, parentMapPath, emptyParent);
}
}
}
/**
- * Subclasses of this class are required to implement creation of parent
- * nodes based on behaviour of their underlying transaction.
+ * Subclasses of this class are required to implement creation of parent nodes based on
+ * behaviour of their underlying transaction.
*
* @param store
- * @param key
+ * @param domPath
* @param path
*/
- protected abstract void ensureParentsByMerge(LogicalDatastoreType store,
- YangInstanceIdentifier key, InstanceIdentifier<?> path);
+ protected final void ensureParentsByMerge(final LogicalDatastoreType store, final YangInstanceIdentifier domPath,
+ final InstanceIdentifier<?> path) {
+ final YangInstanceIdentifier parentPath = domPath.getParent();
+ if (parentPath != null) {
+ final NormalizedNode<?, ?> parentNode = getCodec().instanceIdentifierToNode(parentPath);
+ getDelegate().merge(store, YangInstanceIdentifier.create(parentNode.getIdentifier()), parentNode);
+ }
+ }
protected final void doDelete(final LogicalDatastoreType store,
final InstanceIdentifier<?> path) {
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
class BindingDOMWriteTransactionAdapter<T extends DOMDataWriteTransaction> extends
AbstractWriteTransaction<T> implements WriteTransaction {
}
- @Override
- protected void ensureParentsByMerge(final LogicalDatastoreType store,
- final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, final InstanceIdentifier<?> path) {
- List<PathArgument> currentArguments = new ArrayList<>();
- DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
- Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator();
- while (iterator.hasNext()) {
- PathArgument currentArg = iterator.next();
- try {
- currentOp = currentOp.getChild(currentArg);
- } catch (DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
- }
- currentArguments.add(currentArg);
- org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(
- currentArguments);
-
- getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
- }
- }
-
@Override
public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
doDelete( store, path);
}
+ @Deprecated
@Override
public ListenableFuture<RpcResult<TransactionStatus>> commit() {
- return AbstractDataTransaction.convertToLegacyCommitFuture(submit());
+ throw new UnsupportedOperationException();
}
@Override
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTree;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeFactory;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
});
private BindingRuntimeContext runtimeContext;
- private DataNormalizer legacyToNormalized;
public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy,
final BindingNormalizedNodeCodecRegistry codecRegistry) {
}
}
- public DataNormalizer getDataNormalizer() {
- return legacyToNormalized;
- }
-
public Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> toBinding(
@Nonnull final Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized)
throws DeserializationException {
@Override
public void onGlobalContextUpdated(final SchemaContext arg0) {
- legacyToNormalized = new DataNormalizer(arg0);
runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, arg0);
codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
if(futureSchema != null) {
return codecRegistry.deserializeFunction(path);
}
- /**
- * Returns an default object according to YANG schema for supplied path.
- *
- * @param path DOM Path
- * @return Node with defaults set on.
- */
- public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
- final Iterator<PathArgument> iterator = path.getPathArguments().iterator();
- DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation();
- while (iterator.hasNext()) {
- final PathArgument currentArg = iterator.next();
- try {
- currentOp = currentOp.getChild(currentArg);
- } catch (final DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
- }
- }
- return currentOp.createDefault(path.getLastPathArgument());
- }
-
public BindingNormalizedNodeCodecRegistry getCodecRegistry() {
return codecRegistry;
}
return clazzes;
}
+ protected NormalizedNode<?, ?> instanceIdentifierToNode(final YangInstanceIdentifier parentPath) {
+ return ImmutableNodes.fromInstanceId(runtimeContext.getSchemaContext(), parentPath);
+ }
+
+ public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier parentMapPath) {
+ final BindingCodecTreeNode<?> mapCodec = codecRegistry.getCodecContext().getSubtreeCodec(parentMapPath);
+ final Object schema = mapCodec.getSchema();
+ if (schema instanceof ListSchemaNode) {
+ final ListSchemaNode castedSchema = (ListSchemaNode) schema;
+ if (castedSchema.isUserOrdered()) {
+ return Builders.orderedMapBuilder(castedSchema).build();
+ } else {
+ return Builders.mapBuilder(castedSchema).build();
+ }
+ }
+ throw new IllegalArgumentException("Path does not point to list schema node");
+ }
+
}
--- /dev/null
+/*
+ * 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.controller.sal.binding.impl;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yangtools.concepts.Identifiable;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RootBindingAwareBroker implements Identifiable<String>, BindingAwareBroker, AutoCloseable,
+ RpcProviderRegistry {
+
+ private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
+
+
+ private final String identifier;
+
+
+ private final ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
+ private final ImmutableClassToInstanceMap<BindingAwareService> supportedProviderServices;
+
+ public RootBindingAwareBroker(final String instanceName,
+ final ImmutableClassToInstanceMap<BindingAwareService> consumerServices,
+ final ImmutableClassToInstanceMap<BindingAwareService> providerServices) {
+ this.identifier = instanceName;
+ supportedConsumerServices = consumerServices;
+ supportedProviderServices = providerServices;
+ }
+
+ @Override
+ public String getIdentifier() {
+ return identifier;
+ }
+
+
+ public RpcProviderRegistry getRpcProviderRegistry() {
+ return supportedProviderServices.getInstance(RpcProviderRegistry.class);
+ }
+
+ public RpcProviderRegistry getRpcBroker() {
+ return getRpcBroker();
+ }
+
+ public MountPointService getMountService() {
+ return supportedConsumerServices.getInstance(MountPointService.class);
+ }
+
+ @Override
+ public ConsumerContext registerConsumer(final BindingAwareConsumer consumer) {
+ checkState(supportedConsumerServices != null, "Broker is not initialized.");
+ return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
+ }
+
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider provider) {
+ checkState(supportedProviderServices != null, "Broker is not initialized.");
+ return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices);
+ }
+
+ @Override
+ public void close() throws Exception {
+ // FIXME: Close all sessions
+ }
+
+ @Override
+ public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
+ final T implementation) throws IllegalStateException {
+ return getRpcProviderRegistry().addRoutedRpcImplementation(type, implementation);
+ }
+
+ @Override
+ public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T implementation)
+ throws IllegalStateException {
+ return getRpcProviderRegistry().addRpcImplementation(type, implementation);
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(final Class<T> module) {
+ return getRpcBroker().getRpcService(module);
+ }
+}
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRouteInGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.yang.binding.DataObject;
@Test
public void testClusteredDataChangeListernerRegisteration() {
- BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry);
+ final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry);
- BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(dataBroker, codec);
+ final BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(dataBroker, codec);
Mockito.when(codecRegistry.toYangInstanceIdentifier(TOP_PATH)).thenReturn(yangInstanceIdentifier);
- ArgumentCaptor<ClusteredDOMDataChangeListener> clusteredDOMListener = ArgumentCaptor.
+ final ArgumentCaptor<ClusteredDOMDataChangeListener> clusteredDOMListener = ArgumentCaptor.
forClass(ClusteredDOMDataChangeListener.class);
- ArgumentCaptor<LogicalDatastoreType> logicalDatastoreType = ArgumentCaptor.forClass(LogicalDatastoreType.class);
- ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor.
+ final ArgumentCaptor<LogicalDatastoreType> logicalDatastoreType = ArgumentCaptor.forClass(LogicalDatastoreType.class);
+ final ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor.
forClass(AsyncDataBroker.DataChangeScope.class);
- ArgumentCaptor<YangInstanceIdentifier> yangInstanceIdentifier = ArgumentCaptor.
+ final ArgumentCaptor<YangInstanceIdentifier> yangInstanceIdentifier = ArgumentCaptor.
forClass(YangInstanceIdentifier.class);
- TestListener listener = new TestListener();
+ final TestListener listener = new TestListener();
bindingDOMDataBrokerAdapter.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, TOP_PATH, listener,
AsyncDataBroker.DataChangeScope.BASE);
private class TestListener implements ClusteredDataChangeListener {
@Override
- public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
}
}
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
TreeComplexUsesAugment.class);
private void writeInitialState() {
- WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH,
new TopBuilder().build());
- TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder()
+ final TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder()
.setContainerWithUses(
new ContainerWithUsesBuilder().setLeafFromGrouping(
"foo").build()).build();
}
private void delete(final InstanceIdentifier<?> path) {
- WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
tx.delete(LogicalDatastoreType.OPERATIONAL, path);
assertCommit(tx.submit());
}
private void deleteAndListenAugment(final DataChangeScope scope,
final InstanceIdentifier<?> path) {
writeInitialState();
- TestListener listener = createListener(
+ final TestListener listener = createListener(
LogicalDatastoreType.OPERATIONAL, WILDCARDED_AUGMENT_PATH,
scope);
delete(path);
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
TreeComplexUsesAugment.class);
public void writeTopWithListItem(final LogicalDatastoreType store) {
- ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
- Top topItem = top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)));
+ final ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
+ final Top topItem = top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)));
tx.put(store, TOP_PATH, topItem);
assertCommit(tx.submit());
}
public void deleteItem(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
- ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
+ final ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
tx.delete(store, path);
assertCommit(tx.submit());
}
@Test
public void writeTopWithListItemAugmentedListenTopSubtree() {
- TestListener listener = createListener(CONFIGURATION,TOP_PATH, DataChangeScope.SUBTREE);
+ final TestListener listener = createListener(CONFIGURATION,TOP_PATH, DataChangeScope.SUBTREE);
listener.startCapture();
writeTopWithListItem(CONFIGURATION);
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), TOP_PATH);
assertContains(event.getCreatedData(), path(TOP_FOO_KEY));
@Test
public void writeTopWithListItemAugmentedListenAugmentSubtreeWildcarded() {
- TestListener listener = createListener(CONFIGURATION,AUGMENT_WILDCARD, DataChangeScope.SUBTREE);
+ final TestListener listener = createListener(CONFIGURATION,AUGMENT_WILDCARD, DataChangeScope.SUBTREE);
listener.startCapture();
writeTopWithListItem(CONFIGURATION);
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
/*
* Event should not contain parent nodes
@Test
public void deleteAugmentChildListenTopSubtree() {
writeTopWithListItem(CONFIGURATION);
- TestListener listener = createListener(CONFIGURATION, TOP_PATH, DataChangeScope.SUBTREE);
- InstanceIdentifier<?> deletePath = path(TOP_FOO_KEY,USES_ONE_KEY);
+ final TestListener listener = createListener(CONFIGURATION, TOP_PATH, DataChangeScope.SUBTREE);
+ final InstanceIdentifier<?> deletePath = path(TOP_FOO_KEY,USES_ONE_KEY);
deleteItem(CONFIGURATION,deletePath);
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertEmpty(event.getCreatedData());
public void deleteAugmentChildListenAugmentSubtreeWildcarded() {
writeTopWithListItem(CONFIGURATION);
- TestListener listener = createListener(CONFIGURATION, AUGMENT_WILDCARD, DataChangeScope.SUBTREE);
- InstanceIdentifier<?> deletePath = path(TOP_FOO_KEY,USES_ONE_KEY);
+ final TestListener listener = createListener(CONFIGURATION, AUGMENT_WILDCARD, DataChangeScope.SUBTREE);
+ final InstanceIdentifier<?> deletePath = path(TOP_FOO_KEY,USES_ONE_KEY);
deleteItem(CONFIGURATION,deletePath);
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertEmpty(event.getCreatedData());
package org.opendaylight.controller.md.sal.binding.impl.test;
+import static org.junit.Assert.assertTrue;
+import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertContains;
+import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertEmpty;
+import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
+import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment;
+import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.leafOnlyUsesAugment;
+import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
+import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
+
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertContains;
-import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertEmpty;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.leafOnlyUsesAugment;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment;
-
public class Bug1418AugmentationTest extends AbstractDataChangeListenerTest{
private static final InstanceIdentifier<Top> TOP = InstanceIdentifier.create(Top.class);
private static final InstanceIdentifier<TopLevelList> TOP_FOO = TOP.child(TopLevelList.class, TOP_FOO_KEY);
@Test
public void leafOnlyAugmentationCreatedTest() {
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
assertTrue(listener.hasEvent());
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), SIMPLE_AUGMENT);
assertEmpty(event.getUpdatedData());
assertEmpty(event.getOriginalData());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf changed"));
assertCommit(writeTx.submit());
assertTrue(listener.hasEvent());
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getUpdatedData(), SIMPLE_AUGMENT);
assertContains(event.getOriginalData(), SIMPLE_AUGMENT);
assertEmpty(event.getCreatedData());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT);
assertCommit(writeTx.submit());
assertTrue(listener.hasEvent());
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getRemovedPaths(), SIMPLE_AUGMENT);
assertContains(event.getOriginalData(), SIMPLE_AUGMENT);
assertEmpty(event.getCreatedData());
@Test
public void complexAugmentationCreatedTest() {
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
assertCommit(writeTx.submit());
assertTrue(listener.hasEvent());
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), COMPLEX_AUGMENT);
assertContains(event.getCreatedData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
assertEmpty(event.getUpdatedData());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
assertCommit(writeTx.submit());
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY_MOD));
assertCommit(writeTx.submit());
assertTrue(listener.hasEvent());
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getUpdatedData(), COMPLEX_AUGMENT);
assertContains(event.getCreatedData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY_MOD));
assertContains(event.getRemovedPaths(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChanged;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.OpendaylightMdsalBindingTestListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChanged;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
listenerRegistration.close();
}
- private static class TestNotifListener implements OpendaylightMdsalListTestListener {
- private List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
- private CountDownLatch latch;
+ private static class TestNotifListener implements OpendaylightMdsalBindingTestListener {
+ private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
+ private final CountDownLatch latch;
- public TestNotifListener(CountDownLatch latch) {
+ public TestNotifListener(final CountDownLatch latch) {
this.latch = latch;
}
@Override
- public void onTwoLevelListChanged(TwoLevelListChanged notification) {
+ public void onTwoLevelListChanged(final TwoLevelListChanged notification) {
receivedNotifications.add(notification);
latch.countDown();
}
import org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@Override
protected void setupWithDataBroker(final DataBroker dataBroker) {
- WriteTransaction initialTx = dataBroker.newWriteOnlyTransaction();
+ final WriteTransaction initialTx = dataBroker.newWriteOnlyTransaction();
initialTx.put(CONFIGURATION, TOP, top(topLevelList(TOP_FOO_KEY)));
assertCommit(initialTx.submit());
}
@Test
public void replaceTopNodeSubtreeListeners() {
- TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
- TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
- TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
- TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
+ final TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
+ final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
+ final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
+ final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
+ final ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.put(CONFIGURATION, TOP, top(topLevelList(TOP_BAR_KEY)));
assertCommit(writeTx.submit());
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> top = topListener.event();
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> all = allListener.event();
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> foo = fooListener.event();
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> bar = barListener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> top = topListener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> all = allListener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> foo = fooListener.event();
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> bar = barListener.event();
// Listener for TOP element
assertContains(top.getOriginalData(), TOP,TOP_FOO);
@Test
public void mergeTopNodeSubtreeListeners() {
- TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
- TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
- TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
- TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
+ final TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
+ final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
+ final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
+ final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
+ final ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.merge(CONFIGURATION, TOP, top(topLevelList(TOP_BAR_KEY)));
assertCommit(writeTx.submit());
@Test
public void putTopBarNodeSubtreeListeners() {
- TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
- TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
- TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
- TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
+ final TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
+ final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
+ final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
+ final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
+ final ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.put(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY));
assertCommit(writeTx.submit());
@Test
public void mergeTopBarNodeSubtreeListeners() {
- TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
- TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
- TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
- TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
+ final TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
+ final TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE);
+ final TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
+ final TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE);
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
+ final ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.merge(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY));
assertCommit(writeTx.submit());
import static org.junit.Assert.assertTrue;
+import com.google.common.base.Optional;
import java.util.concurrent.ExecutionException;
-
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-
public class WriteTransactionTest extends AbstractDataBrokerTest {
private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
@Test
public void test() throws InterruptedException, ExecutionException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE);
writeTx.submit().get();
@Test
public void testPutCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
writeTx.submit().checkedGet();
- ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
- Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
+ final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+ final Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
assertTrue("Top node must exists after commit",topNode.isPresent());
- Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
+ final Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit",listNode.isPresent());
}
@Test
public void testMergeCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
writeTx.submit().checkedGet();
- ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
- Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
+ final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+ final Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
assertTrue("Top node must exists after commit",topNode.isPresent());
- Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
+ final Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit",listNode.isPresent());
}
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry;
-import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.compat.HydrogenMountProvisionServiceAdapter;
import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter;
import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
import org.opendaylight.controller.sal.core.api.BrokerService;
private RootBindingAwareBroker baBrokerImpl;
- private HeliumNotificationProviderServiceAdapter baNotifyImpl;
-
-
private BrokerImpl biBrokerImpl;
private final ListeningExecutorService executor;
private ImmutableMap<LogicalDatastoreType, DOMStore> newDatastores;
- @Deprecated
- private DataProviderService baData;
-
private DOMDataBroker newDOMDataBroker;
private final MockSchemaService mockSchemaService = new MockSchemaService();
public void startBindingBroker() {
checkState(executor != null, "Executor needs to be set");
- checkState(baData != null, "Binding Data Broker must be started");
- checkState(baNotifyImpl != null, "Notification Service must be started");
baConsumerRpc = new BindingDOMRpcServiceAdapter(getDomRpcInvoker(), codec);
baProviderRpc = new BindingDOMRpcProviderServiceAdapter(getDomRpcRegistry(), codec);
-
- baBrokerImpl = new RootBindingAwareBroker("test");
-
final MountPointService mountService = new BindingDOMMountPointServiceAdapter(biMountImpl, codec);
- baBrokerImpl.setMountService(mountService);
- baBrokerImpl.setLegacyMountManager(new HydrogenMountProvisionServiceAdapter(mountService));
- baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(baConsumerRpc, baProviderRpc));
- baBrokerImpl.setLegacyDataBroker(baData);
- baBrokerImpl.setNotificationBroker(baNotifyImpl);
- baBrokerImpl.start();
+
+ final ImmutableClassToInstanceMap<BindingAwareService> consumerServices =
+ ImmutableClassToInstanceMap.<BindingAwareService>builder().build();
+ final ImmutableClassToInstanceMap<BindingAwareService> providerServices =
+ ImmutableClassToInstanceMap.<BindingAwareService>builder().build();;
+ baBrokerImpl = new RootBindingAwareBroker("test", consumerServices, providerServices);
}
public void startForwarding() {
startDomMountPoint();
startBindingToDomMappingService();
startNewDataBroker();
- startNewBindingDataBroker();
startBindingNotificationBroker();
startBindingBroker();
}
}
- public void startNewBindingDataBroker() {
- final HydrogenDataBrokerAdapter forwarded = new HydrogenDataBrokerAdapter(dataBroker);
- baData = forwarded;
- }
-
private void startDomMountPoint() {
biMountImpl = new DOMMountPointServiceImpl();
}
domListenService = router;
publishService = new BindingDOMNotificationPublishServiceAdapter(codec, domPublishService);
listenService = new BindingDOMNotificationServiceAdapter(codec, domListenService);
- baNotifyImpl = new HeliumNotificationProviderServiceAdapter(publishService,listenService);
}
updateYangSchema(moduleInfos);
}
- @Deprecated
- public DataProviderService getBindingDataBroker() {
- return baData;
- }
+
public RpcProviderRegistry getBindingRpcRegistry() {
- return baBrokerImpl.getRoot();
+ return baBrokerImpl.getRpcProviderRegistry();
}
public DOMRpcProviderService getDomRpcRegistry() {
}
- public MountProviderService getBindingMountProviderService() {
- return baBrokerImpl.getLegacyMount();
- }
-
public DOMMountPointService getDomMountProviderService() {
return biMountImpl;
}
*/
@Beta
@Nullable InstanceIdentifier.PathArgument deserializePathArgument(@Nullable YangInstanceIdentifier.PathArgument arg);
+
+ Object getSchema();
}
}
protected DataContainerCodecPrototype<ChoiceCaseNode> loadCase(final Class<?> childClass) {
- final Optional<ChoiceCaseNode> childSchema = factory().getRuntimeContext().getCaseSchemaDefinition(schema(), childClass);
+ final Optional<ChoiceCaseNode> childSchema = factory().getRuntimeContext().getCaseSchemaDefinition(getSchema(), childClass);
if (childSchema.isPresent()) {
return DataContainerCodecPrototype.from(childClass, childSchema.get(), factory());
}
- LOG.debug("Supplied class %s is not valid case in schema %s", childClass, schema());
+ LOG.debug("Supplied class %s is not valid case in schema %s", childClass, getSchema());
return null;
}
@Override
public NodeCodecContext<?> yangPathArgumentChild(final YangInstanceIdentifier.PathArgument arg) {
final DataContainerCodecPrototype<?> cazeProto = byYangCaseChild.get(arg);
- childNonNull(cazeProto != null, arg,"Argument %s is not valid child of %s", arg, schema());
+ childNonNull(cazeProto != null, arg,"Argument %s is not valid child of %s", arg, getSchema());
return cazeProto.get().yangPathArgumentChild(arg);
}
this.prototype = prototype;
}
- protected final T schema() {
+ @Override
+ public final T getSchema() {
return prototype.getSchema();
}
protected DataObjectCodecContext(final DataContainerCodecPrototype<T> prototype) {
super(prototype);
- this.leafChild = factory().getLeafNodes(getBindingClass(), schema());
+ this.leafChild = factory().getLeafNodes(getBindingClass(), getSchema());
final Map<Class<?>, Method> clsToMethod = BindingReflections.getChildrenClassToMethod(getBindingClass());
if (Augmentable.class.isAssignableFrom(getBindingClass())) {
- this.possibleAugmentations = factory().getRuntimeContext().getAvailableAugmentationTypes(schema());
+ this.possibleAugmentations = factory().getRuntimeContext().getAvailableAugmentationTypes(getSchema());
} else {
this.possibleAugmentations = ImmutableMap.of();
}
} else {
childSupplier = byYang.get(arg);
}
- childNonNull(childSupplier != null, arg, "Argument %s is not valid child of %s", arg, schema());
+ childNonNull(childSupplier != null, arg, "Argument %s is not valid child of %s", arg, getSchema());
return (NodeCodecContext<D>) childSupplier.get();
}
// was defined.
DataSchemaNode sameName;
try {
- sameName = schema().getDataChildByName(origDef.getQName());
+ sameName = getSchema().getDataChildByName(origDef.getQName());
} catch (final IllegalArgumentException e) {
sameName = null;
}
} else {
// We are looking for instantiation via uses in other module
final QName instantiedName = QName.create(namespace(), origDef.getQName().getLocalName());
- final DataSchemaNode potential = schema().getDataChildByName(instantiedName);
+ final DataSchemaNode potential = getSchema().getDataChildByName(instantiedName);
// We check if it is really instantiated from same
// definition as class was derived
if (potential != null && origDef.equals(SchemaNodeUtils.getRootOriginalIfPossible(potential))) {
}
}
final DataSchemaNode nonNullChild =
- childNonNull(childSchema, childClass, "Node %s does not have child named %s", schema(), childClass);
+ childNonNull(childSchema, childClass, "Node %s does not have child named %s", getSchema(), childClass);
return DataContainerCodecPrototype.from(childClass, nonNullChild, factory());
}
@SuppressWarnings("unchecked")
final Entry<AugmentationIdentifier, AugmentationSchema> augSchema = factory().getRuntimeContext()
- .getResolvedAugmentationSchema(schema(), augClass);
+ .getResolvedAugmentationSchema(getSchema(), augClass);
return DataContainerCodecPrototype.from(augClass, augSchema.getKey(), augSchema.getValue(), factory());
}
KeyedListNodeCodecContext(final DataContainerCodecPrototype<ListSchemaNode> prototype) {
super(prototype);
- this.codec = factory().getPathArgumentCodec(getBindingClass(), schema());
+ this.codec = factory().getPathArgumentCodec(getBindingClass(), getSchema());
try {
this.keyGetter = getBindingClass().getMethod("getKey");
} catch (NoSuchMethodException e) {
private final YangInstanceIdentifier.PathArgument yangIdentifier;
private final Codec<Object, Object> valueCodec;
private final Method getter;
+ private final DataSchemaNode schema;
public LeafNodeCodecContext(final DataSchemaNode schema, final Codec<Object, Object> codec, final Method getter) {
this.yangIdentifier = new YangInstanceIdentifier.NodeIdentifier(schema.getQName());
this.valueCodec = codec;
this.getter = getter;
+ this.schema = schema;
}
@Override
return getDomPathArgument();
}
+ @Override
+ public Object getSchema() {
+ return schema;
+ }
+
}
\ No newline at end of file
@SuppressWarnings("unchecked")
@Override
public DataContainerCodecContext<?,?> load(final QName qname) {
- final DataSchemaNode childSchema = schema().getDataChildByName(qname);
- childNonNull(childSchema, qname,"Argument %s is not valid child of %s", qname,schema());
+ final DataSchemaNode childSchema = getSchema().getDataChildByName(qname);
+ childNonNull(childSchema, qname,"Argument %s is not valid child of %s", qname,getSchema());
if (childSchema instanceof DataNodeContainer || childSchema instanceof ChoiceSchemaNode) {
@SuppressWarnings("rawtypes")
final Class childCls = factory().getRuntimeContext().getClassForSchema(childSchema);
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public ContainerNodeCodecContext load(final SchemaPath key) {
- final ContainerSchemaNode schema = SchemaContextUtil.getRpcDataSchema(schema(), key);
+ final ContainerSchemaNode schema = SchemaContextUtil.getRpcDataSchema(getSchema(), key);
final Class cls = factory().getRuntimeContext().getClassForSchema(schema);
return getRpc(cls);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public NotificationCodecContext load(final SchemaPath key) throws Exception {
- final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(schema(), key);
+ final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(getSchema(), key);
final Class clz = factory().getRuntimeContext().getClassForSchema(schema);
return getNotification(clz);
}
final Class<Object> parent = ClassLoaderUtils.findFirstGenericArgument(key, ChildOf.class);
IncorrectNestingException.check(DataRoot.class.isAssignableFrom(parent), "Class %s is not top level item.", key);
final QName qname = BindingReflections.findQName(key);
- final DataSchemaNode childSchema = childNonNull(schema().getDataChildByName(qname),key,"%s is not top-level item.",key);
+ final DataSchemaNode childSchema = childNonNull(getSchema().getDataChildByName(qname),key,"%s is not top-level item.",key);
return DataContainerCodecPrototype.from(key, childSchema, factory()).get();
}
final QName qname = BindingReflections.findQName(key);
final QNameModule module = qname.getModule();
RpcDefinition rpc = null;
- for (final RpcDefinition potential : schema().getOperations()) {
+ for (final RpcDefinition potential : getSchema().getOperations()) {
final QName potentialQName = potential.getQName();
/*
*
* FIXME: After Lithium cleanup of yang-model-api, use direct call on schema context
* to retrieve notification via index.
*/
- final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(schema(),
+ final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(getSchema(),
SchemaPath.create(true, qname));
Preconditions.checkArgument(schema != null, "Supplied %s is not valid notification", notificationType);
import javassist.ClassPool;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.binding.data.codec.impl.MissingClassInLoadingStrategyException;
import java.util.Collections;
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.RpcComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.RpcComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
/*
* Copyright (c) 2015 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
import java.util.List;
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode;
import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeCachingCodec;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
*/
package org.opendaylight.yangtools.binding.data.codec.test;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.RpcComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.RpcComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.put.top.input.top.level.list.choice.in.list.ComplexViaUsesWithDifferentNameBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.top.level.list.choice.in.list.ComplexViaUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.put.top.input.top.level.list.choice.in.list.ComplexViaUsesWithDifferentNameBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.ComplexViaUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import java.util.Collections;
-
-import static org.junit.Assert.assertEquals;
-
public class CaseSubstitutionTest extends AbstractBindingRuntimeTest {
@Override
public void setup() {
super.setup();
- JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
+ final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
registry.onBindingRuntimeContextUpdated(getRuntimeContext());
}
@Test
public void choiceInGroupingSubstituted() {
- TopLevelList baRpc = new TopLevelListBuilder()
+ final TopLevelList baRpc = new TopLevelListBuilder()
.setKey(TOP_FOO_KEY)
.setChoiceInList(new ComplexViaUsesWithDifferentNameBuilder(createComplexData()).build())
.build();
- TopLevelList baTree = new TopLevelListBuilder()
+ final TopLevelList baTree = new TopLevelListBuilder()
.setKey(TOP_FOO_KEY)
.setChoiceInList(new ComplexViaUsesBuilder(createComplexData()).build())
.build();
- NormalizedNode<?, ?> domTreeEntry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, baTree).getValue();
- NormalizedNode<?, ?> domRpcEntry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, baRpc).getValue();
+ final NormalizedNode<?, ?> domTreeEntry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, baTree).getValue();
+ final NormalizedNode<?, ?> domRpcEntry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, baRpc).getValue();
assertEquals(domTreeEntry, domRpcEntry);
}
import java.util.Map.Entry;
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.RpcComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.RpcComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeaf;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeafBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.ChoiceInList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.RpcComplexUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeaf;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeafBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.ChoiceInList;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
@Override
public void setup() {
super.setup();
- JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
+ final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
registry.onBindingRuntimeContextUpdated(getRuntimeContext());
}
@Test
public void testCaseWithEmptyLeafType() {
- TopLevelList withEmptyCase = new TopLevelListBuilder()
+ final TopLevelList withEmptyCase = new TopLevelListBuilder()
.setKey(TOP_FOO_KEY)
.setChoiceInList(new EmptyLeafBuilder().setEmptyType(true).build())
.build();
- Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> dom = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, withEmptyCase);
- Entry<InstanceIdentifier<?>, DataObject> readed = registry.fromNormalizedNode(dom.getKey(),dom.getValue());
- ChoiceInList list = ((TopLevelList) readed.getValue()).getChoiceInList();
+ final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> dom = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, withEmptyCase);
+ final Entry<InstanceIdentifier<?>, DataObject> readed = registry.fromNormalizedNode(dom.getKey(),dom.getValue());
+ final ChoiceInList list = ((TopLevelList) readed.getValue()).getChoiceInList();
assertTrue(list instanceof EmptyLeaf);
assertTrue(((EmptyLeaf) list).isEmptyType());
}
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.binding.data.codec.impl.IncorrectNestingException;
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
- private static final QName TOP_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:binding", "2014-07-01", "top");
+ private static final QName TOP_QNAME = Top.QNAME;
private static final YangInstanceIdentifier BI_TOP_PATH = YangInstanceIdentifier.builder().node(TOP_QNAME).build();
private static final YangInstanceIdentifier BI_TREE_LEAF_ONLY = FULL_CODEC.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY);
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.Iterables;
import javassist.ClassPool;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
- public static final QName TOP_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:binding", "2014-07-01", "top");
+ public static final QName TOP_QNAME = Top.QNAME;
public static final QName TOP_LEVEL_LIST_QNAME = QName.create(TOP_QNAME, "top-level-list");
public static final QName TOP_LEVEL_LIST_KEY = QName.create(TOP_QNAME, "name");
private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
*/
package org.opendaylight.yangtools.binding.data.codec.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class InstanceIdentifierTest extends AbstractBindingRuntimeTest {
@Override
public void setup() {
super.setup();
- JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
+ final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
registry.onBindingRuntimeContextUpdated(getRuntimeContext());
}
@Test
public void testComplexAugmentationSerialization() {
- YangInstanceIdentifier yangII = registry.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES);
- PathArgument lastArg = yangII.getLastPathArgument();
+ final YangInstanceIdentifier yangII = registry.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES);
+ final PathArgument lastArg = yangII.getLastPathArgument();
assertTrue("Last argument should be AugmentationIdentifier", lastArg instanceof AugmentationIdentifier);
- InstanceIdentifier<?> bindingII = registry.fromYangInstanceIdentifier(yangII);
+ final InstanceIdentifier<?> bindingII = registry.fromYangInstanceIdentifier(yangII);
assertEquals(BA_TREE_COMPLEX_USES, bindingII);
}
@Test
public void testLeafOnlyAugmentationSerialization() {
- PathArgument leafOnlyLastArg = registry.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument();
+ final PathArgument leafOnlyLastArg = registry.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument();
assertTrue("Last argument should be AugmentationIdentifier", leafOnlyLastArg instanceof AugmentationIdentifier);
assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME));
}
import java.util.Map.Entry;
import javassist.ClassPool;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.ThirdParty;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexLeaves;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexLeavesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Int32StringUnion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.ThirdParty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexLeaves;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexLeavesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Int32StringUnion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
@Override
public void setup() {
super.setup();
- JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
+ final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
registry.onBindingRuntimeContextUpdated(getRuntimeContext());
}
@Test
public void testCaseWithLeafReferencesType() {
- TreeComplexLeaves binding = new TreeComplexLeavesBuilder()
+ final TreeComplexLeaves binding = new TreeComplexLeavesBuilder()
.setIdentity(ThirdParty.class)
.setIdentityRef(ThirdParty.class)
.setSimpleType(10)
.setSchemaUnawareUnion(new Int32StringUnion("foo"))
.setSchemaUnawareUnionRef(new Int32StringUnion(10))
.build();
- Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> dom = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, binding);
- Entry<InstanceIdentifier<?>, DataObject> readed = registry.fromNormalizedNode(dom.getKey(),dom.getValue());
- TreeComplexLeaves readedAugment = ((TreeComplexLeaves) readed.getValue());
+ final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> dom = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, binding);
+ final Entry<InstanceIdentifier<?>, DataObject> readed = registry.fromNormalizedNode(dom.getKey(),dom.getValue());
+ final TreeComplexLeaves readedAugment = ((TreeComplexLeaves) readed.getValue());
assertEquals(binding,readedAugment);
import static org.junit.Assert.assertEquals;
import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.*;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.augmentationBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.HashSet;
import javassist.ClassPool;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment2Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.augment.choice1.Case1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.Case11Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.ChoiceContainer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.ChoiceContainerBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.choice.identifier.ExtendedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.choice.identifier.extended.ExtendedIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.AugmentChoice1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.Case1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.Case11Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.choice.identifier.ExtendedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.choice.identifier.extended.ExtendedIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
public static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
public static final TopLevelListKey TOP_LEVEL_LIST_FOO_KEY = new TopLevelListKey(TOP_LEVEL_LIST_FOO_KEY_VALUE);
- public static final QName TOP_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:binding", "2014-07-01", "top");
+ public static final QName TOP_QNAME = Top.QNAME;
public static final QName TOP_LEVEL_LIST_QNAME = QName.create(TOP_QNAME, "top-level-list");
public static final QName TOP_LEVEL_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name");
public static final QName TOP_LEVEL_LEAF_LIST_QNAME = QName.create(TOP_QNAME, "top-level-leaf-list");
public static final QName NESTED_LIST_QNAME = QName.create(TOP_QNAME, "nested-list");
public static final QName NESTED_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name");
- public static final QName CHOICE_CONTAINER_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:binding", "2014-07-01", "choice-container");
+ public static final QName CHOICE_CONTAINER_QNAME = ChoiceContainer.QNAME;
public static final QName CHOICE_IDENTIFIER_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "identifier");
public static final QName CHOICE_IDENTIFIER_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "id");
public static final QName SIMPLE_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "simple-id");
private BindingNormalizedNodeCodecRegistry registry;
+ @Override
@Before
public void setup() {
super.setup();
- JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
+ final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
registry.onBindingRuntimeContextUpdated(getRuntimeContext());
}
@Test
public void containerToNormalized() {
- Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top());
- ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
+ final ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
.withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
assertEquals(topNormalized, entry.getValue());
@Test
public void containerFromNormalized() {
- ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
+ final ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
.withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
- Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
+ final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
assertEquals(top(), entry.getValue());
}
@Test
public void listWithKeysToNormalized() {
- Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
registry.toNormalizedNode(BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
- MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
+ final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
.withNodeIdentifier(
new YangInstanceIdentifier.NodeIdentifierWithPredicates(
TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
@Test
public void listWithKeysFromNormalized() {
- MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
+ final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
.withNodeIdentifier(
new YangInstanceIdentifier.NodeIdentifierWithPredicates(
TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.build();
- Map.Entry<InstanceIdentifier<?>, DataObject> entry =
+ final Map.Entry<InstanceIdentifier<?>, DataObject> entry =
registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, topLevelListNormalized);
assertEquals(topLevelList(TOP_LEVEL_LIST_FOO_KEY), entry.getValue());
}
@Test
public void leafOnlyAugmentationToNormalized() {
- Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
registry.toNormalizedNode(BA_TREE_LEAF_ONLY, new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
- Set<QName> augmentationChildren = new HashSet<>();
+ final Set<QName> augmentationChildren = new HashSet<>();
augmentationChildren.add(SIMPLE_VALUE_QNAME);
- AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
+ final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren))
.withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
.build();
@Test
public void leafOnlyAugmentationFromNormalized() {
- Set<QName> augmentationChildren = new HashSet<>();
+ final Set<QName> augmentationChildren = new HashSet<>();
augmentationChildren.add(SIMPLE_VALUE_QNAME);
- AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
+ final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren))
.withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
.build();
- Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH.node(
+ final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH.node(
new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren)), augmentationNode);
assertEquals(new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build(), entry.getValue());
}
@Test
public void leafListToNormalized() {
- List<String> topLevelLeafList = new ArrayList<>();
+ final List<String> topLevelLeafList = new ArrayList<>();
topLevelLeafList.add("foo");
- Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
+ final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
- Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
- ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
+ final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
.withChild(ImmutableLeafSetNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
@Test
public void leafListFromNormalized() {
- ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create()
+ final ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
.withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
.withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
new YangInstanceIdentifier.NodeWithValue(TOP_LEVEL_LEAF_LIST_QNAME, "foo")).withValue("foo").build()).build())
.build();
- Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
- List<String> topLevelLeafList = new ArrayList<>();
+ final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
+ final List<String> topLevelLeafList = new ArrayList<>();
topLevelLeafList.add("foo");
- Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
+ final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
assertEquals(top, entry.getValue());
}
@Test
public void choiceToNormalized() {
- ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
+ final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
- Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
registry.toNormalizedNode(InstanceIdentifier.create(ChoiceContainer.class), choiceContainerBA);
- ContainerNode choiceContainer = ImmutableContainerNodeBuilder.create()
+ final ContainerNode choiceContainer = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_CONTAINER_QNAME))
.withChild(ImmutableChoiceNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
.withChild(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(EXTENDED_ID_QNAME))
@Test
public void choiceFromNormalized() {
- ContainerNode choiceContainerBI = ImmutableContainerNodeBuilder.create()
+ final ContainerNode choiceContainerBI = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_CONTAINER_QNAME))
.withChild(ImmutableChoiceNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
.withChild(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(EXTENDED_ID_QNAME))
.withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value")).build()).build())
.build();
- Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH, choiceContainerBI);
- ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
+ final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH, choiceContainerBI);
+ final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
assertEquals(choiceContainerBA, entry.getValue());
}
@Test
public void orderedLisToNormalized() {
- InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
- List<NestedList> nestedLists = new ArrayList<>();
+ final InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
+ final List<NestedList> nestedLists = new ArrayList<>();
nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("foo")).build());
nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("bar")).build());
- TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
- Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(ii, topLevelList);
- MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ final TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(ii, topLevelList);
+ final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(
@Test
public void orderedLisFromNormalized() {
- MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(
ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NESTED_LIST_QNAME))
.withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
.withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
- InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
+ final InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
- Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, foo);
- List<NestedList> nestedLists = new ArrayList<>();
+ final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, foo);
+ final List<NestedList> nestedLists = new ArrayList<>();
nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("foo")).build());
nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("bar")).build());
- TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
+ final TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
assertEquals(topLevelList, entry.getValue());
}
@Test
public void augmentMultipleChoices() {
- QName augmentChoice1QName = QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:augment",
- "2014-07-09", "augment-choice1");
- QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
+ final QName augmentChoice1QName = AugmentChoice1.QNAME;
+ final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
final YangInstanceIdentifier.NodeIdentifier containerId =
new YangInstanceIdentifier.NodeIdentifier(containerQName);
- TopBuilder tBuilder = new TopBuilder();
- TopChoiceAugment1Builder tca1Builder = new TopChoiceAugment1Builder();
- Case1Builder c1Builder = new Case1Builder();
- TopChoiceAugment2Builder tca2Builder = new TopChoiceAugment2Builder();
- Case11Builder c11Builder = new Case11Builder();
- Case11ChoiceCaseContainerBuilder cccc1Builder = new Case11ChoiceCaseContainerBuilder();
+ final TopBuilder tBuilder = new TopBuilder();
+ final TopChoiceAugment1Builder tca1Builder = new TopChoiceAugment1Builder();
+ final Case1Builder c1Builder = new Case1Builder();
+ final TopChoiceAugment2Builder tca2Builder = new TopChoiceAugment2Builder();
+ final Case11Builder c11Builder = new Case11Builder();
+ final Case11ChoiceCaseContainerBuilder cccc1Builder = new Case11ChoiceCaseContainerBuilder();
cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
tca2Builder.setAugmentChoice2(c11Builder.build());
import javassist.ClassPool;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.TwoLevelListChanged;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.TwoLevelListChangedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChanged;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import javassist.ClassPool;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.GetTopOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.GetTopOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.PutTopInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.PutTopInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.GetTopOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.GetTopOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.PutTopInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.PutTopInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>yang-ext</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
package org.opendaylight.controller.md.sal.test.model.util;
import com.google.common.collect.ImmutableList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
+import java.util.Arrays;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyUsesAugmentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUses;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.Arrays;
-
public class ListsBindingUtils {
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
}
public static TopLevelList topLevelList(final TopLevelListKey key, final TreeComplexUsesAugment augment) {
- TopLevelListBuilder builder = new TopLevelListBuilder().setKey(key);
+ final TopLevelListBuilder builder = new TopLevelListBuilder().setKey(key);
builder.addAugmentation(TreeComplexUsesAugment.class, augment);
return builder.build();
}
public static TreeComplexUsesAugment complexUsesAugment(final ListViaUsesKey... keys) {
- ImmutableList.Builder<ListViaUses> listViaUses = ImmutableList.<ListViaUses> builder();
- for (ListViaUsesKey key : keys) {
+ final ImmutableList.Builder<ListViaUses> listViaUses = ImmutableList.<ListViaUses> builder();
+ for (final ListViaUsesKey key : keys) {
listViaUses.add(new ListViaUsesBuilder().setKey(key).build());
}
return new TreeComplexUsesAugmentBuilder().setListViaUses(listViaUses.build()).build();
}
- public static TreeLeafOnlyUsesAugment leafOnlyUsesAugment(String leafFromGroupingValue) {
+ public static TreeLeafOnlyUsesAugment leafOnlyUsesAugment(final String leafFromGroupingValue) {
return new TreeLeafOnlyUsesAugmentBuilder().setLeafFromGrouping(leafFromGroupingValue).build();
}
-/*
- * 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701;
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701;
+
/**
* The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
* In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
* The reason behind putting it under src/main/java is:
* This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
* loss of user code.
+ *
*/
public class Int32StringUnionBuilder {
- public static Int32StringUnion getDefaultInstance(final String defaultValue) {
+ public static Int32StringUnion getDefaultInstance(final java.lang.String defaultValue) {
try {
return new Int32StringUnion(Integer.parseInt(defaultValue));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return new Int32StringUnion(defaultValue);
}
}
-module opendaylight-yangtools-augment-test {
+module opendaylight-mdsal-augment-test {
- namespace "urn:opendaylight:params:xml:ns:yang:yangtools:test:augment";
+ namespace "urn:opendaylight:params:xml:ns:yang:mdsal:test:augment";
prefix aug-test;
- import opendaylight-yangtools-binding-test {
+ import opendaylight-mdsal-binding-test {
prefix test;
}
import yang-ext {
-module opendaylight-yangtools-binding-test {
+module opendaylight-mdsal-binding-test {
- namespace "urn:opendaylight:params:xml:ns:yang:yangtools:test:binding";
+ namespace "urn:opendaylight:params:xml:ns:yang:mdsal:test:binding";
prefix list-test;
namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:of-migration-test-model";
prefix of-migration-test;
- import opendaylight-mdsal-list-test {prefix test;}
+ import opendaylight-mdsal-binding-test {prefix test;}
import yang-ext {prefix ext;}
import opendaylight-mdsal-augment-test {prefix aug;}
import opendaylight-test-routed-rpc {prefix routed;}
<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.controller</groupId>
- <artifactId>sal-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
</parent>
- <artifactId>sal-binding-util</artifactId>
+ <artifactId>mdsal-binding-util</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
</dependencies>
<scm>
import static com.google.common.base.Preconditions.checkNotNull;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.MutableClassToInstanceMap;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.BindingAwareService;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.MutableClassToInstanceMap;
-
public class BindingContextUtils {
- public static ConsumerContext createConsumerContext(BindingAwareConsumer consumer,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ public static ConsumerContext createConsumerContext(final BindingAwareConsumer consumer,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
checkNotNull(consumer,"Consumer should not be null");
checkNotNull(serviceProvider,"Service map should not be null");
return new SingleConsumerContextImpl(serviceProvider);
}
- public static ProviderContext createProviderContext(BindingAwareProvider provider,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ public static ProviderContext createProviderContext(final BindingAwareProvider provider,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
checkNotNull(provider,"Provider should not be null");
checkNotNull(serviceProvider,"Service map should not be null");
return new SingleProviderContextImpl(serviceProvider);
}
- public static ConsumerContext createConsumerContextAndInitialize(BindingAwareConsumer consumer,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
- ConsumerContext context = createConsumerContext(consumer, serviceProvider);
+ public static ConsumerContext createConsumerContextAndInitialize(final BindingAwareConsumer consumer,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ final ConsumerContext context = createConsumerContext(consumer, serviceProvider);
consumer.onSessionInitialized(context);
return context;
}
- public static ProviderContext createProviderContextAndInitialize(BindingAwareProvider provider,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
- ProviderContext context = createProviderContext(provider, serviceProvider);
+ public static ProviderContext createProviderContextAndInitialize(final BindingAwareProvider provider,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ final ProviderContext context = createProviderContext(provider, serviceProvider);
provider.onSessionInitiated(context);
return context;
}
- public static <T extends BindingAwareService> T createContextProxyOrReturnService(Class<T> service, T instance) {
+ public static <T extends BindingAwareService> T createContextProxyOrReturnService(final Class<T> service, final T instance) {
// FIXME: Create Proxy
return instance;
}
private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
private ClassToInstanceMap<BindingAwareService> serviceProvider;
- public SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ public SingleConsumerContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
this.serviceProvider = serviceProvider;
}
@Override
- public final <T extends RpcService> T getRpcService(Class<T> module) {
+ public final <T extends RpcService> T getRpcService(final Class<T> module) {
return getSALService(RpcConsumerRegistry.class).getRpcService(module);
}
@Override
- public final <T extends BindingAwareService> T getSALService(Class<T> service) {
+ public final <T extends BindingAwareService> T getSALService(final Class<T> service) {
checkNotNull(service,"Service class should not be null.");
- T potential = alreadyRetrievedServices.getInstance(service);
+ final T potential = alreadyRetrievedServices.getInstance(service);
if(potential != null) {
return potential;
}
return tryToRetrieveSalService(service);
}
- private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(Class<T> service) {
+ private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(final Class<T> service) {
final T potential = alreadyRetrievedServices.getInstance(service);
if(potential != null) {
return potential;
private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
- public SingleProviderContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ public SingleProviderContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
super(serviceProvider);
}
@Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- L listener) {
- return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type,
- T implementation) throws IllegalStateException {
+ public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
+ final T implementation) throws IllegalStateException {
return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
}
@Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
+ public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T implementation)
throws IllegalStateException {
return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
}
<module>mdsal-binding-generator-impl</module>
<module>mdsal-binding-java-api-generator</module>
<module>maven-sal-api-gen-plugin</module>
- <module>mdsal-binding-test-model</module>
- <module>mdsal-binding-dom-codec</module>
<!-- FIXME: should be probably renamed to mdsal-model-binding-parent -->
<module>binding-parent</module>
<module>yang-binding</module>
+
+ <module>mdsal-binding-test-model</module>
+ <module>mdsal-binding-dom-codec</module>
+
+ <module>mdsal-binding-api</module>
+ <module>mdsal-binding-util</module>
+ <module>mdsal-binding-dom-adapter</module>
</modules>
</project>
+++ /dev/null
-/*
- * 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.controller.md.sal.test.model.util;
-
-import com.google.common.collect.ImmutableList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedListKey;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import java.util.Arrays;
-
-public class ListsBindingUtils {
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
-
- private ListsBindingUtils() {
- throw new UnsupportedOperationException();
- }
-
- public static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
- public static final TopLevelListKey TOP_BAR_KEY = new TopLevelListKey("bar");
- public static final ListViaUsesKey USES_ONE_KEY = new ListViaUsesKey("one");
- public static final ListViaUsesKey USES_TWO_KEY = new ListViaUsesKey("two");
-
-
- public static InstanceIdentifier<TopLevelList> path(final TopLevelListKey key) {
- return TOP_PATH.child(TopLevelList.class, key);
- }
-
- public static InstanceIdentifier<NestedList> path(final TopLevelListKey top,final NestedListKey nested) {
- return path(top).child(NestedList.class, nested);
- }
-
- public static InstanceIdentifier<ListViaUses> path(final TopLevelListKey top,final ListViaUsesKey uses) {
- return path(top).augmentation(TreeComplexUsesAugment.class).child(ListViaUses.class, uses);
- }
-
- public static <T extends DataObject & Augmentation<TopLevelList>> InstanceIdentifier<T> path(final TopLevelListKey key, final Class<T> augmentation) {
- return path(key).augmentation(augmentation);
- }
-
- public static Top top(final TopLevelList... listItems) {
- return new TopBuilder().setTopLevelList(Arrays.asList(listItems)).build();
- }
-
- public static TopLevelList topLevelList(final TopLevelListKey key) {
- return new TopLevelListBuilder().setKey(key).build();
- }
-
- public static TopLevelList topLevelList(final TopLevelListKey key, final TreeComplexUsesAugment augment) {
- TopLevelListBuilder builder = new TopLevelListBuilder().setKey(key);
- builder.addAugmentation(TreeComplexUsesAugment.class, augment);
- return builder.build();
- }
-
- public static TreeComplexUsesAugment complexUsesAugment(final ListViaUsesKey... keys) {
- ImmutableList.Builder<ListViaUses> listViaUses = ImmutableList.<ListViaUses> builder();
- for (ListViaUsesKey key : keys) {
- listViaUses.add(new ListViaUsesBuilder().setKey(key).build());
- }
- return new TreeComplexUsesAugmentBuilder().setListViaUses(listViaUses.build()).build();
- }
-
- public static TreeLeafOnlyUsesAugment leafOnlyUsesAugment(String leafFromGroupingValue) {
-
- return new TreeLeafOnlyUsesAugmentBuilder().setLeafFromGrouping(leafFromGroupingValue).build();
- }
-
-}
+++ /dev/null
-module opendaylight-mdsal-augment-test {
-
- namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:augment";
- prefix aug-test;
-
- import opendaylight-mdsal-list-test {
- prefix test;
- }
- import yang-ext {
- prefix ext;
- }
-
- description
- "This module contains a collection of YANG augmentations used for
- some test cases.";
-
- revision 2014-07-09 {
- description
- "Test model for testing data broker with nested lists.";
- }
-
- grouping leaf-from-grouping {
- leaf leaf-from-grouping {
- type string;
- }
- }
-
- grouping complex-from-grouping {
- container container-with-uses {
- uses leaf-from-grouping;
- }
- list list-via-uses {
- key "name";
- leaf name {
- type string;
- }
- }
-
- }
-
- augment "/test:top/test:top-level-list" {
- ext:augment-identifier tree-leaf-only-uses-augment;
- uses leaf-from-grouping;
- }
-
- augment "/test:put-top/test:input/test:top-level-list" {
- ext:augment-identifier rpc-leaf-only-uses-augment;
- uses leaf-from-grouping;
- }
-
- augment "/test:top/test:top-level-list" {
- ext:augment-identifier tree-complex-uses-augment;
- uses complex-from-grouping;
- }
-
- augment "/test:put-top/test:input/test:top-level-list" {
- ext:augment-identifier rpc-complex-uses-augment;
- uses complex-from-grouping;
- }
-
- augment "/test:top/test:top-level-list" {
- ext:augment-identifier tree-leaf-only-augment;
-
- leaf simple-value {
- type string;
- }
- }
-
- augment "/test:top/test:top-level-list" {
- ext:augment-identifier tree-second-leaf-only-augment;
-
- leaf second-simple-value {
- type string;
- }
- }
-
- augment "/test:put-top/test:input/test:top-level-list" {
- ext:augment-identifier rpc-leaf-only-augment;
-
- leaf simple-value {
- type string;
- }
- }
-
- augment "/test:put-top/test:input/test:top-level-list" {
- ext:augment-identifier rpc-second-leaf-only-augment;
-
- leaf second-simple-value {
- type string;
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-module opendaylight-mdsal-list-test {
-
- namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:list";
- prefix list-test;
-
-
- description
- "This module contains a collection of YANG definitions used for
- some test cases.";
-
- revision 2014-07-01 {
- description
- "Test model for testing data broker with nested lists.";
- }
-
- grouping two-level-list {
- list top-level-list {
- description
- "Top Level List";
- key "name";
- leaf name {
- type string;
- }
- list nested-list {
- key "name";
- leaf name {
- type string;
- }
- leaf type {
- type string;
- mandatory true;
- description
- "Mandatory type of list.";
- }
- ordered-by user;
- description
- "A list of service functions that compose the service chain";
- }
- }
- }
-
- container top {
- uses two-level-list;
- }
-
- notification two-level-list-changed {
- uses two-level-list;
- }
-
- rpc put-top {
- input {
- uses two-level-list;
- }
- }
-}
+++ /dev/null
-/*
- * 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.api;
-
-import org.osgi.framework.BundleContext;
-
-@Deprecated
-public abstract class AbstractBindingAwareConsumer extends AbstractBrokerAwareActivator implements BindingAwareConsumer {
-
- @Override
- protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
- broker.registerConsumer(this, context);
- }
-
-}
+++ /dev/null
-/*
- * 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.api;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.osgi.framework.BundleContext;
-
-@Deprecated
-public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator implements BindingAwareProvider {
-
- @Override
- protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
- ProviderContext ctx = broker.registerProvider(this, context);
- }
-}
+++ /dev/null
-/*
- * 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.api;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-
-/**
-*
-* A developer implemented component that gets registered with the Broker.
-*
-* Semantically, a consumer may:
-*
-* <ol>
-* <li>Subscribe for Notifications </li>
-* <li>Invoke RPCs</li>
-* <li>Read from either the operational or config data tree</li>
-* <li>Write to the config data tree</li>
-* </ol>
-* If you need to:
-* <ol>
-* <li> Emit Notifications</li>
-* <li> Provide the implementation of RPCs </li>
-* <li> Write to the operational data tree </li>
-* </ol>
-*
-* Consider using a BindingAwareProvider
-*
-* Examples:
-*
-* To get a NotificationService:
-*
-* {code
-* public void onSessionInitiated(ProviderContext session) {
-* NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
-* notificationService.publish(notification)
-* }
-* where notification is an instance of a modeled Notification.
-* For more information on sending notifications via the NotificationProviderService
-* @see org.opendaylight.controller.sal.binding.api.NotificationProviderService
-*
-*
-* A consumer can *invoke* and RPC ( ie, call foo(fooArgs)) but it cannot register an RPC
-* implementation with the MD-SAL that others can invoke(call).
-* To get an invokable RPC:
-*
-* {code
-* public void onSessionInitiated(ProviderContext session) {
-* MyService rpcFlowSalService = session.getRpcService(MyService.class);
-* }
-*
-* Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it. The returned
-* rpcFlowSalService can be used like any other object by invoking its methods. Note, nothing special needs to be done
-* for RoutedRPCs. They just work.
-*
-* To get a DataBroker to allow access to the data tree:
-*
-* {code
-* public void onSessionInitiated(final ProviderContext session) {
-* DataBroker databroker = session.getSALService(BindingDataBroker.class);
-* }
-* }
-* @see org.opendaylight.controller.md.sal.common.api.data.BindingDataBroker
-* for more info on using the DataBroker.
-*
-*/
-public interface BindingAwareConsumer {
-
- /**
- * Callback signaling initialization of the consumer session to the SAL.
- *
- * The consumer MUST use the session for all communication with SAL or
- * retrieving SAL infrastructure services.
- *
- * This method is invoked by
- * {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
- *
- * @param session
- * Unique session between consumer and SAL.
- */
- void onSessionInitialized(ConsumerContext session);
-
-}
+++ /dev/null
-/*
- * 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.api;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-
-/**
- *
- * A developer implemented component that gets registered with the Broker.
- *
- * Semantically, a provider may:
- *
- * <ol>
- * <li> Emit Notifications</li>
- * <li> Provide the implementation of RPCs </li>
- * <li> Write to the operational data tree </li>
- * </ol>
- *
- * If a class is not doing at least one of those three, consider using
- * a BindingAwareConsumer instead:
- * @see org.opendaylight.controller.sal.binding.api.BindingAwareConsumer
- *
- * <p>
- *
- *In addition, a BindingAwareProvider can in pursuit of its goals:
- *
- * <ol>
- * <li>Subscribe for Notifications </li>
- * <li>Invoke RPCs</li>
- * <li>Read from either the operational or config data tree</li>
- * <li>Write to the config data tree</li>
- * </ol>
- * (All of the above are things a Consumer can also do).
- *
- *<p>
- *
- * Examples:
- *
- *<p>
- *
- * To get a NotificationService:
- *
- * {code
- * public void onSessionInitiated(ProviderContext session) {
- * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
- * }
- * For more information on sending notifications via the NotificationProviderService
- * @see org.opendaylight.controller.sal.binding.api.NotificationProviderService
- *
- * To register an RPC implementation:
- *
- * {code
- * public void onSessionInitiated(ProviderContext session) {
- * RpcRegistration<MyService> registration = session.addRpcImplementation(MyService.class, myImplementationInstance);
- * }
- *
- * <p>
- *
- * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it and myImplementationInstance
- * is an instance of a class that implements MyService.
- *
- * To register a Routed RPC Implementation:
- * {code
- * public void onSessionInitiated(ProviderContext session) {
- * RoutedRpcRegistration<SalFlowService> flowRegistration = session.addRoutedRpcImplementation(SalFlowService.class, salFlowServiceImplementationInstance);
- flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
- * }
- * }
- *
- * Where SalFlowService.class is a Service interface generated from a yang model with RPCs modeled in it and salFlowServiceImplementationInstance is an instance
- * of a class that implements SalFlowService.
- * <p>
- * The line:
- * {code
- * flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
- * }
- * Is indicating that the RPC implementation is registered to handle RPC invocations that have their NodeContext pointing to the node with instance id nodeInstanceId.
- * This bears a bit of further explanation. RoutedRPCs can be 'routed' to an implementation based upon 'context'. 'context' is a pointer (instanceId) to some place
- * in the data tree. In this example, the 'context' is a pointer to a Node. In this way, a provider can register its ability to provide a service for a particular
- * Node, but not *all* Nodes. The Broker routes the RPC by 'context' to the correct implementation, without the caller having to do extra work. Because of this when
- * a RoutedRPC is registered, it needs to also be able to indicate for which 'contexts' it is providing an implementation.
- *
- * An example of a Routed RPC would be an updateFlow(node, flow) that would be routed based on node to the provider which had registered to provide
- * it *for that node*.
- *
- *<p>
- *
- * To get a DataBroker to allow access to the data tree:
- *
- * {code
- * public void onSessionInitiated(final ProviderContext session) {
- * DataBroker databroker = session.getSALService(BindingDataBroker.class);
- * }
- * }
- * @see org.opendaylight.controller.md.sal.common.api.data.BindingDataBroker
- * for more info on using the DataBroker.
- *
- */
-public interface BindingAwareProvider {
-
- /**
- * Callback signaling initialization of the consumer session to the SAL.
- *
- * The consumer MUST use the session for all communication with SAL or
- * retrieving SAL infrastructure services.
- *
- * This method is invoked by
- * {@link BindingAwareBroker#registerProvider(BindingAwareProvider)}
- *
- * @param session Unique session between consumer and SAL.
- */
- void onSessionInitiated(ProviderContext session);
-}
+++ /dev/null
-/*
- * 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.api;
-
-import java.util.EventListener;
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Interface for a notification service that provides publish/subscribe capabilities for YANG
- * modeled notifications. This interface is a combination of the {@link NotificationService} and
- * {@link NotificationPublishService} interfaces.
- *
- * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.NotificationPublishService}.
- */
-@Deprecated
-public interface NotificationProviderService extends NotificationService, NotificationPublishService<Notification> {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void publish(Notification notification);
-
- /**
- * {@inheritDoc}
- */
- @Override
- void publish(Notification notification, ExecutorService executor);
-
- /**
- * Registers a listener to be notified about notification subscriptions. This
- * enables a component to know when there is a notification listener subscribed
- * for a particular notification type.
- * <p>
- * On registration of this listener, the
- * {@link NotificationInterestListener#onNotificationSubscribtion(Class)} method
- * will be invoked for every notification type that currently has a notification listener
- * subscribed.
- *
- * @param interestListener the listener that will be notified when subscriptions
- * for new notification types occur.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- ListenerRegistration<NotificationInterestListener> registerInterestListener(
- NotificationInterestListener interestListener);
-
- /**
- * Interface for a listener interested in being notified about notification subscriptions.
- */
- public interface NotificationInterestListener extends EventListener {
-
- /**
- * Callback that is invoked when a notification listener subscribes for a
- * particular notification type.
- * <p>
- * This method is only called for the first subscription that occurs for a
- * particular notification type. Subsequent subscriptions for the same
- * notification type do not trigger invocation of this method.
- * <p>
- * <b>Note:</b>This callback is delivered from thread not owned by this listener,
- * all processing should be as fast as possible and implementations should
- * not do any blocking calls or block this thread.
- *
- * @param notificationType the notification type for the subscription that occurred.
- */
- void onNotificationSubscribtion(Class<? extends Notification> notificationType);
- }
-}
+++ /dev/null
-/*
- * 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.api;
-
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Notification broker which allows clients to subscribe for and publish YANG-modeled notifications.
- *
- *<p>
- * Two styles of listeners are supported:
- * <ul>
- * <li>Generic listener</li>
- * <li>Dispatch listener - listener, which implements <code>{ModelName}Listener</code> interface,
- * which has dispatch methods for each defined notification. Methods are invoked based on notification type (class).
- * </li>
- *
- * <h3>Generic Listener</h3>
- * <p>
- * A generic listener implements the {@link NotificationListener} interface which has one callback method
- * <code>onNotification</code> that is invoked for any notification type the listener is subscribed to.
- * <p>
- * A generic listener is subscribed using the {@link #registerNotificationListener(Class, NotificationListener)}
- * method by which you specify the type of notification to receive. A generic listener may be registered for
- * multiple notification types via multiple subscriptions.
- * <p>
- * Generic listeners allow for a more flexible approach, allowing you to subscribe for just
- * one type of notification from a YANG model. You could also have a general subscription
- * for all notification in the system via
- * <pre>
- * service.registerNotificationListener(Notification.class, listener);
- * </pre>
- *
- * <h3>Dispatch Listener</h3>
- * <p>
- * A dispatch listener implements a YANG-generated module interface <code>{ModuleName}Listener</code>
- * which handles all the notifications defined in the YANG model. Each notification type translates to
- * a specific method of the form <code>on{NotificationType}</code> on the generated interface.
- * The generated interface also extends the
- * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations
- * are registered using {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)}
- * method.
- *
- * <h5>Dispatch Listener Example</h5>
- * <p>
- * Lets assume we have following YANG model:
- *
- * <pre>
- * module example {
- * ...
- *
- * notification start {
- * ...
- * }
- *
- * notification stop {
- * ...
- * }
- * }
- * </pre>
- *
- * The generated interface will be:
- * <pre>
- * public interface ExampleListener extends NotificationListener {
- * void onStart(Start notification);
- * void onStop(Stop notification);
- * }
- * </pre>
- * The following defines an implementation of the generated interface:
- * <pre>
- * public class MyExampleListener implements ExampleListener {
- * public void onStart(Start notification) {
- * // do something
- * }
- *
- * public void onStop(Stop notification) {
- * // do something
- * }
- * }
- * </pre>
- * The implementation is registered as follows:
- * <pre>
- * MyExampleListener listener = new MyExampleListener();
- * ListenerRegistration<NotificationListener> reg = service.registerNotificationListener( listener );
- * </pre>
- * The <code>onStart</code> method will be invoked when someone publishes a <code>Start</code> notification and
- * the <code>onStop</code> method will be invoked when someone publishes a <code>Stop</code> notification.
- *
- * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.NotificationService} instead.
- */
-@Deprecated
-public interface NotificationService extends BindingAwareService {
- /**
- * Registers a generic listener implementation for a specified notification type.
- *
- * @param notificationType the YANG-generated interface of the notification type.
- * @param listener the listener implementation that will receive notifications.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- Class<T> notificationType, NotificationListener<T> listener);
-
- /**
- * Registers a listener which implements a YANG-generated notification interface derived from
- * {@link org.opendaylight.yangtools.yang.binding.NotificationListener}.
- * The listener is registered for all notifications present in the implemented interface.
- *
- * @param listener the listener implementation that will receive notifications.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
- org.opendaylight.yangtools.yang.binding.NotificationListener listener);
-}
+++ /dev/null
-/*
- * 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.api.data;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangePublisher;
-import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransactionFactory;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * DataBrokerService provides unified access to the data stores available in the
- * system.
- *
- *
- * @see DataProviderService
- * @deprecated Replaced by newer better documented version {@link org.opendaylight.controller.md.sal.binding.api.DataBroker}
- */
-@Deprecated
-public interface DataBrokerService extends //
- BindingAwareService, //
- DataModificationTransactionFactory<InstanceIdentifier<? extends DataObject>, DataObject>, //
- DataReader<InstanceIdentifier<? extends DataObject>, DataObject>, //
- DataChangePublisher<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> {
- /**
- * Creates a data modification transaction.
- *
- * @return new blank data modification transaction.
- * @deprecated Replaced by more specific transaction types. Please use
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadOnlyTransaction(),
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadWriteTransaction()
- * or
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newWriteOnlyTransaction().
- */
- @Deprecated
- @Override
- DataModificationTransaction beginTransaction();
-
- /**
- * Reads data subtree from configurational store.
- * (Store which is populated by consumer, which is usually used to
- * inject state into providers. E.g. Flow configuration)
- *
- *
- * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadOnlyTransaction()}
- *
- */
- @Deprecated
- @Override
- public DataObject readConfigurationData(InstanceIdentifier<? extends DataObject> path);
-
- /**
- * Reads data subtree from operational store.
- * (Store which is populated by providers, which is usually used to
- * capture state of providers. E.g. Topology)
- *
- * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadOnlyTransaction()}
- */
- @Deprecated
- @Override
- public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path);
-
- /**
- * Register a data change listener for particular subtree.
- *
- * Callback is invoked each time data in subtree changes.
- *
- * @deprecated Please use {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#registerDataChangeListener(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, InstanceIdentifier, org.opendaylight.controller.md.sal.binding.api.DataChangeListener, org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope)}
- * which provides more fine-grained registration options.
- */
- @Deprecated
- @Override
- public ListenerRegistration<DataChangeListener> registerDataChangeListener(
- InstanceIdentifier<? extends DataObject> path, DataChangeListener listener);
-}
+++ /dev/null
-/*
- * 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.api.data;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- *
- * @deprecated Replaced by {@link org.opendaylight.controller.md.sal.binding.api.DataChangeListener}
- *
- */
-@Deprecated
-public interface DataChangeListener extends
- org.opendaylight.controller.md.sal.common.api.data.DataChangeListener<InstanceIdentifier<? extends DataObject>, DataObject> {
-
- @Override
- public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change);
-}
+++ /dev/null
-/*
- * 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.api.data;
-
-import java.util.EventListener;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-/**
- *
- *
- * @deprecated Replaced by more specific transaction types. Please use
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadOnlyTransaction(),
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadWriteTransaction()
- * or
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newWriteOnlyTransaction().
- *
- *
- */
-@Deprecated
-public interface DataModificationTransaction extends DataModification<InstanceIdentifier<? extends DataObject>, DataObject> {
- /**
- * Returns an unique identifier for transaction
- *
- */
- @Override
- Object getIdentifier();
-
- /**
- * Initiates a two-phase commit of candidate data.
- *
- * <p>
- * The {@link Consumer} could initiate a commit of candidate data
- *
- * <p>
- * The successful commit changes the state of the system and may affect
- * several components.
- *
- * <p>
- * The effects of successful commit of data are described in the
- * specifications and YANG models describing the {@link Provider} components
- * of controller. It is assumed that {@link Consumer} has an understanding
- * of this changes.
- *
- *
- * @see org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler for further information how two-phase commit is
- * processed.
- * @param store
- * Identifier of the store, where commit should occur.
- * @return Result of the commit, containing success information or list of
- * encountered errors, if commit was not successful.
- */
- @Override
- Future<RpcResult<TransactionStatus>> commit();
-
- /**
- * Register a listener for transaction
- *
- * @param listener
- * @return
- */
- ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener);
-
- /**
- * Listener for transaction state changes
- */
- public interface DataTransactionListener extends EventListener {
- /**
- * Callback is invoked after each transaction status change.
- *
- * @param transaction Transaction
- * @param status New status
- */
- void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status);
- }
-}
+++ /dev/null
-/*
- * 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.api.data;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataProvisionService;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * DataProviderService is common access point for {@link org.opendaylight.controller.sal.binding.api.BindingAwareProvider} providers
- * to access data trees described by the YANG model.
- *
- * @deprecated Replaced by {@link org.opendaylight.controller.md.sal.common.api.data.AsyncConfigurationCommitCoordinator} service.
- */
-@Deprecated
-public interface DataProviderService extends DataBrokerService, DataProvisionService<InstanceIdentifier<? extends DataObject>, DataObject> {
- /**
- * Registers a data reader for particular subtree of overal YANG data tree.
- *
- * Registered data reader is called if anyone tries to read data from
- * paths which are nested to provided path.
- *
- * @param path Subpath which is handled by registered data reader
- * @param reader Instance of reader which
- * @return Registration object for reader. Invoking {@link Registration#close()} will unregister reader.
- * @deprecated Data Reader contract is removed from capabilities of MD-SAL and is replaced by replaced by org.opendaylight.controller.sal.core.spi.data.DOMStore contract.
- */
- @Deprecated
- Registration registerDataReader(InstanceIdentifier<? extends DataObject> path,DataReader<InstanceIdentifier<? extends DataObject>,DataObject> reader);
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.api.data;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Synchronized wrapper for DataModificationTransaction.
- *
- * To get instance of synchronized wrapper use {@link #from(DataModificationTransaction)}
- *
- * @deprecated Replaced by more specific transaction types. Please use
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadOnlyTransaction(),
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadWriteTransaction()
- * or
- * {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newWriteOnlyTransaction().
- *
- */
-@Deprecated
-public final class SynchronizedTransaction implements DataModificationTransaction,Delegator<DataModificationTransaction> {
-
- private final DataModificationTransaction delegate;
-
- private SynchronizedTransaction(final DataModificationTransaction delegate) {
- this.delegate = delegate;
- }
-
- /**
- * Returns synchronized wrapper on supplied transaction.
- *
- * @param transaction Transaction for which synchronized wrapper should be created.
- * @return Synchronized wrapper over transaction.
- */
- public static final SynchronizedTransaction from(final DataModificationTransaction transaction) {
- Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
- if (transaction instanceof SynchronizedTransaction) {
- return (SynchronizedTransaction) transaction;
- }
- return new SynchronizedTransaction(transaction);
- }
-
- @Override
- public synchronized Map<InstanceIdentifier<? extends DataObject>, DataObject> getCreatedOperationalData() {
- return delegate.getCreatedOperationalData();
- }
-
- @Override
- public synchronized Map<InstanceIdentifier<? extends DataObject>, DataObject> getCreatedConfigurationData() {
- return delegate.getCreatedConfigurationData();
- }
-
- @Override
- public synchronized DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
- return delegate.readOperationalData(path);
- }
-
- @Override
- public synchronized TransactionStatus getStatus() {
- return delegate.getStatus();
- }
-
- @Override
- public synchronized Map<InstanceIdentifier<? extends DataObject>, DataObject> getUpdatedOperationalData() {
- return delegate.getUpdatedOperationalData();
- }
-
- @Override
- public synchronized Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public synchronized DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
- return delegate.readConfigurationData(path);
- }
-
- @Override
- public synchronized Future<RpcResult<TransactionStatus>> commit() {
- return delegate.commit();
- }
-
- @Override
- public synchronized void putOperationalData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
- delegate.putOperationalData(path, data);
- }
-
- @Override
- public synchronized void putConfigurationData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
- delegate.putConfigurationData(path, data);
- }
-
- @Override
- public synchronized Map<InstanceIdentifier<? extends DataObject>, DataObject> getUpdatedConfigurationData() {
- return delegate.getUpdatedConfigurationData();
- }
-
- @Override
- public synchronized void removeOperationalData(final InstanceIdentifier<? extends DataObject> path) {
- delegate.removeOperationalData(path);
- }
-
- @Override
- public synchronized void removeConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
- delegate.removeConfigurationData(path);
- }
-
- @Override
- public synchronized Set<InstanceIdentifier<? extends DataObject>> getRemovedConfigurationData() {
- return delegate.getRemovedConfigurationData();
- }
-
- @Override
- public synchronized Set<InstanceIdentifier<? extends DataObject>> getRemovedOperationalData() {
- return delegate.getRemovedOperationalData();
- }
-
- @Override
- public synchronized Map<InstanceIdentifier<? extends DataObject>, DataObject> getOriginalConfigurationData() {
- return delegate.getOriginalConfigurationData();
- }
-
- @Override
- public synchronized ListenerRegistration<DataTransactionListener> registerListener(final DataTransactionListener listener) {
- return delegate.registerListener(listener);
- }
-
- @Override
- public synchronized Map<InstanceIdentifier<? extends DataObject>, DataObject> getOriginalOperationalData() {
- return delegate.getOriginalOperationalData();
- }
-
- @Override
- public synchronized DataModificationTransaction getDelegate() {
- return delegate;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((delegate == null) ? 0 : delegate.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()){
- return false;
- }
- SynchronizedTransaction other = (SynchronizedTransaction) obj;
- if (delegate == null) {
- if (other.delegate != null) {
- return false;
- }
- } else if (!delegate.equals(other.delegate)) {
- return false;
- }
- return true;
- }
-}
-
+++ /dev/null
-/*
- * 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.api.mount;
-
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public interface MountInstance //
- extends //
- RpcConsumerRegistry, //
- Identifiable<InstanceIdentifier<?>>, //
- NotificationService, //
- DataBrokerService {
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.api.mount;
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-
-/**
- * Provider's version of Mount Point, this version allows access to MD-SAL
- * services specific for this mountpoint and registration / provision of
- * interfaces for mount point.
- *
- * @author ttkacik
- *
- */
-public interface MountProviderInstance //
- extends //
- MountInstance, //
- DataProviderService, //
- RpcProviderRegistry, //
- NotificationProviderService {
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.api.mount;
-
-import java.util.EventListener;
-
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Provider MountProviderService, this version allows access to MD-SAL services
- * specific for this mountpoint and registration / provision of interfaces for
- * mount point.
- *
- * @author ttkacik
- *
- */
-public interface MountProviderService extends MountService {
-
- @Override
- public MountProviderInstance getMountPoint(InstanceIdentifier<?> path);
-
- MountProviderInstance createMountPoint(InstanceIdentifier<?> path);
-
- MountProviderInstance createOrGetMountPoint(InstanceIdentifier<?> path);
-
- ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener);
-
- public interface MountProvisionListener extends EventListener {
-
- void onMountPointCreated(InstanceIdentifier<?> path);
-
- void onMountPointRemoved(InstanceIdentifier<?> path);
-
- }
-}
+++ /dev/null
-/*
- * 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.api.mount;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public interface MountService extends BindingAwareService {
-
- MountInstance getMountPoint(InstanceIdentifier<?> path);
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.api.rpc;
-
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-public final class RpcContextIdentifier implements Immutable{
-
- public final Class<? extends RpcService> rpcService;
- public final Class<? extends BaseIdentity> routingContext;
-
- private RpcContextIdentifier(Class<? extends RpcService> rpcService, Class<? extends BaseIdentity> routingContext) {
- super();
- this.rpcService = rpcService;
- this.routingContext = routingContext;
- }
-
- public Class<? extends RpcService> getRpcService() {
- return rpcService;
- }
-
- public Class<? extends BaseIdentity> getRoutingContext() {
- return routingContext;
- }
-
- public static final RpcContextIdentifier contextForGlobalRpc(Class<? extends RpcService> serviceType) {
- return new RpcContextIdentifier(serviceType, null);
- }
-
- public static final RpcContextIdentifier contextFor(Class<? extends RpcService> serviceType,Class<? extends BaseIdentity> routingContext) {
- return new RpcContextIdentifier(serviceType, routingContext);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((routingContext == null) ? 0 : routingContext.hashCode());
- result = prime * result + ((rpcService == null) ? 0 : rpcService.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- RpcContextIdentifier other = (RpcContextIdentifier) obj;
- if (routingContext == null) {
- if (other.routingContext != null)
- return false;
- } else if (!routingContext.equals(other.routingContext))
- return false;
- if (rpcService == null) {
- if (other.rpcService != null)
- return false;
- } else if (!rpcService.equals(other.rpcService))
- return false;
- return true;
- }
-
-}
+++ /dev/null
-/*
- * 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.api.rpc;
-
-import java.util.Set;
-
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-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
- * overall 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> extends //
- RouteChangePublisher<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
-
- /**
- * 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> getServiceType();
-
-
- /**
- * Returns a instance of T which is associated with this router instance
- * and routes messages based on routing tables.
- *
- * @return type of RpcService which is served by this instance of router.
- */
- T getInvocationProxy();
-
- /**
- * 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();
-
- Set<Class<? extends BaseIdentity>> getContexts();
-
- RoutedRpcRegistration<T> addRoutedRpcImplementation(T service);
-
- RpcRegistration<T> registerDefaultService(T service);
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.api.rpc;
-
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-public interface RpcRoutingContext<C extends BaseIdentity,S extends RpcService> {
-
- Class<C> getContextType();
- Class<S> getServiceType();
-}
+++ /dev/null
-/*
- * 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.api.rpc;
-
-import java.util.Map;
-
-import org.opendaylight.controller.md.sal.common.api.routing.MutableRoutingTable;
-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> extends
- MutableRoutingTable<Class<? extends C>, InstanceIdentifier<?>, S> {
-
- Class<C> getIdentifier();
-
- /**
- * 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 removeRoute(InstanceIdentifier<?> path);
-
- /**
- *
- */
- S getRoute(InstanceIdentifier<?> nodeInstance);
-
- /**
- *
- * @return
- */
- Map<InstanceIdentifier<?>, S> getRoutes();
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.compat;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Abstract implementation of {@link NotificationListenerRegistration}.
- *
- * @param <T> Notification type
- */
-abstract class AbstractNotificationListenerRegistration<T extends Notification> extends AbstractListenerRegistration<NotificationListener<T>> implements NotificationListenerRegistration<T> {
- private final Class<? extends Notification> type;
-
- protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type, final NotificationListener<T> listener) {
- super(listener);
- this.type = Preconditions.checkNotNull(type);
- }
-
- @Override
- public Class<? extends Notification> getType() {
- return type;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void notify(final Notification notification) {
- if (!isClosed()) {
- getInstance().onNotification((T)notification);
- }
- }
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.compat;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * An aggregated listener registration. This is a result of registering an invoker which can handle multiple
- * interfaces at the same time. In order to support correct delivery, we need to maintain per-type registrations
- * which get squashed if a notification which implements multiple interfaces is encountered.
- *
- * We take care of that by implementing alternate {@link #hashCode()}/{@link #equals(Object)}, which resolve
- * to the backing aggregator.
- *
- * @param <N> Notification type
- * @param <A> Aggregator type
- */
-abstract class AggregatedNotificationListenerRegistration<N extends Notification, A> extends AbstractNotificationListenerRegistration<N> {
- private final A aggregator;
-
- protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type, final NotificationListener<N> listener, final A aggregator) {
- super(type, listener);
- this.aggregator = Preconditions.checkNotNull(aggregator);
- }
-
- protected A getAggregator() {
- return aggregator;
- }
-
- @Override
- public int hashCode() {
- return aggregator.hashCode();
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!this.getClass().equals(obj.getClass())) {
- return false;
- }
-
- return aggregator.equals(((AggregatedNotificationListenerRegistration<?, ?>)obj).aggregator);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-final class CompositeRoutedRpcRegistration<T extends RpcService> implements RoutedRpcRegistration<T> {
-
- private final Class<T> type;
- private final T instance;
- private final BindingDOMRpcProviderServiceAdapter adapter;
- private final Map<InstanceIdentifier<?>, ObjectRegistration<T>> registrations = new HashMap<>(2);
-
- CompositeRoutedRpcRegistration(final Class<T> type, final T impl, final BindingDOMRpcProviderServiceAdapter providerAdapter) {
- this.type = type;
- this.instance = impl;
- this.adapter = providerAdapter;
- }
-
- @Override
- public Class<T> getServiceType() {
- return type;
- }
-
- @Override
- public T getInstance() {
- return instance;
- }
-
- @Deprecated
- @Override
- public void registerInstance(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- registerPath(context, path);
- }
-
- @Override
- public synchronized void registerPath(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- if(!registrations.containsKey(path)) {
- registrations.put(path, adapter.registerRpcImplementation(type, instance, ImmutableSet.<InstanceIdentifier<?>>of(path)));
- }
- }
-
-
- @Override
- @Deprecated
- public void unregisterInstance(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- unregisterPath(context, path);
- }
-
- @Override
- public synchronized void unregisterPath(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- final ObjectRegistration<T> reg = registrations.remove(path);
- if(reg != null) {
- try {
- reg.close();
- } catch (final Exception e) {
- // FIXME: Once we have proper subclass of ObjectRegistrationo
- throw Throwables.propagate(e);
- }
- }
- }
-
- @Override
- public synchronized void close() {
- try {
- for(final ObjectRegistration<T> reg : registrations.values()) {
- reg.close();
- }
- } catch (final Exception e) {
- throw Throwables.propagate(e);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import com.google.common.base.Throwables;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-final class DelegatedRootRpcRegistration<T extends RpcService> implements RpcRegistration<T> {
-
- private final ObjectRegistration<T> delegate;
- private final Class<T> type;
-
- public DelegatedRootRpcRegistration(final Class<T> type,final ObjectRegistration<T> impl) {
- this.delegate = impl;
- this.type = type;
- }
-
-
- @Override
- public void close() {
- try {
- // FIXME: Should use more specific registration object.
- delegate.close();
- } catch (final Exception e) {
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public T getInstance() {
- return delegate.getInstance();
- }
-
- @Override
- public Class<T> getServiceType() {
- return type;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.binding.impl.LazySerializedDOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-final class FunctionalNotificationListenerAdapter<N extends Notification> implements DOMNotificationListener {
-
- private final BindingNormalizedNodeSerializer codec;
- private final NotificationListener<N> delegate;
- private final Class<N> type;
-
- public FunctionalNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final Class<N> type, final NotificationListener<N> delegate) {
- this.codec = codec;
- this.type = type;
- this.delegate = delegate;
- }
-
- @Override
- public void onNotification(@Nonnull final DOMNotification notification) {
- delegate.onNotification( type.cast(deserialize(notification)));
- }
-
- private Notification deserialize(final DOMNotification notification) {
- if(notification instanceof LazySerializedDOMNotification) {
- return ((LazySerializedDOMNotification) notification).getBindingData();
- }
- return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HeliumNotificationProviderServiceAdapter extends HeliumNotificationServiceAdapter implements NotificationProviderService, AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceAdapter.class);
-
- private final NotificationPublishService notificationPublishService;
-
- public HeliumNotificationProviderServiceAdapter(NotificationPublishService notificationPublishService,
- NotificationService notificationService) {
- super(notificationService);
- this.notificationPublishService = notificationPublishService;
- }
-
- @Override
- public void publish(final Notification notification) {
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.error("Notification publication was interupted: " + e);
- }
- }
-
- @Override
- public void publish(final Notification notification, final ExecutorService executor) {
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.error("Notification publication was interupted: " + e);
- }
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- NotificationInterestListener interestListener) {
- throw new UnsupportedOperationException("InterestListener is not supported.");
- }
-
- @Override
- public void close() throws Exception {
-
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import com.google.common.collect.Sets;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HeliumNotificationProviderServiceWithInterestListeners extends HeliumNotificationProviderServiceAdapter {
-
- private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceWithInterestListeners.class);
-
- private final ListenerRegistry<NotificationInterestListener> interestListeners = ListenerRegistry.create();
- private final ListenerRegistration<Listener> domListener;
- private final DOMNotificationService domService;
- private final BindingToNormalizedNodeCodec codec;
-
- public HeliumNotificationProviderServiceWithInterestListeners(
- final BindingDOMNotificationPublishServiceAdapter publishService, final BindingDOMNotificationServiceAdapter listenService, final DOMNotificationSubscriptionListenerRegistry registry) {
- super(publishService, listenService);
- this.codec = publishService.getCodecRegistry();
- this.domListener = registry.registerSubscriptionListener(new Listener());
- this.domService = listenService.getDomService();
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- final NotificationInterestListener listener) {
- notifyListener(listener, translate(domListener.getInstance().getAllObserved()));
- return interestListeners.register(listener);
- }
-
- private Set<Class<? extends Notification>> translate(final Set<SchemaPath> added) {
- return codec.getNotificationClasses(added);
- }
-
- private void notifyAllListeners(final Set<SchemaPath> added) {
- final Iterator<ListenerRegistration<NotificationInterestListener>> listeners = interestListeners.iterator();
- if(listeners.hasNext()) {
- final Set<Class<? extends Notification>> baEvent = translate(added);
- while(listeners.hasNext()) {
- final NotificationInterestListener listenerRef = listeners.next().getInstance();
- try {
- notifyListener(listenerRef,baEvent);
- } catch (final Exception e) {
- LOG.warn("Unhandled exception during invoking listener {}",e, listenerRef);
- }
- }
- }
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- final Class<T> type, final NotificationListener<T> listener) {
-
- final FunctionalNotificationListenerAdapter<T> adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener);
- final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
- final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
- return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
- @Override
- protected void removeRegistration() {
- domReg.close();
- }
-
- };
- }
-
- private void notifyListener(final NotificationInterestListener listener, final Set<Class<? extends Notification>> baEvent) {
- for(final Class<? extends Notification> event: baEvent) {
- listener.onNotificationSubscribtion(event);
- }
- }
-
- private final class Listener implements DOMNotificationSubscriptionListener {
-
- private volatile Set<SchemaPath> allObserved = Collections.emptySet();
-
- @Override
- public void onSubscriptionChanged(final Set<SchemaPath> currentTypes) {
- final Set<SchemaPath> added = Sets.difference(currentTypes, allObserved).immutableCopy();
- notifyAllListeners(added);
- allObserved = Sets.union(allObserved, added).immutableCopy();
- }
-
- Set<SchemaPath> getAllObserved() {
- return allObserved;
- }
- }
-
- @Override
- public void close() throws Exception {
- super.close();
- domListener.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-public class HeliumNotificationServiceAdapter implements org.opendaylight.controller.sal.binding.api.NotificationService, AutoCloseable {
-
- private final NotificationService notificationService;
-
- public HeliumNotificationServiceAdapter(NotificationService notificationService) {
- this.notificationService = notificationService;
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<org.opendaylight.controller.sal.binding.api.NotificationListener<T>> registerNotificationListener(
- final Class<T> notificationType, final org.opendaylight.controller.sal.binding.api.NotificationListener<T> listener) {
- throw new UnsupportedOperationException("Not supported type of listener.");
- }
-
- @Override
- public ListenerRegistration<NotificationListener> registerNotificationListener(
- final NotificationListener listener) {
- return notificationService.registerNotificationListener(listener);
- }
-
- @Override
- public void close() throws Exception {
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-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.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-public class HeliumRpcProviderRegistry implements RpcProviderRegistry {
-
- private final RpcConsumerRegistry consumerRegistry;
- private final BindingDOMRpcProviderServiceAdapter providerAdapter;
-
- public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry,
- final BindingDOMRpcProviderServiceAdapter providerAdapter) {
- this.consumerRegistry = consumerRegistry;
- this.providerAdapter = providerAdapter;
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type, final T impl)
- throws IllegalStateException {
- return new CompositeRoutedRpcRegistration<>(type,impl,providerAdapter);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T impl)
- throws IllegalStateException {
- final ObjectRegistration<T> reg = providerAdapter.registerRpcImplementation(type, impl);
- return new DelegatedRootRpcRegistration<>(type,reg);
- }
-
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> type) {
- return consumerRegistry.getRpcService(type);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- final L arg0) {
- // FIXME: Implement this only if necessary
- return null;
- }
-
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.compat;
-
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
-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.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class HydrogenDataBrokerAdapter implements DataProviderService, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(HydrogenDataBrokerAdapter.class);
-
- private final ConcurrentMap<InstanceIdentifier<?>, CommitHandlerRegistrationImpl> commitHandlers =
- new ConcurrentHashMap<>();
- private final ListeningExecutorService executorService = SingletonHolder.getDefaultCommitExecutor();
-
- private final DataBroker delegate;
-
- public HydrogenDataBrokerAdapter(final DataBroker dataBroker) {
- delegate = dataBroker;
- LOG.info("ForwardedBackwardsCompatibleBroker started.");
- }
-
- @Override
- public DataModificationTransaction beginTransaction() {
- return new ForwardedBackwardsCompatibleTransacion(delegate.newReadWriteTransaction());
- }
-
- @Override
- public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
- final DataModificationTransaction tx = beginTransaction();
- return tx.readConfigurationData(path);
- }
-
- @Override
- public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
- final DataModificationTransaction tx = beginTransaction();
- return tx.readOperationalData(path);
- }
-
- @Override
- public Registration registerCommitHandler(
- final InstanceIdentifier<? extends DataObject> path,
- final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
- final CommitHandlerRegistrationImpl reg = new CommitHandlerRegistrationImpl(path, commitHandler);
- commitHandlers.put(path, reg);
- return reg;
- }
-
- @Override
- @Deprecated
- public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>> registerCommitHandlerListener(
- final RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>> commitHandlerListener) {
- throw new UnsupportedOperationException("Not supported contract.");
- }
-
- @Override
- public ListenerRegistration<DataChangeListener> registerDataChangeListener(
- final InstanceIdentifier<? extends DataObject> path, final DataChangeListener listener) {
-
-
- final org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener);
- final org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener);
-
- final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg = delegate.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
- final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg = delegate.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
-
- return new LegacyListenerRegistration(listener,cfgReg,operReg);
- }
-
- @Override
- public Registration registerDataReader(
- final InstanceIdentifier<? extends DataObject> path,
- final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
- throw new UnsupportedOperationException("Data reader contract is not supported.");
- }
-
- public ListenableFuture<RpcResult<TransactionStatus>> commit(final ForwardedBackwardsCompatibleTransacion tx) {
-
- final List<DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject>> subTrans = new ArrayList<>();
- LOG.debug("Tx: {} Submitted.",tx.getIdentifier());
- final ListenableFuture<Boolean> requestCommit = executorService.submit(new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- try {
- for (final CommitHandlerRegistrationImpl handler : commitHandlers.values()) {
-
- final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx = handler
- .getInstance().requestCommit(tx);
- subTrans.add(subTx);
- }
- } catch (final Exception e) {
- LOG.error("Tx: {} Rollback.",tx.getIdentifier(),e);
- for (final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans) {
- subTx.rollback();
- }
- return false;
- }
- LOG.debug("Tx: {} Can Commit True.",tx.getIdentifier());
- return true;
- }
-
- });
-
- final ListenableFuture<RpcResult<TransactionStatus>> dataStoreCommit = Futures.transform(requestCommit, new AsyncFunction<Boolean, RpcResult<TransactionStatus>>() {
-
- @Override
- public ListenableFuture<RpcResult<TransactionStatus>> apply(final Boolean requestCommitSuccess) throws Exception {
- if(requestCommitSuccess) {
- return AbstractDataTransaction.convertToLegacyCommitFuture(tx.delegate.submit());
- }
- return Futures.immediateFuture(RpcResultBuilder.<TransactionStatus>failed().withResult(TransactionStatus.FAILED).build());
- }
- });
-
- return Futures.transform(dataStoreCommit, new Function<RpcResult<TransactionStatus>,RpcResult<TransactionStatus>>() {
- @Override
- public RpcResult<TransactionStatus> apply(final RpcResult<TransactionStatus> input) {
- if(input.isSuccessful()) {
- for(final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans ) {
- subTx.finish();
- }
- } else {
- LOG.error("Tx: {} Rollback - Datastore commit failed.",tx.getIdentifier());
- for(final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans ) {
- subTx.rollback();
- }
- }
- return input;
- }
- });
- }
-
- @Deprecated
- private class ForwardedBackwardsCompatibleTransacion implements DataModificationTransaction {
-
- private final ListenerRegistry<DataTransactionListener> listeners = ListenerRegistry.create();
- private final Map<InstanceIdentifier<? extends DataObject>, DataObject> updated = new HashMap<>();
- private final Map<InstanceIdentifier<? extends DataObject>, DataObject> created = new HashMap<>();
- private final Set<InstanceIdentifier<? extends DataObject>> removed = new HashSet<>();
- private final Map<InstanceIdentifier<? extends DataObject>, DataObject> original = new HashMap<>();
- private TransactionStatus status = TransactionStatus.NEW;
-
- private final Set<InstanceIdentifier<? extends DataObject>> posponedRemovedOperational = new HashSet<>();
- private final Set<InstanceIdentifier<? extends DataObject>> posponedRemovedConfiguration = new HashSet<>();
-
- private final ReadWriteTransaction delegate;
-
-
- @Override
- public final TransactionStatus getStatus() {
- return status;
- }
-
- protected ForwardedBackwardsCompatibleTransacion(final ReadWriteTransaction delegate) {
- this.delegate = delegate;
- LOG.debug("Tx {} allocated.",getIdentifier());
- }
-
- @Override
- public void putOperationalData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
- final boolean previouslyRemoved = posponedRemovedOperational.remove(path);
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
- if(previouslyRemoved) {
- delegate.put(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
- } else {
- delegate.merge(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
- }
- }
-
- @Override
- public void putConfigurationData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
- final boolean previouslyRemoved = posponedRemovedConfiguration.remove(path);
- final DataObject originalObj = readConfigurationData(path);
- if (originalObj != null) {
- original.put(path, originalObj);
-
- } else {
- created.put(path, data);
- }
- updated.put(path, data);
- @SuppressWarnings({"rawtypes","unchecked"})
- final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
- if(previouslyRemoved) {
- delegate.put(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
- } else {
- delegate.merge(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
- }
- }
-
- @Override
- public void removeOperationalData(final InstanceIdentifier<? extends DataObject> path) {
- posponedRemovedOperational.add(path);
- }
-
- @Override
- public void removeConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
- posponedRemovedConfiguration.add(path);
- }
-
- @Override
- public Map<InstanceIdentifier<? extends DataObject>, DataObject> getCreatedOperationalData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Map<InstanceIdentifier<? extends DataObject>, DataObject> getCreatedConfigurationData() {
- return created;
- }
-
- @Override
- public Map<InstanceIdentifier<? extends DataObject>, DataObject> getUpdatedOperationalData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Map<InstanceIdentifier<? extends DataObject>, DataObject> getUpdatedConfigurationData() {
- return updated;
- }
-
- @Override
- public Set<InstanceIdentifier<? extends DataObject>> getRemovedConfigurationData() {
- return removed;
- }
-
- @Override
- public Set<InstanceIdentifier<? extends DataObject>> getRemovedOperationalData() {
- return Collections.emptySet();
- }
-
- @Override
- public Map<InstanceIdentifier<? extends DataObject>, DataObject> getOriginalConfigurationData() {
- return original;
- }
-
- @Override
- public Map<InstanceIdentifier<? extends DataObject>, DataObject> getOriginalOperationalData() {
- return Collections.emptyMap();
- }
-
- @Override
- public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
- try {
- return delegate.read(LogicalDatastoreType.OPERATIONAL, path).get().orNull();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Read of {} failed.", path,e);
- return null;
- }
- }
-
- @Override
- public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
- try {
- return delegate.read(LogicalDatastoreType.CONFIGURATION, path).get().orNull();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Read of {} failed.", path,e);
- return null;
- }
- }
-
- private void changeStatus(final TransactionStatus status) {
- LOG.trace("Transaction {} changed status to {}", getIdentifier(), status);
- this.status = status;
-
- for(final ListenerRegistration<DataTransactionListener> listener : listeners) {
- try {
- listener.getInstance().onStatusUpdated(this, status);
- } catch (final Exception e) {
- LOG.error("Error during invoking transaction listener {}",listener.getInstance(),e);
- }
- }
- }
-
- @Override
- public ListenableFuture<RpcResult<TransactionStatus>> commit() {
-
- for(final InstanceIdentifier<? extends DataObject> path : posponedRemovedConfiguration) {
- delegate.delete(LogicalDatastoreType.CONFIGURATION, path);
- }
-
- for(final InstanceIdentifier<? extends DataObject> path : posponedRemovedOperational) {
- delegate.delete(LogicalDatastoreType.OPERATIONAL, path);
- }
-
- changeStatus(TransactionStatus.SUBMITED);
-
- final ListenableFuture<RpcResult<TransactionStatus>> f = HydrogenDataBrokerAdapter.this.commit(this);
-
- Futures.addCallback(f, new FutureCallback<RpcResult<TransactionStatus>>() {
- @Override
- public void onSuccess(final RpcResult<TransactionStatus> result) {
- changeStatus(result.getResult());
- }
-
- @Override
- public void onFailure(final Throwable t) {
- LOG.error("Transaction {} failed to complete", getIdentifier(), t);
- changeStatus(TransactionStatus.FAILED);
- }
- });
-
- return f;
- }
-
- @Override
- public ListenerRegistration<DataTransactionListener> registerListener(final DataTransactionListener listener) {
- return listeners.register(listener);
- }
-
- @Override
- public Object getIdentifier() {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-
- private class CommitHandlerRegistrationImpl extends
- AbstractObjectRegistration<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> {
-
- private final InstanceIdentifier<? extends DataObject> path;
-
- public CommitHandlerRegistrationImpl(final InstanceIdentifier<? extends DataObject> path,
- final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
- super(commitHandler);
- this.path = path;
- }
-
- @Override
- protected void removeRegistration() {
- commitHandlers.remove(path, this);
- }
-
- }
-
-
- private static final class LegacyListenerRegistration implements ListenerRegistration<DataChangeListener> {
-
- private final DataChangeListener instance;
- private final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg;
- private final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg;
-
- public LegacyListenerRegistration(final DataChangeListener listener,
- final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg,
- final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg) {
- this.instance = listener;
- this.cfgReg = cfgReg;
- this.operReg = operReg;
- }
-
- @Override
- public DataChangeListener getInstance() {
- return instance;
- }
-
- @Override
- public void close() {
- cfgReg.close();
- operReg.close();
- }
-
- }
-
- private static class BackwardsCompatibleOperationalDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator<DataChangeListener> {
-
- private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener<?,?> delegate;
-
-
- public BackwardsCompatibleOperationalDataChangeInvoker(final DataChangeListener listener) {
- this.delegate = listener;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-
- final DataChangeEvent legacyChange = HydrogenDataChangeEvent.createOperational(change);
- delegate.onDataChanged(legacyChange);
-
- }
-
- @Override
- public DataChangeListener getDelegate() {
- return (DataChangeListener) delegate;
- }
-
- }
-
- private static class BackwardsCompatibleConfigurationDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator<DataChangeListener> {
- private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener<?,?> delegate;
-
- public BackwardsCompatibleConfigurationDataChangeInvoker(final DataChangeListener listener) {
- this.delegate = listener;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-
- final DataChangeEvent legacyChange = HydrogenDataChangeEvent.createConfiguration(change);
-
- delegate.onDataChanged(legacyChange);
-
- }
-
- @Override
- public DataChangeListener getDelegate() {
- return (DataChangeListener) delegate;
- }
-
- }
-
- @Override
- public void close() throws Exception {
- // TODO Auto-generated method stub
- }
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.compat;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated
-public abstract class HydrogenDataChangeEvent implements
- DataChangeEvent<InstanceIdentifier<? extends DataObject>, DataObject> {
-
- private HydrogenDataChangeEvent() {
- }
-
- public static final DataChangeEvent<InstanceIdentifier<?>, DataObject> createOperational(
- final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- return new OperationalChangeEvent(change);
- }
-
- public static final DataChangeEvent<InstanceIdentifier<?>, DataObject> createConfiguration(
- final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- return new ConfigurationChangeEvent(change);
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getCreatedOperationalData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getCreatedConfigurationData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getUpdatedOperationalData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getUpdatedConfigurationData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Set<InstanceIdentifier<?>> getRemovedConfigurationData() {
- return Collections.emptySet();
- }
-
- @Override
- public Set<InstanceIdentifier<?>> getRemovedOperationalData() {
- return Collections.emptySet();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getOriginalConfigurationData() {
- return Collections.emptyMap();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getOriginalOperationalData() {
- return Collections.emptyMap();
- }
-
- @Override
- public DataObject getOriginalConfigurationSubtree() {
- return null;
- }
-
- @Override
- public DataObject getOriginalOperationalSubtree() {
- return null;
- }
-
- @Override
- public DataObject getUpdatedConfigurationSubtree() {
- return null;
- }
-
- @Override
- public DataObject getUpdatedOperationalSubtree() {
- return null;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private static final class OperationalChangeEvent extends HydrogenDataChangeEvent {
-
- private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
- private Map<InstanceIdentifier<?>, DataObject> updatedCache;
-
- public OperationalChangeEvent(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- this.delegate = change;
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getCreatedOperationalData() {
- return delegate.getCreatedData();
- }
-
- @Override
- public Set<InstanceIdentifier<?>> getRemovedOperationalData() {
- return delegate.getRemovedPaths();
- }
-
- @Override
- public DataObject getOriginalOperationalSubtree() {
- return delegate.getOriginalSubtree();
- }
-
- @Override
- public DataObject getUpdatedOperationalSubtree() {
- return delegate.getUpdatedSubtree();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getOriginalOperationalData() {
- return (Map) delegate.getOriginalData();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getUpdatedOperationalData() {
- if(updatedCache == null) {
- final Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
- final Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
- final Map<InstanceIdentifier<?>, DataObject> updatedComposite =
- new HashMap<>(created.size() + updated.size());
- updatedComposite.putAll(created);
- updatedComposite.putAll(updated);
- updatedCache = Collections.unmodifiableMap(updatedComposite);
- }
- return updatedCache;
- }
-
- @Override
- public String toString() {
- return "OperationalChangeEvent [delegate=" + delegate + "]";
- }
-
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private static final class ConfigurationChangeEvent extends HydrogenDataChangeEvent {
-
- private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
- private Map<InstanceIdentifier<?>, DataObject> updatedCache;
-
- public ConfigurationChangeEvent(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- this.delegate = change;
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getCreatedConfigurationData() {
- return delegate.getCreatedData();
- }
-
- @Override
- public Set<InstanceIdentifier<?>> getRemovedConfigurationData() {
- return delegate.getRemovedPaths();
- }
-
- @Override
- public DataObject getOriginalConfigurationSubtree() {
- return delegate.getOriginalSubtree();
- }
-
- @Override
- public DataObject getUpdatedConfigurationSubtree() {
- return delegate.getUpdatedSubtree();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getOriginalConfigurationData() {
- return (Map) delegate.getOriginalData();
- }
-
- @Override
- public Map<InstanceIdentifier<?>, DataObject> getUpdatedConfigurationData() {
- if(updatedCache == null) {
- final Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
- final Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
- final Map<InstanceIdentifier<?>, DataObject> updatedComposite =
- new HashMap<>(created.size() + updated.size());
- updatedComposite.putAll(created);
- updatedComposite.putAll(updated);
- updatedCache = Collections.unmodifiableMap(updatedComposite);
- }
- return updatedCache;
- }
-
- @Override
- public String toString() {
- return "ConfigurationChangeEvent [delegate=" + delegate + "]";
- }
-
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-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.BindingAwareService;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-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.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-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.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated
-public class HydrogenMountInstanceAdapter implements MountProviderInstance {
-
- private final ClassToInstanceMap<BindingAwareService> services;
- private final InstanceIdentifier<?> identifier;
-
-
- public HydrogenMountInstanceAdapter(final MountPoint key) {
- this.identifier = key.getIdentifier();
- final ImmutableClassToInstanceMap.Builder<BindingAwareService> builder = ImmutableClassToInstanceMap.builder();
-
- final Optional<DataBroker> dataBroker = key.getService(DataBroker.class);
- if(dataBroker.isPresent()) {
- builder.put(DataBrokerService.class, new HydrogenDataBrokerAdapter(dataBroker.get()));
- }
- final Optional<org.opendaylight.controller.md.sal.binding.api.NotificationService> notificationService = key.getService(org.opendaylight.controller.md.sal.binding.api.NotificationService.class);
- if(notificationService.isPresent()) {
- builder.put(NotificationService.class, new HeliumNotificationServiceAdapter(notificationService.get()));
- }
- final Optional<RpcConsumerRegistry> rpcRegistry = key.getService(RpcConsumerRegistry.class);
- if(rpcRegistry.isPresent()) {
- builder.put(RpcConsumerRegistry.class, rpcRegistry.get());
- }
- services = builder.build();
- }
-
-
- private <T extends BindingAwareService> T service(final Class<T> service) {
- final T potential = services.getInstance(service);
- Preconditions.checkState(potential != null, "Service %s is not supported by mount point %s",service,this.getIdentifier());
- return potential;
- }
-
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> serviceInterface) {
- return service(RpcConsumerRegistry.class).getRpcService(serviceInterface);
- }
-
- @Override
- public InstanceIdentifier<?> getIdentifier() {
- return identifier;
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- final Class<T> notificationType, final NotificationListener<T> listener) {
- return service(NotificationService.class).registerNotificationListener(notificationType, listener);
- }
-
- @Override
- public ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
- final org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- return service(NotificationService.class).registerNotificationListener(listener);
- }
-
- @Override
- public DataModificationTransaction beginTransaction() {
- return service(DataBrokerService.class).beginTransaction();
- }
-
- @Override
- public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
- return service(DataBrokerService.class).readConfigurationData(path);
- }
-
- @Override
- public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
- return service(DataBrokerService.class).readOperationalData(path);
- }
-
- @Override
- public ListenerRegistration<DataChangeListener> registerDataChangeListener(
- final InstanceIdentifier<? extends DataObject> path, final DataChangeListener listener) {
- return service(DataBrokerService.class).registerDataChangeListener(path,listener);
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> serviceInterface,
- final T implementation) throws IllegalStateException {
- return service(RpcProviderRegistry.class).addRoutedRpcImplementation(serviceInterface, implementation);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> serviceInterface, final T implementation)
- throws IllegalStateException {
- return service(RpcProviderRegistry.class).addRpcImplementation(serviceInterface, implementation);
- }
-
- @Override
- public void publish(final Notification notification) {
- service(NotificationProviderService.class).publish(notification);
- }
-
- @Override
- public void publish(final Notification notification, final ExecutorService executor) {
- service(NotificationProviderService.class).publish(notification);
- }
-
- @Override
- public Registration registerCommitHandler(final InstanceIdentifier<? extends DataObject> arg0,
- final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> arg1) {
- return service(DataProviderService.class).registerCommitHandler(arg0, arg1);
- }
-
- @Override
- public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>> registerCommitHandlerListener(
- final RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>> arg0) {
- return service(DataProviderService.class).registerCommitHandlerListener(arg0);
- }
-
- @Override
- public Registration registerDataReader(final InstanceIdentifier<? extends DataObject> path,
- final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
- return service(DataProviderService.class).registerDataReader(path, reader);
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- final NotificationInterestListener interestListener) {
- return service(NotificationProviderService.class).registerInterestListener(interestListener);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- final L arg0) {
- return service(RpcProviderRegistry.class).registerRouteChangeListener(arg0);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.sal.binding.api.mount.MountService;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated
-public class HydrogenMountPointServiceAdapter implements MountService {
-
- private final MountPointService delegate;
-
- public HydrogenMountPointServiceAdapter(final MountPointService mountService) {
- delegate = mountService;
- }
-
- private final LoadingCache<MountPoint, HydrogenMountInstanceAdapter> mountAdapters = CacheBuilder.newBuilder().weakKeys()
- .build(new CacheLoader<MountPoint, HydrogenMountInstanceAdapter>() {
-
- @Override
- public HydrogenMountInstanceAdapter load(final MountPoint key) throws Exception {
- return new HydrogenMountInstanceAdapter(key);
- }
- });
-
- @Override
- public HydrogenMountInstanceAdapter getMountPoint(final InstanceIdentifier<?> path) {
- final Optional<MountPoint> mount = delegate.getMountPoint(path);
- if (mount.isPresent()) {
- return mountAdapters.getUnchecked(mount.get());
- }
- return null;
- }
-
- MountPointService getDelegate() {
- return delegate;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-@Deprecated
-public class HydrogenMountProvisionServiceAdapter extends HydrogenMountPointServiceAdapter implements MountProviderService {
-
- public HydrogenMountProvisionServiceAdapter(final MountPointService mountService) {
- super(mountService);
- }
-
- @Override
- public MountProviderInstance createMountPoint(final InstanceIdentifier<?> path) {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- @Override
- public MountProviderInstance createOrGetMountPoint(final InstanceIdentifier<?> path) {
- return getMountPoint(path);
- }
-
- @Override
- public ListenerRegistration<MountProvisionListener> registerProvisionListener(final MountProvisionListener listener) {
- return new ListenerRegistration<MountProvisionListener>() {
-
- @Override
- public MountProvisionListener getInstance() {
- return listener;
- }
-
- @Override
- public void close() {
- }
- };
- }
-
-}
+++ /dev/null
-/**
- * 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.md.sal.binding.compat;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class HydrogenNotificationBrokerImpl implements NotificationProviderService, AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(HydrogenNotificationBrokerImpl.class);
-
- private final ListenerRegistry<NotificationInterestListener> interestListeners =
- ListenerRegistry.create();
- private final AtomicReference<ListenerMapGeneration> listeners = new AtomicReference<>(new ListenerMapGeneration());
- private final ExecutorService executor;
-
- public HydrogenNotificationBrokerImpl(final ExecutorService executor) {
- this.executor = Preconditions.checkNotNull(executor);
- }
-
- @Override
- public void publish(final Notification notification) {
- publish(notification, executor);
- }
-
- @Override
- public void publish(final Notification notification, final ExecutorService service) {
- for (final NotificationListenerRegistration<?> r : listeners.get().listenersFor(notification)) {
- service.submit(new NotifyTask(r, notification));
- }
- }
-
- @GuardedBy("this")
- private Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> mutableListeners() {
- return HashMultimap.create(listeners.get().getListeners());
- }
-
- private void addRegistrations(final NotificationListenerRegistration<?>... registrations) {
- synchronized (this) {
- final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> newListeners =
- mutableListeners();
- for (final NotificationListenerRegistration<?> reg : registrations) {
- newListeners.put(reg.getType(), reg);
- }
-
- listeners.set(new ListenerMapGeneration(newListeners));
- }
-
- // Notifications are dispatched out of lock...
- for (final NotificationListenerRegistration<?> reg : registrations) {
- announceNotificationSubscription(reg.getType());
- }
- }
-
- private synchronized void removeRegistrations(final NotificationListenerRegistration<?>... registrations) {
- final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> newListeners =
- mutableListeners();
-
- for (final NotificationListenerRegistration<?> reg : registrations) {
- newListeners.remove(reg.getType(), reg);
- }
-
- listeners.set(new ListenerMapGeneration(newListeners));
- }
-
- private void announceNotificationSubscription(final Class<? extends Notification> notification) {
- for (final ListenerRegistration<NotificationInterestListener> listener : interestListeners) {
- try {
- listener.getInstance().onNotificationSubscribtion(notification);
- } catch (final Exception e) {
- LOG.warn("Listener {} reported unexpected error on notification {}",
- listener.getInstance(), notification, e);
- }
- }
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(final NotificationInterestListener interestListener) {
- final ListenerRegistration<NotificationInterestListener> registration = this.interestListeners.register(interestListener);
-
- for (final Class<? extends Notification> notification : listeners.get().getKnownTypes()) {
- interestListener.onNotificationSubscribtion(notification);
- }
- return registration;
- }
-
- @Override
- public <T extends Notification> NotificationListenerRegistration<T> registerNotificationListener(final Class<T> notificationType, final NotificationListener<T> listener) {
- final NotificationListenerRegistration<T> reg = new AbstractNotificationListenerRegistration<T>(notificationType, listener) {
- @Override
- protected void removeRegistration() {
- removeRegistrations(this);
- }
- };
-
- addRegistrations(reg);
- return reg;
- }
-
- @Override
- public ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(final org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- final NotificationInvoker invoker = NotificationInvoker.invokerFor(listener);
- final Set<Class<? extends Notification>> types = invoker.getSupportedNotifications();
- final NotificationListenerRegistration<?>[] regs = new NotificationListenerRegistration<?>[types.size()];
-
- // Populate the registrations...
- int i = 0;
- for (final Class<? extends Notification> type : types) {
- regs[i] = new AggregatedNotificationListenerRegistration<Notification, Object>(type, invoker, regs) {
- @Override
- protected void removeRegistration() {
- // Nothing to do, will be cleaned up by parent (below)
- }
- };
- ++i;
- }
-
- // ... now put them to use ...
- addRegistrations(regs);
-
- // ... finally return the parent registration
- return new AbstractListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener>(listener) {
- @Override
- protected void removeRegistration() {
- removeRegistrations(regs);
- for (final ListenerRegistration<?> reg : regs) {
- reg.close();
- }
- }
- };
- }
-
- @Override
- public void close() {
- }
-
-}
+++ /dev/null
-/**
- * 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.controller.md.sal.binding.compat;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-import com.google.common.base.Predicate;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Multimap;
-
-/**
- * An immutable view of the current generation of listeners.
- */
-final class ListenerMapGeneration {
- private static final int CACHE_MAX_ENTRIES = 1000;
-
- /**
- * Constant map of notification type to subscribed listeners.
- */
- private final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> typeToListeners;
-
- /**
- * Dynamic cache of notification implementation to matching listeners. This cache loads entries based on
- * the contents of the {@link #typeToListeners} map.
- */
- private final LoadingCache<Class<?>, Iterable<NotificationListenerRegistration<?>>> implementationToListeners =
- CacheBuilder.newBuilder()
- .weakKeys()
- .maximumSize(CACHE_MAX_ENTRIES)
- .build(new CacheLoader<Class<?>, Iterable<NotificationListenerRegistration<?>>>() {
- @Override
- public Iterable<NotificationListenerRegistration<?>> load(final Class<?> key) {
- final Set<NotificationListenerRegistration<?>> regs = new HashSet<>();
-
- for (final Class<?> type : getNotificationTypes(key)) {
- @SuppressWarnings("unchecked")
- final Collection<NotificationListenerRegistration<?>> l = typeToListeners.get((Class<? extends Notification>) type);
- if (l != null) {
- regs.addAll(l);
- }
- }
-
- return ImmutableSet.copyOf(regs);
- }
- });
-
- ListenerMapGeneration() {
- typeToListeners = ImmutableMultimap.of();
- }
-
- ListenerMapGeneration(final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> listeners) {
- this.typeToListeners = ImmutableMultimap.copyOf(listeners);
- }
-
- /**
- * Current listeners. Exposed for creating the next generation.
- *
- * @return Current type-to-listener map.
- */
- Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> getListeners() {
- return typeToListeners;
- }
-
- /**
- * Look up the listeners which need to see this notification delivered.
- *
- * @param notification Notification object
- * @return Iterable of listeners, guaranteed to be nonnull.
- */
- public Iterable<NotificationListenerRegistration<?>> listenersFor(final Notification notification) {
- // Safe to use, as our loader does not throw checked exceptions
- return implementationToListeners.getUnchecked(notification.getClass());
- }
-
- public Iterable<Class<? extends Notification>> getKnownTypes() {
- return typeToListeners.keySet();
- }
-
- private static Iterable<Class<?>> getNotificationTypes(final Class<?> cls) {
- final Class<?>[] ifaces = cls.getInterfaces();
- return Iterables.filter(Arrays.asList(ifaces), new Predicate<Class<?>>() {
- @Override
- public boolean apply(final Class<?> input) {
- if (Notification.class.equals(input)) {
- return false;
- }
- return Notification.class.isAssignableFrom(input);
- }
- });
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.compat;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker;
-import org.opendaylight.yangtools.yang.common.QName;
-
-final class NotificationInvoker implements org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> {
-
- private final NotificationListener delegate;
- private final Map<Class<? extends Notification>,InvokerContext> invokers;
-
-
- private NotificationInvoker(final NotificationListener listener) {
- delegate = listener;
- final Map<Class<? extends Notification>, InvokerContext> builder = new HashMap<>();
- for(final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
- final Class<?> iface = ifaceToken.getRawType();
- if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
- @SuppressWarnings("unchecked")
- final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
- final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
- for(final Class<? extends Notification> type : getNotificationTypes(listenerType)) {
- builder.put(type, new InvokerContext(BindingReflections.findQName(type) , invoker));
- }
- }
- }
- invokers = ImmutableMap.copyOf(builder);
- }
-
- public static NotificationInvoker invokerFor(final NotificationListener listener) {
- return new NotificationInvoker(listener);
- }
-
- public Set<Class<? extends Notification>> getSupportedNotifications() {
- return invokers.keySet();
- }
-
- @Override
- public void onNotification(final Notification notification) {
- getContext(notification.getImplementedInterface()).invoke(notification);
- }
-
- private InvokerContext getContext(final Class<?> type) {
- return invokers.get(type);
- }
-
- @SuppressWarnings("unchecked")
- private static Set<Class<? extends Notification>> getNotificationTypes(final Class<? extends org.opendaylight.yangtools.yang.binding.NotificationListener> type) {
- // TODO: Investigate possibility and performance impact if we cache this or expose
- // it from NotificationListenerInvoker
- final Set<Class<? extends Notification>> ret = new HashSet<>();
- for(final Method method : type.getMethods()) {
- if(BindingReflections.isNotificationCallback(method)) {
- final Class<? extends Notification> notification = (Class<? extends Notification>) method.getParameterTypes()[0];
- ret.add(notification);
- }
- }
- return ret;
- }
-
- private final class InvokerContext {
-
- private final QName name;
- private final NotificationListenerInvoker invoker;
-
- private InvokerContext(final QName name, final NotificationListenerInvoker invoker) {
- this.name = name;
- this.invoker = invoker;
- }
-
- public void invoke(final Notification notification) {
- invoker.invokeNotification(delegate, name, notification);
- }
-
- }
-
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.compat;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * A registration of a {@link NotificationListener}. Allows query of the type
- * of the notification and dispatching the notification atomically with regard
- * to unregistration.
- *
- * @param <T> Type of notification
- */
-interface NotificationListenerRegistration<T extends Notification> extends ListenerRegistration<NotificationListener<T>> {
- /**
- * Return the interface class of the notification type.
- *
- * @return Notification type.
- */
- Class<? extends Notification> getType();
-
- /**
- * Dispatch a notification to the listener.
- *
- * @param notification Notification to be dispatched
- */
- void notify(Notification notification);
-}
+++ /dev/null
-/**
- * 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.md.sal.binding.compat;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class NotifyTask implements Runnable {
- private static final Logger LOG = LoggerFactory.getLogger(NotifyTask.class);
-
- private final NotificationListenerRegistration<?> registration;
- private final Notification notification;
-
- public NotifyTask(final NotificationListenerRegistration<?> registration, final Notification notification) {
- this.registration = Preconditions.checkNotNull(registration);
- this.notification = Preconditions.checkNotNull(notification);
- }
-
- @SuppressWarnings("unchecked")
- private <T extends Notification> NotificationListenerRegistration<T> getRegistration() {
- return (NotificationListenerRegistration<T>)registration;
- }
-
- @Override
- public void run() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Delivering notification {} to {}", notification, registration.getInstance());
- } else {
- LOG.trace("Delivering notification {} to {}", notification.getClass().getName(), registration.getInstance());
- }
-
- try {
- getRegistration().notify(notification);
- } catch (final Exception e) {
- LOG.error("Unhandled exception thrown by listener: {}", registration.getInstance(), e);
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Notification delivered {} to {}", notification, registration.getInstance());
- } else {
- LOG.trace("Notification delivered {} to {}", notification.getClass().getName(), registration.getInstance());
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((registration== null) ? 0 : registration.hashCode());
- result = prime * result + ((notification== null) ? 0 : notification.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final NotifyTask other = (NotifyTask) obj;
- if (registration == null) {
- if (other.registration != null) {
- return false;
- }
- } else if (!registration.equals(other.registration)) {
- return false;
- }
- if (notification == null) {
- if (other.notification != null) {
- return false;
- }
- } else if (!notification.equals(other.notification)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("listener", registration)
- .add("notification", notification.getClass())
- .toString();
- }
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.impl;
-
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class AbstractReadWriteTransaction extends AbstractWriteTransaction<DOMDataReadWriteTransaction> {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractReadWriteTransaction.class);
-
- public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate, final BindingToNormalizedNodeCodec codec) {
- super(delegate, codec);
- }
-
- @Override
- protected final void ensureParentsByMerge(final LogicalDatastoreType store,
- final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath,
- final InstanceIdentifier<?> path) {
- List<PathArgument> currentArguments = new ArrayList<>();
- DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
- Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator();
- while (iterator.hasNext()) {
- PathArgument currentArg = iterator.next();
- try {
- currentOp = currentOp.getChild(currentArg);
- } catch (DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
- }
- currentArguments.add(currentArg);
- org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(
- currentArguments);
-
- final Boolean exists;
- try {
- exists = getDelegate().exists(store, currentPath).checkedGet();
- } catch (ReadFailedException e) {
- LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
- throw new IllegalStateException("Failed to read pre-existing data", e);
- }
-
- if (!exists && iterator.hasNext()) {
- getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
- }
- }
- }
-
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
-import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-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.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountService;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Mutable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RootBindingAwareBroker implements Mutable, Identifiable<String>, BindingAwareBroker, AutoCloseable,
- RpcProviderRegistry {
-
- private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
-
- RootSalInstance controllerRoot;
-
- private final String identifier;
-
- private RpcProviderRegistry rpcBroker;
-
- private NotificationProviderService notificationBroker;
-
- @SuppressWarnings("deprecation")
- private DataProviderService legacyDataBroker;
-
- private DataBroker dataBroker;
-
- private MountProviderService legacyMount;
-
- private ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
-
- private ImmutableClassToInstanceMap<BindingAwareService> supportedProviderServices;
-
- private MountPointService mountService;
-
- public void setLegacyMountManager(final MountProviderService legacyMount) {
- this.legacyMount = legacyMount;
- }
-
- public RootBindingAwareBroker(final String instanceName) {
- this.identifier = instanceName;
- }
-
- @Override
- public String getIdentifier() {
- return identifier;
- }
-
- public RootSalInstance getRoot() {
- return controllerRoot;
- }
-
- public DataProviderService getDataBroker() {
- return this.legacyDataBroker;
- }
-
- public NotificationProviderService getNotificationBroker() {
- return this.notificationBroker;
- }
-
- public RpcProviderRegistry getRpcProviderRegistry() {
- return this.rpcBroker;
- }
-
- public RpcProviderRegistry getRpcBroker() {
- return rpcBroker;
- }
-
- public MountPointService getMountService() {
- return mountService;
- }
-
- public MountProviderService getLegacyMount() {
- return legacyMount;
- }
-
- public void setDataBroker(final DataBroker asyncDataBroker) {
- dataBroker = asyncDataBroker;
- }
-
- public void setMountService(final MountPointService mount) {
- this.mountService = mount;
- }
-
- public void setRpcBroker(final RpcProviderRegistry rpcBroker) {
- this.rpcBroker = rpcBroker;
- }
-
- public void setNotificationBroker(final NotificationProviderService notificationBroker) {
- this.notificationBroker = notificationBroker;
- }
-
- public void setLegacyDataBroker(final DataProviderService dataBroker) {
- this.legacyDataBroker = dataBroker;
- }
-
- public void start() {
- checkState(controllerRoot == null, "Binding Aware Broker was already started.");
- LOG.info("Starting Binding Aware Broker: {}", identifier);
-
- controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker());
-
- final ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap
- .builder();
-
- consBuilder.put(NotificationService.class, getRoot());
- consBuilder.put(DataBrokerService.class, getRoot());
- consBuilder.put(RpcConsumerRegistry.class, getRoot());
- if (dataBroker != null) {
- consBuilder.put(DataBroker.class, dataBroker);
- }
- consBuilder.put(MountPointService.class, mountService);
- consBuilder.put(MountService.class, legacyMount).build();
- supportedConsumerServices = consBuilder.build();
- supportedProviderServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
- .putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot())
- .put(DataProviderService.class, getRoot()).put(RpcProviderRegistry.class, getRoot())
- .put(MountProviderService.class, legacyMount).build();
- }
-
- @Override
- public ConsumerContext registerConsumer(final BindingAwareConsumer consumer, final BundleContext ctx) {
- return registerConsumer(consumer);
- }
-
- @Override
- public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) {
- return registerProvider(provider);
- }
-
- @Override
- public ConsumerContext registerConsumer(final BindingAwareConsumer consumer) {
- checkState(supportedConsumerServices != null, "Broker is not initialized.");
- return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
- }
-
- @Override
- public ProviderContext registerProvider(final BindingAwareProvider provider) {
- checkState(supportedProviderServices != null, "Broker is not initialized.");
- return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices);
- }
-
- @Override
- public void close() throws Exception {
- // FIXME: Close all sessions
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
- final T implementation) throws IllegalStateException {
- return getRoot().addRoutedRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T implementation)
- throws IllegalStateException {
- return getRoot().addRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> module) {
- return getRoot().getRpcService(module);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- final L arg0) {
- return getRoot().registerRouteChangeListener(arg0);
- }
-
- public class RootSalInstance extends
- AbstractBindingSalProviderInstance<DataProviderService, NotificationProviderService, RpcProviderRegistry> {
-
- public RootSalInstance(final RpcProviderRegistry rpcRegistry,
- final NotificationProviderService notificationBroker, final DataProviderService dataBroker) {
- super(rpcRegistry, notificationBroker, dataBroker);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.md.sal.binding.impl.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
-
-import com.google.common.collect.ImmutableList;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChanged;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificationBrokerTest {
-
- private NotificationProviderService notificationProviderService;
-
- @Before
- public void initTest() {
- final NotificationService notificationService = getNotificationService();
- final NotificationPublishService notificationPublishService = getNotificationPublishService();
- notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService, notificationService);
- }
-
- private TwoLevelListChanged createTestData() {
- final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
- tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().setKey(new TopLevelListKey("test")).build()));
- return tb.build();
- }
-
- @Test
- public void testNotifSubscriptionForwarded() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
- final TwoLevelListChanged testData = createTestData();
-
- final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch);
- final ListenerRegistration<NotificationListener> listenerRegistration =
- notificationProviderService.registerNotificationListener(testNotifListener);
- notificationProviderService.publish(testData);
-
- latch.await(500L, TimeUnit.MILLISECONDS);
- assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
- assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
- listenerRegistration.close();
- }
-
- private static class NotifTestListenerChild extends NotifTestListener {
-
- public NotifTestListenerChild(final CountDownLatch latch) {
- super(latch);
- }
- }
- private static class NotifTestListener implements OpendaylightMdsalListTestListener {
- private List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
- private CountDownLatch latch;
-
- public NotifTestListener(CountDownLatch latch) {
- this.latch = latch;
- }
-
- @Override
- public void onTwoLevelListChanged(TwoLevelListChanged notification) {
- receivedNotifications.add(notification);
- latch.countDown();
- }
-
- public List<TwoLevelListChanged> getReceivedNotifications() {
- return receivedNotifications;
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 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.md.sal.binding.impl.test;
-
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.concurrent.ExecutionException;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestCustomizer;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-
-@Deprecated
-public class ForwardedBackwardsCompatibleDataBrokerTest extends
- AbstractDataBrokerTest {
-
- private HydrogenDataBrokerAdapter dataBroker;
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
- private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
- private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
- private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
-
- @Override
- protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(TopLevelList.class));
- }
-
- @Override
- protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
- return new DataBrokerTestCustomizer();
- }
-
- @Override
- protected void setupWithDataBroker(final DataBroker dataBroker) {
- super.setupWithDataBroker(dataBroker);
- this.dataBroker = new HydrogenDataBrokerAdapter(dataBroker);
- }
-
-
-
-
- /**
- * The purpose of this test is to exercise the backwards compatible broker
- * <p>
- * This test tries to execute the code which ensures that the parents
- * for a given node get automatically created.
- *
- * @see org.opendaylight.controller.md.sal.binding.impl.AbstractReadWriteTransaction#ensureParentsByMerge(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.binding.InstanceIdentifier)
- */
- @Test
- public void testEnsureParentsByMerge() throws InterruptedException, ExecutionException {
- final DataModificationTransaction writeTx =
- dataBroker.beginTransaction();
-
- writeTx.putOperationalData(NODE_PATH, NODE);
-
- writeTx.commit().get();
-
- // TOP_PATH should exist as it is the parent of NODE_PATH
- final DataObject object = dataBroker.readOperationalData(TOP_PATH);
-
- assertNotNull(object);
-
- }
-
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.test;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Before;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
-import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-
-public abstract class AbstractDataServiceTest {
-
- protected DataProviderService baDataService;
-
- protected BindingTestContext testContext;
-
- @Before
- public void setUp() {
- ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
- BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
- factory.setExecutor(executor);
- factory.setStartWithParsedSchema(getStartWithSchema());
- testContext = factory.getTestContext();
- testContext.start();
-
- baDataService = testContext.getBindingDataBroker();
- }
-
- protected boolean getStartWithSchema() {
- return true;
- }
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.test;
-
-import static org.junit.Assert.assertNotNull;
-import org.opendaylight.yangtools.yang.binding.Augmentable;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-
-public class AugmentationVerifier<T extends Augmentable<T>> {
-
- private T object;
-
- public AugmentationVerifier(T objectToVerify) {
- this.object = objectToVerify;
- }
-
- public AugmentationVerifier<T> assertHasAugmentation(Class<? extends Augmentation<T>> augmentation) {
- assertHasAugmentation(object, augmentation);
- return (AugmentationVerifier<T>) this;
- }
-
- public static <T extends Augmentable<T>> void assertHasAugmentation(T object,
- Class<? extends Augmentation<T>> augmentation) {
- assertNotNull(object);
- assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", object.getAugmentation(augmentation));
- }
-
- public static <T extends Augmentable<T>> AugmentationVerifier<T> from(T obj) {
- return new AugmentationVerifier<T>(obj);
- }
-
-}
+++ /dev/null
-/*
- * 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.controller.sal.binding.test;
-
-public class BindingTestUtilities {
-
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.util;
-
-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.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-import com.google.common.base.Preconditions;
-
-public abstract class AbstractBindingSalConsumerInstance<D extends DataBrokerService, N extends NotificationService, R extends RpcConsumerRegistry> //
- 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;
- }
-
- @Override
- public <T extends RpcService> T getRpcService(Class<T> module) {
- return getRpcRegistryChecked().getRpcService(module);
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- Class<T> notificationType, NotificationListener<T> listener) {
- return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener);
- }
-
- @Override
- public ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
- org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- return getNotificationBrokerChecked().registerNotificationListener(listener);
- }
-
- @Override
- public DataModificationTransaction beginTransaction() {
- return getDataBrokerChecked().beginTransaction();
- }
-
- @Override
- @Deprecated
- public DataObject readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
- return getDataBrokerChecked().readConfigurationData(path);
- }
-
- @Override
- public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
- return getDataBrokerChecked().readOperationalData(path);
- }
-
- @Override
- @Deprecated
- public ListenerRegistration<DataChangeListener> registerDataChangeListener(
- InstanceIdentifier<? extends DataObject> path, DataChangeListener listener) {
- return getDataBrokerChecked().registerDataChangeListener(path, listener);
- }
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.util;
-
-import java.util.concurrent.ExecutorService;
-
-import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-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.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-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.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-public abstract class AbstractBindingSalProviderInstance<D extends DataProviderService, N extends NotificationProviderService, R extends RpcProviderRegistry> //
- extends AbstractBindingSalConsumerInstance<D, N, R> //
- implements //
- DataProviderService, //
- RpcProviderRegistry, //
- NotificationProviderService {
-
- public AbstractBindingSalProviderInstance(R rpcRegistry, N notificationBroker,
- D dataBroker) {
- super(rpcRegistry, notificationBroker, dataBroker);
- }
-
- @Override
- public Registration registerDataReader(
- InstanceIdentifier<? extends DataObject> path,
- DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
- return getDataBrokerChecked().registerDataReader(path, reader);
- }
-
- @Override
- public Registration registerCommitHandler(
- InstanceIdentifier<? extends DataObject> path,
- DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
- return getDataBrokerChecked().registerCommitHandler(path, commitHandler);
- }
-
- @Override
- public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>> registerCommitHandlerListener(
- RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>> commitHandlerListener) {
- return getDataBrokerChecked().registerCommitHandlerListener(commitHandlerListener);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
- throws IllegalStateException {
- return getRpcRegistryChecked().addRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
- throws IllegalStateException {
- return getRpcRegistryChecked().addRoutedRpcImplementation(type, implementation);
- }
-
- @Override
- public void publish(Notification notification) {
- getNotificationBrokerChecked().publish(notification);
- }
-
- @Override
- public void publish(Notification notification, ExecutorService service) {
- getNotificationBrokerChecked().publish(notification, service);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- L listener) {
- return getRpcRegistryChecked().registerRouteChangeListener(listener);
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- NotificationInterestListener interestListener) {
- return getNotificationBrokerChecked().registerInterestListener(interestListener);
- }
-}
+++ /dev/null
-/*
- * 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.controller.md.sal.binding.util;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- *
- *
- * @deprecated Use
- * {@link org.opendaylight.controller.md.sal.binding.api.ReadTransaction#read(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, InstanceIdentifier)}
- * instead.
- */
-@Deprecated
-public final class TypeSafeDataReader {
-
- private final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate;
-
- public DataReader<InstanceIdentifier<?>, DataObject> getDelegate() {
- return delegate;
- }
-
- public TypeSafeDataReader(
- final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
- this.delegate = delegate;
- }
-
- @SuppressWarnings("unchecked")
- public <D extends DataObject> D readConfigurationData(
- final InstanceIdentifier<D> path) {
- return (D) delegate.readConfigurationData(path);
- }
-
- @SuppressWarnings("unchecked")
- public <D extends DataObject> D readOperationalData(
- final InstanceIdentifier<D> path) {
- return (D) delegate.readOperationalData(path);
- }
-
- public static TypeSafeDataReader forReader(
- final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
- return new TypeSafeDataReader(delegate);
- }
-}