<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-broker-impl</artifactId>
<version>${mdsal.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-remote</artifactId>
+ <version>${mdsal.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-restconf-broker</artifactId>
+ <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>concepts</artifactId>
<version>${yangtools.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>restconf-client-api</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>restconf-client-impl</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
<!-- config-->
<dependency>
<artifactId>sal-connector-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-remote</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Supporting Libraries -->
<dependency>
* Returns a session specific instance (implementation) of requested
* YANG module implentation / service provided by consumer.
*
- * @param service
- * Broker service
* @return Session specific implementation of service
*/
<T extends RpcService> T getRpcService(Class<T> module);
org.opendaylight.controller.sal.binding.impl.*,
org.opendaylight.controller.sal.binding.codegen,
org.opendaylight.controller.sal.binding.codegen.*,
- org.opendaylight.controller.sal.binding.dom.*,
+ <!--org.opendaylight.controller.sal.binding.dom.*,-->
org.opendaylight.controller.sal.binding.osgi.*,
</Private-Package>
</instructions>
*/
package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import java.util.Hashtable;
import java.util.Map.Entry;
import java.util.Set;
-
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
/**
*
*/
@Override
public java.lang.AutoCloseable createInstance() {
-
+
RuntimeGeneratedMappingServiceProxy potential = tryToReuseGlobalInstance();
if(potential != null) {
return potential;
BindingIndependentMappingService, //
Delegator<BindingIndependentMappingService>, //
AutoCloseable {
-
+
private BindingIndependentMappingService delegate;
private ServiceReference<BindingIndependentMappingService> reference;
private BundleContext bundleContext;
this.delegate = Preconditions.checkNotNull(delegate);
}
- @Override
public CodecRegistry getCodecRegistry() {
return delegate.getCodecRegistry();
}
- @Override
public CompositeNode toDataDom(DataObject data) {
return delegate.toDataDom(data);
}
- @Override
public Entry<InstanceIdentifier, CompositeNode> toDataDom(
Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> entry) {
return delegate.toDataDom(entry);
}
- @Override
public InstanceIdentifier toDataDom(
org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path) {
return delegate.toDataDom(path);
}
- @Override
public DataObject dataObjectFromDataDom(
org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path,
CompositeNode result) throws DeserializationException {
return delegate.dataObjectFromDataDom(path, result);
}
- @Override
public org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> fromDataDom(InstanceIdentifier entry)
throws DeserializationException {
return delegate.fromDataDom(entry);
}
- @Override
public Set<QName> getRpcQNamesFor(Class<? extends RpcService> service) {
return delegate.getRpcQNamesFor(service);
}
- @Override
- public DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput) {
- return delegate.dataObjectFromDataDom(inputClass, domInput);
- }
-
@Override
public Optional<Class<? extends RpcService>> getRpcServiceClassFor(String namespace, String revision) {
- return delegate.getRpcServiceClassFor(namespace, revision);
+ return delegate.getRpcServiceClassFor(namespace,revision);
}
+ public DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput) {
+ return delegate.dataObjectFromDataDom(inputClass, domInput);
+ }
+
@Override
public void close() throws Exception {
if(delegate != null) {
*/
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.util.AbstractBindingSalProviderInstance;
import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
+import static com.google.common.base.Preconditions.checkState;
public class RootBindingAwareBroker implements //
Mutable, //
private final DataChange<P, D> dataChange;
private final D originalConfigurationSubtree;
-
-
private final D originalOperationalSubtree;
private final D updatedOperationalSubtree;
private final D updatedConfigurationSubtree;
<build>
<plugins>
+ <!-- TODO - unite yang-maven-plugin configuration in md-sal-->
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<artifactId>sal-remote</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
<url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
<tag>HEAD</tag>
</scm>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
</plugin>
</plugins>
</build>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- <version>1.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
</project>
+++ /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.restconf.service.impl;
-
-import java.util.concurrent.Future;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.BeginTransactionOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateNotificationStreamInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateNotificationStreamOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-public class SalRemoteServiceImpl implements SalRemoteService {
- @Override
- public Future<RpcResult<BeginTransactionOutput>> beginTransaction() {
- return null;
- }
-
- @Override
- public Future<RpcResult<CreateDataChangeEventSubscriptionOutput>> createDataChangeEventSubscription(CreateDataChangeEventSubscriptionInput input) {
- return null;
- }
-
- @Override
- public Future<RpcResult<CreateNotificationStreamOutput>> createNotificationStream(CreateNotificationStreamInput input) {
- return null;
- }
-}
<version>1.1-SNAPSHOT</version>
</parent>
<artifactId>sal-restconf-broker</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
<url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
<tag>HEAD</tag>
</scm>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
- <version>1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-util</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-remote</artifactId>
- <version>1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-broker-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-config</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-core-api</artifactId>
- <version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-client-api</artifactId>
<version>${yangtools.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>restconf-client-impl</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ <Bundle-Activator>org.opendaylight.controller.sal.restconf.broker.osgi.Activator</Bundle-Activator>
+ <Import-Package>
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>
+ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ </codeGeneratorClass>
+ <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
+ <additionalConfiguration>
+ <namespaceToPackage1>
+ urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+ </namespaceToPackage1>
+ </additionalConfiguration>
+ </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>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-jmx-generator-plugin</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-data-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public final class DataBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractDataBrokerImplModule
+ {
+
+ public DataBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public DataBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ DataBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ //TODO:implement
+ throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-data-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public class DataBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractDataBrokerImplModuleFactory
+{
+
+
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-notification-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public final class NotificationBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractNotificationBrokerImplModule
+ {
+
+ public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ NotificationBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ //TODO:implement
+ throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-notification-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public class NotificationBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractNotificationBrokerImplModuleFactory
+{
+
+
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-rpc-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public final class RpcBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractRpcBrokerImplModule
+ {
+
+ public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ RpcBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ //TODO:implement
+ throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-rpc-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public class RpcBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractRpcBrokerImplModuleFactory
+{
+
+
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-runtime-generated-mapping
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public final class RuntimeMappingModule extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractRuntimeMappingModule
+ {
+
+ public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ RuntimeMappingModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ //TODO:implement
+ throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-runtime-generated-mapping
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public class RuntimeMappingModuleFactory extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractRuntimeMappingModuleFactory
+{
+
+
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-broker-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public final class SalRemoteServiceBrokerModule extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractSalRemoteServiceBrokerModule
+ {
+
+ public SalRemoteServiceBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public SalRemoteServiceBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ SalRemoteServiceBrokerModule oldModule, java.lang.AutoCloseable oldInstance) {
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ protected void customValidation(){
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ //TODO:implement
+ throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-restconf-broker-impl yang module local name: restconf-broker-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Feb 10 15:32:31 CET 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.restconf.broker;
+
+/**
+*
+*/
+public class SalRemoteServiceBrokerModuleFactory extends org.opendaylight.controller.config.yang.md.sal.restconf.broker.AbstractSalRemoteServiceBrokerModuleFactory
+{
+
+
+}
+++ /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.impl;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-public class NotificationServiceImpl implements NotificationService {
- @Override
- public <T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
-
- }
-
- @Override
- public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
-
- }
-
- @Override
- public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
-
- }
-
- @Override
- public <T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
-
- }
-
- @Override
- public <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
- //TODO implementation using sal-remote
- return null;
- }
-
- @Override
- public Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- //TODO implementation using sal-remote
- return null;
- }
-}
* 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;
+package org.opendaylight.controller.sal.restconf.binding.impl;
import java.net.URL;
import java.util.concurrent.Future;
package org.opendaylight.controller.sal.restconf.broker;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.Consumer;
-import org.opendaylight.controller.sal.core.api.Provider;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+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.NotificationService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.restconf.broker.impl.RemoteServicesFactory;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static com.google.common.base.Preconditions.checkState;
-public class SalRemoteServiceBroker implements Broker,AutoCloseable {
+public class SalRemoteServiceBroker implements BindingAwareBroker,AutoCloseable {
- @Override
- public void close() throws Exception {
+ private static final Logger logger = LoggerFactory.getLogger(SalRemoteServiceBroker.class.toString());
+ private ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
+
+ private final String identifier;
+
+ private RpcConsumerRegistry rpcBroker;
+ private NotificationService notificationBroker;
+ private DataBrokerService dataBroker;
+ private final RemoteServicesFactory servicesFactory;
+
+ public SalRemoteServiceBroker(String instanceName,RestconfClientContext clientContext){
+ this.identifier = instanceName;
+ this.servicesFactory = new RemoteServicesFactory(clientContext);
}
- @Override
- public ConsumerSession registerConsumer(Consumer cons, BundleContext context) {
- return null;
+ public void start() {
+ logger.info("Starting Binding Aware Broker: {}", identifier);
+
+ supportedConsumerServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
+ .put(NotificationService.class, servicesFactory.getNotificationService()) //
+ .put(DataBrokerService.class,servicesFactory.getDataBrokerService() ) //
+ .put(RpcConsumerRegistry.class,servicesFactory.getRpcConsumerRegistry() ).build();
}
+ public ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx) {
+ throw new UnsupportedOperationException();
+ }
+ @Override
+ public void close() throws Exception {
+ //TODO decide if serviceFactory should close clientContext or it has to be closed by consumer
+ }
@Override
- public ProviderSession registerProvider(Provider prov, BundleContext context) {
- return null;
+ public ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx) {
+ checkState(supportedConsumerServices != null, "Broker is not initialized.");
+ return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
}
+
}
--- /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.restconf.broker.event;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.DataChangedNotification;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RemoteDataChangeEvent implements DataChangeEvent<InstanceIdentifier<? extends DataObject>,DataObject> {
+
+
+ private final DataChangedNotification dataChangedNotification;
+
+
+ public RemoteDataChangeEvent(DataChangedNotification dataChangedNotification){
+
+ this.dataChangedNotification = dataChangedNotification;
+ }
+
+ @Override
+ public DataObject getOriginalConfigurationSubtree() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public DataObject getOriginalOperationalSubtree() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public DataObject getUpdatedConfigurationSubtree() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public DataObject getUpdatedOperationalSubtree() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Map<InstanceIdentifier<?>, DataObject> getCreatedOperationalData() {
+ return new HashMap<InstanceIdentifier<?>, DataObject>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 0 && d.getStore().getIntValue() == 1){
+ put(d.getPath(),d);
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Map<InstanceIdentifier<?>, DataObject> getCreatedConfigurationData() {
+ return new HashMap<InstanceIdentifier<?>, DataObject>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 0 && d.getStore().getIntValue() == 0){
+ put(d.getPath(),d);
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Map<InstanceIdentifier<?>, DataObject> getUpdatedOperationalData() {
+ return new HashMap<InstanceIdentifier<?>, DataObject>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 1){
+ put(d.getPath(),d);
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Map<InstanceIdentifier<?>, DataObject> getUpdatedConfigurationData() {
+ return new HashMap<InstanceIdentifier<?>, DataObject>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 0){
+ put(d.getPath(),d);
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Set<InstanceIdentifier<?>> getRemovedConfigurationData() {
+ return new HashSet<InstanceIdentifier<?>>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 2 && d.getStore().getIntValue() == 0){
+ add(d.getPath());
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Set<InstanceIdentifier<?>> getRemovedOperationalData() {
+ return new HashSet<InstanceIdentifier<?>>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 2 && d.getStore().getIntValue() == 1){
+ add(d.getPath());
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Map<InstanceIdentifier<?>, DataObject> getOriginalConfigurationData() {
+ return new HashMap<InstanceIdentifier<?>, DataObject>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 0){
+ put(d.getPath(),d);
+ }
+ }
+ }};
+ }
+
+ @Override
+ public Map<InstanceIdentifier<?>, DataObject> getOriginalOperationalData() {
+ return new HashMap<InstanceIdentifier<?>, DataObject>(){{
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){
+ if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 1){
+ put(d.getPath(),d);
+ }
+ }
+ }};
+ }
+}
--- /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.restconf.broker.impl;
+
+import com.google.common.base.Optional;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+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.common.DataStoreIdentifier;
+import org.opendaylight.controller.sal.restconf.broker.listeners.RemoteDataChangeNotificationListener;
+import org.opendaylight.controller.sal.restconf.broker.tools.RemoteStreamTools;
+import org.opendaylight.controller.sal.restconf.broker.transactions.RemoteDataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.BeginTransactionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
+import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
+import org.opendaylight.yangtools.restconf.client.api.event.ListenableEventStreamContext;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataBrokerServiceImpl implements DataBrokerService {
+
+ private static final Logger logger = LoggerFactory.getLogger(DataBrokerServiceImpl.class.toString());
+ private RestconfClientContext restconfClientContext;
+ private SalRemoteService salRemoteService;
+
+ public DataBrokerServiceImpl(RestconfClientContext restconfClientContext) {
+ this.restconfClientContext = restconfClientContext;
+ this.salRemoteService = this.restconfClientContext.getRpcServiceContext(SalRemoteService.class).getRpcService();
+ }
+ @Override
+ public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public DataObject getData(InstanceIdentifier<? extends DataObject> data) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public DataObject getConfigurationData(InstanceIdentifier<?> data) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public DataModificationTransaction beginTransaction() {
+ Future<RpcResult<BeginTransactionOutput>> rpcResultFuture = this.salRemoteService.beginTransaction();
+ //TODO finish yang model for proper remoteDataModificationTransaction setup
+ RemoteDataModificationTransaction remoteDataModificationTransaction = new RemoteDataModificationTransaction();
+ return remoteDataModificationTransaction;
+ }
+
+ @Override
+ public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
+ throw new UnsupportedOperationException("Deprecated");
+ }
+
+ @Override
+ public DataObject readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+ try {
+ Optional<DataObject> optDataObject = (Optional<DataObject>) this.restconfClientContext.getConfigurationDatastore().readData(path).get();
+ if (optDataObject.isPresent()){
+ return optDataObject.get();
+ }
+ } catch (InterruptedException e) {
+ logger.trace("Reading configuration data interrupted {}",e);
+ } catch (ExecutionException e) {
+ logger.trace("Reading configuration execution exception {}",e);
+ }
+ throw new IllegalStateException("No data to return.");
+ }
+
+ @Override
+ public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
+ try {
+ Optional<DataObject> optDataObject = (Optional<DataObject>) this.restconfClientContext.getOperationalDatastore().readData(path).get();
+ if (optDataObject.isPresent()){
+ return optDataObject.get();
+ }
+ } catch (InterruptedException e) {
+ logger.trace("Reading configuration data interrupted {}",e);
+ } catch (ExecutionException e) {
+ logger.trace("Reading configuration execution exception {}",e);
+ }
+ throw new IllegalStateException("No data to return.");
+ }
+ @Override
+ public ListenerRegistration<DataChangeListener> registerDataChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener listener) {
+ CreateDataChangeEventSubscriptionInputBuilder inputBuilder = new CreateDataChangeEventSubscriptionInputBuilder();
+ Future<RpcResult<CreateDataChangeEventSubscriptionOutput>> rpcResultFuture = salRemoteService.createDataChangeEventSubscription(inputBuilder.setPath(path).build());
+ String streamName = "";
+ try {
+ if (rpcResultFuture.get().isSuccessful()){
+ streamName = rpcResultFuture.get().getResult().getStreamName();
+ }
+ } catch (InterruptedException e) {
+ logger.trace("Interupted while getting rpc result due to {}",e);
+ } catch (ExecutionException e) {
+ logger.trace("Execution exception while getting rpc result due to {}",e);
+ }
+ final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext,streamName);
+ ListenableEventStreamContext restConfListenableEventStreamContext = restconfClientContext.getEventStreamContext(desiredEventStream.get(streamName));
+ RemoteDataChangeNotificationListener remoteDataChangeNotificationListener = new RemoteDataChangeNotificationListener(listener);
+ restConfListenableEventStreamContext.registerNotificationListener(remoteDataChangeNotificationListener);
+ return new SalRemoteDataListenerRegistration(listener);
+ }
+
+ private class SalRemoteDataListenerRegistration implements ListenerRegistration<DataChangeListener> {
+ private DataChangeListener dataChangeListener;
+ public SalRemoteDataListenerRegistration(DataChangeListener dataChangeListener){
+ this.dataChangeListener = dataChangeListener;
+ }
+ @Override
+ public DataChangeListener getInstance() {
+ return this.dataChangeListener;
+ }
+ @Override
+ public void close() 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.restconf.broker.impl;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import org.opendaylight.controller.sal.binding.api.NotificationListener;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.restconf.broker.listeners.RemoteNotificationListener;
+import org.opendaylight.controller.sal.restconf.broker.tools.RemoteStreamTools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.QName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
+import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public class NotificationServiceImpl implements NotificationService {
+ private SalRemoteService salRemoteService;
+ private RestconfClientContext restconfClientContext;
+
+ private final Multimap<Class<? extends Notification>,NotificationListener<? extends Object>> listeners;
+ private ExecutorService _executor;
+
+ public NotificationServiceImpl(RestconfClientContext restconfClienetContext){
+ this.restconfClientContext = restconfClienetContext;
+ this.salRemoteService = this.restconfClientContext.getRpcServiceContext(SalRemoteService.class).getRpcService();
+
+ HashMultimap<Class<? extends Notification>,NotificationListener<? extends Object>> _create = HashMultimap.<Class<? extends Notification>, NotificationListener<? extends Object>>create();
+ SetMultimap<Class<? extends Notification>,NotificationListener<? extends Object>> _synchronizedSetMultimap = Multimaps.<Class<? extends Notification>, NotificationListener<? extends Object>>synchronizedSetMultimap(_create);
+ this.listeners = _synchronizedSetMultimap;
+
+ }
+ public ExecutorService getExecutor() {
+ return this._executor;
+ }
+
+ public void setExecutor(final ExecutorService executor) {
+ this._executor = executor;
+ }
+
+ @Override
+ public <T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
+ this.listeners.put(notificationType, listener);
+ }
+
+ @Override
+ public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Deprecated method. Use registerNotificationListener instead.");
+ throw _unsupportedOperationException;
+ }
+
+ @Override
+ public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(
+ "Deprecated method. Use RegisterNotificationListener returned value to close registration.");
+ throw _unsupportedOperationException;
+ }
+
+ @Override
+ public <T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
+ this.listeners.remove(notificationType, listener);
+ }
+
+ @Override
+ public <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
+ //TODO implementation using sal-remote
+ List<QName> notifications = new ArrayList<QName>();
+ notifications.add(new QName(notificationType.toString()));
+ String notificationStreamName = RemoteStreamTools.createNotificationStream(salRemoteService, notifications);
+ final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext, notificationStreamName);
+ RemoteNotificationListener remoteNotificationListener = new RemoteNotificationListener(listener);
+ ListenerRegistration listenerRegistration = restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName))).registerNotificationListener(remoteNotificationListener);
+ SalNotificationRegistration salNotificationRegistration = new SalNotificationRegistration(listenerRegistration);
+ return salNotificationRegistration;
+ }
+
+ @Override
+ public Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+ //TODO implementation using sal-remote
+ String notificationStreamName = RemoteStreamTools.createNotificationStream(salRemoteService, null);
+ final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext, notificationStreamName);
+ ListenerRegistration listenerRegistration = restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName))).registerNotificationListener(listener);
+ return listenerRegistration;
+ }
+
+ private class SalNotificationRegistration<T extends Notification> implements Registration<NotificationListener<T>>{
+ private Registration registration;
+
+ public SalNotificationRegistration(ListenerRegistration listenerRegistration){
+ this.registration = listenerRegistration;
+ }
+
+ @Override
+ public NotificationListener<T> getInstance() {
+ return this.getInstance();
+ }
+
+ @Override
+ public void close() throws Exception {
+ this.registration.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.sal.restconf.broker.impl;
+
+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.restconf.client.api.RestconfClientContext;
+
+public class RemoteServicesFactory {
+
+ private final RestconfClientContext restconfClientContext;
+
+ public RemoteServicesFactory(RestconfClientContext restconfClientContext){
+ this.restconfClientContext = restconfClientContext;
+ }
+
+ public DataBrokerService getDataBrokerService(){
+ return new DataBrokerServiceImpl(this.restconfClientContext);
+ }
+
+ public NotificationService getNotificationService(){
+ return new NotificationServiceImpl(this.restconfClientContext);
+ }
+
+ public RpcConsumerRegistry getRpcConsumerRegistry(){
+ return new RpcConsumerRegistryImpl(this.restconfClientContext);
+ }
+
+}
* 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;
+package org.opendaylight.controller.sal.restconf.broker.impl;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
import org.opendaylight.yangtools.yang.binding.RpcService;
public class RpcConsumerRegistryImpl implements RpcConsumerRegistry {
+
+ private RestconfClientContext restconfClientContext;
+
+ public RpcConsumerRegistryImpl(RestconfClientContext restconfClientContext){
+ this.restconfClientContext = restconfClientContext;
+ }
@Override
public <T extends RpcService> T getRpcService(Class<T> module) {
- //TODO implementation using restconf-client
- return null;
+ return restconfClientContext.getRpcServiceContext(module).getRpcService();
}
}
--- /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.restconf.broker.listeners;
+
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.restconf.broker.event.RemoteDataChangeEvent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.DataChangedNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteListener;
+
+public class RemoteDataChangeNotificationListener implements SalRemoteListener {
+
+
+ private final DataChangeListener dataChangeListener;
+
+ public RemoteDataChangeNotificationListener(DataChangeListener dataChangeListener){
+ this.dataChangeListener = dataChangeListener;
+ }
+ @Override
+ public void onDataChangedNotification(DataChangedNotification notification) {
+ this.dataChangeListener.onDataChanged(new RemoteDataChangeEvent(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.sal.restconf.broker.listeners;
+
+import org.opendaylight.controller.sal.binding.api.NotificationListener;
+
+public class RemoteNotificationListener implements org.opendaylight.yangtools.yang.binding.NotificationListener {
+
+ org.opendaylight.controller.sal.binding.api.NotificationListener listener;
+
+ public RemoteNotificationListener(NotificationListener listener){
+ this.listener = listener;
+ }
+ public NotificationListener getListener(){
+ return this.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.restconf.broker.listeners;
+
+import org.opendaylight.controller.sal.binding.api.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+
+public class SalNotificationListener implements NotificationListener {
+ private NotificationListener notificationListener;
+
+ public SalNotificationListener( NotificationListener notificationListener){
+ this.notificationListener = notificationListener;
+ }
+ @Override
+ public void onNotification(Notification notification) {
+ this.notificationListener.onNotification(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.sal.restconf.broker.osgi;
+
+import java.util.Hashtable;
+import javassist.ClassPool;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+
+ private ServiceRegistration<BindingIndependentMappingService> mappingReg;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
+ service.setPool(new ClassPool());
+ service.init();
+ startRuntimeMappingService(service, context);
+ }
+
+ private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) {
+ Hashtable<String, String> properties = new Hashtable<String, String>();
+ mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ if(mappingReg != null) {
+ mappingReg.unregister();
+ }
+ }
+}
--- /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.restconf.broker.tools;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateNotificationStreamInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateNotificationStreamOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.QName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
+import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RemoteStreamTools {
+ private static final Logger logger = LoggerFactory.getLogger(RemoteStreamTools.class.toString());
+
+ public static String createNotificationStream(SalRemoteService salRemoteService,List<QName> notifications){
+ CreateNotificationStreamInputBuilder notificationStreamInputBuilder = new CreateNotificationStreamInputBuilder();
+
+ if (null == notifications){
+ notificationStreamInputBuilder.setNotifications(notifications);
+ }
+
+ Future<RpcResult<CreateNotificationStreamOutput>> notificationStream = salRemoteService.createNotificationStream(notificationStreamInputBuilder.build());
+
+ String nofiticationStreamIdentifier = "";
+ try {
+ if (notificationStream.get().isSuccessful()){
+ nofiticationStreamIdentifier = notificationStream.get().getResult().getNotificationStreamIdentifier();
+ }
+ } catch (InterruptedException e) {
+ logger.trace("Interrupted while resolving notification stream identifier due to {}",e);
+ } catch (ExecutionException e) {
+ logger.trace("Execution exception while resolving notification stream identifier due to {}",e);
+ }
+ return nofiticationStreamIdentifier;
+ }
+
+ public static Map<String,EventStreamInfo> createEventStream(RestconfClientContext restconfClientContext, String desiredStreamName){
+ ListenableFuture<Set<EventStreamInfo>> availableEventStreams = restconfClientContext.getAvailableEventStreams();
+ final Map<String,EventStreamInfo> desiredEventStream = new HashMap<String,EventStreamInfo>();
+
+ try {
+ Iterator<EventStreamInfo> it = availableEventStreams.get().iterator();
+ while (it.hasNext()){
+ if (it.next().getIdentifier().equals(desiredStreamName)){
+ desiredEventStream.put(desiredStreamName,it.next());
+ }
+ }
+ } catch (InterruptedException e) {
+ logger.trace("Resolving of event stream interrupted due to {}",e);
+ } catch (ExecutionException e) {
+ logger.trace("Resolving of event stream failed due to {}",e);
+ }
+ return desiredEventStream;
+ }
+}
--- /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.restconf.broker.transactions;
+
+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.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.common.RpcResult;
+
+public class RemoteDataModificationTransaction implements DataModificationTransaction {
+ //TODO implement this
+
+ @Override
+ public Object getIdentifier() {
+ return null;
+ }
+
+ @Override
+ public TransactionStatus getStatus() {
+ return null;
+ }
+
+ @Override
+ public void putRuntimeData(InstanceIdentifier<? extends DataObject> path, DataObject data) {
+
+ }
+
+ @Override
+ public void putOperationalData(InstanceIdentifier<? extends DataObject> path, DataObject data) {
+
+ }
+
+ @Override
+ public void putConfigurationData(InstanceIdentifier<? extends DataObject> path, DataObject data) {
+
+ }
+
+ @Override
+ public void removeRuntimeData(InstanceIdentifier<? extends DataObject> path) {
+
+ }
+
+ @Override
+ public void removeOperationalData(InstanceIdentifier<? extends DataObject> path) {
+
+ }
+
+ @Override
+ public void removeConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+
+ }
+
+ @Override
+ public Future<RpcResult<TransactionStatus>> commit() {
+ return null;
+ }
+
+ @Override
+ public ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener) {
+ return null;
+ }
+
+ @Override
+ public Map<InstanceIdentifier<? extends DataObject>, DataObject> getCreatedOperationalData() {
+ return null;
+ }
+
+ @Override
+ public Map<InstanceIdentifier<? extends DataObject>, DataObject> getCreatedConfigurationData() {
+ return null;
+ }
+
+ @Override
+ public Map<InstanceIdentifier<? extends DataObject>, DataObject> getUpdatedOperationalData() {
+ return null;
+ }
+
+ @Override
+ public Map<InstanceIdentifier<? extends DataObject>, DataObject> getUpdatedConfigurationData() {
+ return null;
+ }
+
+ @Override
+ public Set<InstanceIdentifier<? extends DataObject>> getRemovedConfigurationData() {
+ return null;
+ }
+
+ @Override
+ public Set<InstanceIdentifier<? extends DataObject>> getRemovedOperationalData() {
+ return null;
+ }
+
+ @Override
+ public Map<InstanceIdentifier<? extends DataObject>, DataObject> getOriginalConfigurationData() {
+ return null;
+ }
+
+ @Override
+ public Map<InstanceIdentifier<? extends DataObject>, DataObject> getOriginalOperationalData() {
+ return null;
+ }
+
+ @Override
+ public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
+ return null;
+ }
+
+ @Override
+ public DataObject readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+ return null;
+ }
+}
--- /dev/null
+// vi: set smarttab et sw=4 tabstop=4:
+module opendaylight-sal-restconf-broker-impl {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:restconf:broker";
+ prefix "restconf-impl";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding {prefix sal;}
+ import opendaylight-md-sal-dom {prefix dom;}
+ import opendaylight-md-sal-common {prefix common;}
+
+ description
+ "Service definition for Restconf MD-SAL.";
+
+ revision "2014-02-10" {
+ description
+ "Initial revision";
+ }
+
+ identity binding-dom-mapping-service {
+ base config:service-type;
+ config:java-class "org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService";
+ }
+
+
+ identity restconf-broker-impl {
+ base config:module-type;
+ config:provided-service sal:binding-data-consumer-broker;
+ config:provided-service sal:binding-notification-subscription-service;
+ /*TODO provide RpcConsumerRegistry*/
+ config:java-name-prefix SalRemoteServiceBroker;
+ }
+
+ identity restconf-data-broker {
+ base config:module-type;
+ config:provided-service sal:binding-data-broker;
+ config:java-name-prefix DataBrokerImpl;
+ }
+
+ identity restconf-rpc-broker {
+ base config:module-type;
+ config:provided-service sal:binding-rpc-registry;
+ config:java-name-prefix RpcBrokerImpl;
+ }
+
+ identity restconf-notification-broker {
+ base config:module-type;
+ config:provided-service sal:binding-notification-service;
+ config:java-name-prefix NotificationBrokerImpl;
+ }
+
+ identity restconf-runtime-generated-mapping {
+ base config:module-type;
+ config:provided-service binding-dom-mapping-service;
+ config:java-name-prefix RuntimeMapping;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case restconf-broker-impl {
+ when "/config:modules/config:module/config:type = 'restconf-broker-impl'";
+
+ /*
+ container rpc-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity sal:binding-rpc-registry;
+ }
+ }
+ }*/
+
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity sal:binding-data-broker;
+ }
+ }
+ }
+
+ container notification-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity sal:binding-notification-service;
+ }
+ }
+ }
+ }
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case restconf-data-broker {
+ when "/config:modules/config:module/config:type = 'restconf-data-broker'";
+ container dom-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity dom:dom-broker-osgi-registry;
+ }
+ }
+ }
+
+ container mapping-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity binding-dom-mapping-service;
+ }
+ }
+ }
+ }
+ }
+
+
+ augment "/config:modules/config:module/config:state" {
+ case restconf-runtime-generated-mapping {
+ when "/config:modules/config:module/config:type = 'restconf-runtime-generated-mapping'";
+ }
+ }
+
+ augment "/config:modules/config:module/config:state" {
+ case restconf-data-broker {
+ when "/config:modules/config:module/config:type = 'restconf-data-broker'";
+ container data {
+ uses common:data-state;
+ }
+ }
+ }
+ augment "/config:modules/config:module/config:state" {
+ case restconf-rpc-broker {
+ when "/config:modules/config:module/config:type = 'restconf-rpc-broker'";
+ uses common:rpc-state;
+ }
+ }
+ augment "/config:modules/config:module/config:state" {
+ case restconf-notification-broker {
+ when "/config:modules/config:module/config:type = 'restconf-notification-broker'";
+ uses common:notification-state;
+ }
+ }
+}
\ No newline at end of file
--- /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.impl.test;
+
+public class DataBrokerImplTest {
+
+ public static void main(String[] args){
+
+ }
+}
--- /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.impl.test;
+
+public class NotificationServiceImplTest {
+
+ public static void main(String[] args){
+
+ }
+}