Merge "Convert yanglib project to blueprint"
authorJakub Morvay <jmorvay@cisco.com>
Tue, 27 Jun 2017 18:34:20 +0000 (18:34 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 27 Jun 2017 18:34:20 +0000 (18:34 +0000)
52 files changed:
features/restconf/odl-restconf-noauth/pom.xml
features/restconf/odl-restconf-noauth/src/main/feature/feature.xml
netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSource.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/NetconfServerSessionNegotiatorFactory.java
netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfCapabilityMonitoringService.java
netconf/netconf-it/src/test/java/org/opendaylight/netconf/it/NetconfITTest.java
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/xml/model/MonitoringSchema.java
netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/xml/model/NetconfState.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/NetconfMessageUtil.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemas.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacade.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpc.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapter.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpc.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTx.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NodeContainerProxy.java
restconf/sal-rest-connector-config/pom.xml
restconf/sal-rest-connector-config/src/main/resources/initial/10-rest-connector.xml
restconf/sal-rest-connector-config/src/main/resources/initial/10-restconf-service.xml
restconf/sal-rest-connector-config/src/main/resources/initial/restconf.cfg [new file with mode: 0644]
restconf/sal-rest-connector/pom.xml
restconf/sal-rest-connector/src/main/java/org/opendaylight/RestconfWrapperProviders.java [deleted file]
restconf/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModule.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/rest/connector/RestConnectorModuleFactory.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/sal/restconf/service/JSONRestconfServiceModule.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/controller/config/yang/sal/restconf/service/JSONRestconfServiceModuleFactory.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfProviderImpl.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Config.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Delete.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Get.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Operational.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Post.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Put.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/RestConnectorRuntimeMXBean.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Rpcs.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/package-info.java [new file with mode: 0644]
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/RestConnectorProvider.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/JsonNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/XmlNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/resources/org/opendaylight/blueprint/restconf-config.xml [new file with mode: 0644]
restconf/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang
restconf/sal-rest-connector/src/main/yang/sal-restconf-service.yang
restconf/sal-rest-connector/src/test/java/org/opendaylight/RestconfWrapperProvidersTest.java [deleted file]
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/RestConnectorProviderTest.java

index eaeeb23d39082829b647a03eccdc5c8d41b4f720..248e0fdb7e8a987c3e4ad1b4d71e58f8ac2c17c1 100644 (file)
             <type>xml</type>
             <classifier>configrestconfservice</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.netconf</groupId>
+            <artifactId>sal-rest-connector-config</artifactId>
+            <version>${project.version}</version>
+            <type>cfg</type>
+            <classifier>restconf</classifier>
+         </dependency>
     </dependencies>
 </project>
index 446396a164e6837a2c035c7fbba528b2e61a5b57..61788c2509c18ab8aa193d48201023be63c39367 100644 (file)
@@ -8,11 +8,14 @@
  -->
 <features name="odl-controller-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
     <feature name="odl-restconf-noauth" version="${project.version}">
-        <configfile finalname="${config.configfile.directory}/${config.restconf.configfile}">
+        <configfile finalname="${config.configfile.directory}/${config.restconf.configfile}" override="true">
             mvn:org.opendaylight.netconf/sal-rest-connector-config/${project.version}/xml/config
         </configfile>
         <configfile finalname="${config.configfile.directory}/${config.restconf.service.configfile}">
             mvn:org.opendaylight.netconf/sal-rest-connector-config/${project.version}/xml/configrestconfservice
         </configfile>
+        <configfile finalname="etc/org.opendaylight.restconf.cfg">
+            mvn:org.opendaylight.netconf/sal-rest-connector-config/${project.version}/cfg/restconf
+        </configfile>
     </feature>
 </features>
index 347278c30135ce6f106e4e81c891a8e344d34168..69abbad23f0ad4d1ab823fac4a99a43211710f95 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.netconf.messagebus.eventsources.netconf;
 
 import static com.google.common.util.concurrent.Futures.immediateFuture;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
@@ -28,7 +27,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.regex.Pattern;
-import javax.annotation.Nullable;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
@@ -142,13 +140,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
         final List<Stream> availableStreams;
         try {
             availableStreams = mount.getAvailableStreams();
-            streamMap = Maps.uniqueIndex(availableStreams, new Function<Stream, String>() {
-                @Nullable
-                @Override
-                public String apply(@Nullable Stream input) {
-                    return input.getName().getValue();
-                }
-            });
+            streamMap = Maps.uniqueIndex(availableStreams, input -> input.getName().getValue());
         } catch (ReadFailedException e) {
             LOG.warn("Can not read streams for node {}", mount.getNodeId());
         }
@@ -165,7 +157,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
     }
 
     @Override
-    public Future<RpcResult<Void>> disJoinTopic(DisJoinTopicInput input) {
+    public Future<RpcResult<Void>> disJoinTopic(final DisJoinTopicInput input) {
         for (NotificationTopicRegistration reg : notificationTopicRegistrations.values()) {
             reg.unRegisterNotificationTopic(input.getTopicId());
         }
@@ -234,7 +226,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
         }
     }
 
-    private void publishNotification(final DOMNotification notification, TopicId topicId) {
+    private void publishNotification(final DOMNotification notification, final TopicId topicId) {
         final ContainerNode topicNotification = Builders.containerBuilder().withNodeIdentifier(TOPIC_NOTIFICATION_ARG)
                 .withChild(ImmutableNodes.leafNode(TOPIC_ID_ARG, topicId))
                 .withChild(ImmutableNodes.leafNode(EVENT_SOURCE_ARG, mount.getNodeId()))
@@ -272,7 +264,7 @@ public class NetconfEventSource implements EventSource, DOMNotificationListener
      * @param notificationPattern pattern
      * @return notification paths
      */
-    private List<SchemaPath> getMatchingNotifications(NotificationPattern notificationPattern) {
+    private List<SchemaPath> getMatchingNotifications(final NotificationPattern notificationPattern) {
         final String regex = notificationPattern.getValue();
 
         final Pattern pattern = Pattern.compile(regex);
index 3d37f8ec13ddeb0401c0e5c82b17956ba6141b1c..b8f5332d8d76f2f5d1844854fbc5aaf2b74f68db 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.impl;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableSet;
@@ -137,12 +136,7 @@ public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorF
     }
 
     public static Set<String> transformCapabilities(final Capabilities capabilities) {
-        return Sets.newHashSet(Collections2.transform(capabilities.getCapability(), new Function<Uri, String>() {
-            @Override
-            public String apply(final Uri uri) {
-                return uri.getValue();
-            }
-        }));
+        return Sets.newHashSet(Collections2.transform(capabilities.getCapability(), Uri::getValue));
     }
 
 }
index 489d984a52ae37f28b292dd7e08bea5f8413f24b..f48a477a58e6b8dc145a7c5c188b4cd0b0f73b09 100644 (file)
@@ -49,12 +49,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
     private static final List<Schema.Location> NETCONF_LOCATIONS = ImmutableList.of(NETCONF_LOCATION);
     private static final BasicCapability CANDIDATE_CAPABILITY =
             new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0");
-    private static final Function<Capability, Uri> CAPABILITY_TO_URI = new Function<Capability, Uri>() {
-        @Override
-        public Uri apply(final Capability input) {
-            return new Uri(input.getCapabilityUri());
-        }
-    };
+    private static final Function<Capability, Uri> CAPABILITY_TO_URI = input -> new Uri(input.getCapabilityUri());
 
     private final NetconfOperationServiceFactory netconfOperationProvider;
     private final Map<Uri, Capability> capabilities = Maps.newHashMap();
@@ -95,13 +90,13 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
                     revision.get(), revisionMapRequest.keySet());
 
             return schema;
-        } else {
-            Preconditions.checkState(revisionMapRequest.size() == 1,
-                    "Expected 1 capability for module %s, available revisions : %s", moduleName,
-                    revisionMapRequest.keySet());
-            //Only one revision is present, so return it
-            return revisionMapRequest.values().iterator().next();
         }
+
+        Preconditions.checkState(revisionMapRequest.size() == 1,
+                "Expected 1 capability for module %s, available revisions : %s", moduleName,
+                revisionMapRequest.keySet());
+        //Only one revision is present, so return it
+        return revisionMapRequest.values().iterator().next();
     }
 
     private void updateCapabilityToSchemaMap(final Set<Capability> added, final Set<Capability> removed) {
@@ -134,7 +129,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
         }
     }
 
-    private static boolean isValidModuleCapability(Capability cap) {
+    private static boolean isValidModuleCapability(final Capability cap) {
         return cap.getModuleName().isPresent()
                 && cap.getRevision().isPresent()
                 && cap.getCapabilitySchema().isPresent();
@@ -149,12 +144,9 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
         listeners.add(listener);
         listener.onCapabilitiesChanged(getCapabilities());
         listener.onSchemasChanged(getSchemas());
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                synchronized (NetconfCapabilityMonitoringService.this) {
-                    listeners.remove(listener);
-                }
+        return () -> {
+            synchronized (NetconfCapabilityMonitoringService.this) {
+                listeners.remove(listener);
             }
         };
     }
@@ -219,7 +211,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
     }
 
     @Override
-    public synchronized void onCapabilitiesChanged(Set<Capability> added, Set<Capability> removed) {
+    public synchronized void onCapabilitiesChanged(final Set<Capability> added, final Set<Capability> removed) {
         onCapabilitiesAdded(added);
         onCapabilitiesRemoved(removed);
         updateCapabilityToSchemaMap(added, removed);
@@ -231,7 +223,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
         }
     }
 
-    private void notifyCapabilityChanged(Capabilities capabilities) {
+    private void notifyCapabilityChanged(final Capabilities capabilities) {
         for (NetconfMonitoringService.CapabilitiesListener listener : listeners) {
             listener.onCapabilitiesChanged(capabilities);
             listener.onSchemasChanged(getSchemas());
@@ -260,7 +252,7 @@ class NetconfCapabilityMonitoringService implements CapabilityListener, AutoClos
 
     private void onCapabilitiesRemoved(final Set<Capability> removedCaps) {
         for (final Capability addedCap : removedCaps) {
-            capabilities.remove(CAPABILITY_TO_URI.apply(addedCap));
+            capabilities.remove(new Uri(addedCap.getCapabilityUri()));
         }
     }
 
index 5d7ce7d0f7a41170c8213a353f468a831c60c382..fc97e693db29f8f07bd3c937cd547bd313f680cf 100644 (file)
@@ -15,7 +15,6 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 
-import com.google.common.base.Function;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -339,12 +338,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
     }
 
     public Set<String> getServiceReferences(final List<ObjectName> testingDeps) {
-        return new HashSet<>(Lists.transform(testingDeps, new Function<ObjectName, String>() {
-            @Override
-            public String apply(final ObjectName input) {
-                return ObjectNameUtil.getReferenceName(input);
-            }
-        }));
+        return new HashSet<>(Lists.transform(testingDeps, ObjectNameUtil::getReferenceName));
     }
 
     public void commit(final TestingNetconfClient netconfClient) throws Exception {
index b3e64c5bc7146914d9776eba9325d0371c33ed3d..57ce954dcea21a17abb18d3e11bc3c4df0801e71 100644 (file)
@@ -8,12 +8,9 @@
 
 package org.opendaylight.netconf.monitoring.xml.model;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Collections2;
 import java.util.Collection;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import javax.xml.bind.annotation.XmlElement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
@@ -22,7 +19,7 @@ final class MonitoringSchema {
 
     private final Schema schema;
 
-    MonitoringSchema(Schema schema) {
+    MonitoringSchema(final Schema schema) {
         this.schema = schema;
     }
 
@@ -38,13 +35,7 @@ final class MonitoringSchema {
 
     @XmlElement(name = "location")
     public Collection<String> getLocation() {
-        return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
-            @Nullable
-            @Override
-            public String apply(@Nonnull Schema.Location input) {
-                return input.getEnumeration().toString();
-            }
-        });
+        return Collections2.transform(schema.getLocation(), input -> input.getEnumeration().toString());
     }
 
     @XmlElement(name = "version")
index 12988086ca380135ddb0fbec9b3d636a058c4a2d..39eba4a84a79b3e309a2099af2c2e6e704387396 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.netconf.monitoring.xml.model;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
 import java.util.Collection;
-import javax.annotation.Nullable;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -18,8 +16,6 @@ import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.netconf.monitoring.MonitoringConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
 
 @XmlRootElement(name = MonitoringConstants.NETCONF_MONITORING_XML_ROOT_ELEMENT)
 public final class NetconfState {
@@ -37,24 +33,12 @@ public final class NetconfState {
     @XmlElementWrapper(name = "schemas")
     @XmlElement(name = "schema")
     public Collection<MonitoringSchema> getSchemas() {
-        return Collections2.transform(schemas.getSchema(), new Function<Schema, MonitoringSchema>() {
-            @Nullable
-            @Override
-            public MonitoringSchema apply(@Nullable final Schema input) {
-                return new MonitoringSchema(input);
-            }
-        });
+        return Collections2.transform(schemas.getSchema(), MonitoringSchema::new);
     }
 
     @XmlElementWrapper(name = "sessions")
     @XmlElement(name = "session")
     public Collection<MonitoringSession> getSessions() {
-        return Collections2.transform(sessions.getSession(), new Function<Session, MonitoringSession>() {
-            @Nullable
-            @Override
-            public MonitoringSession apply(@Nullable final Session input) {
-                return new MonitoringSession(input);
-            }
-        });
+        return Collections2.transform(sessions.getSession(), MonitoringSession::new);
     }
 }
index 995f6a47d02716492469f8953f0b3844513c6cd2..967633f357a9212bbe6957ae5c6b0e6ee82cce78 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.util.messages;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.collect.Collections2;
 import java.util.Collection;
@@ -29,15 +28,15 @@ public final class NetconfMessageUtil {
 
     private NetconfMessageUtil() {}
 
-    public static boolean isOKMessage(NetconfMessage message) throws NetconfDocumentedException {
+    public static boolean isOKMessage(final NetconfMessage message) throws NetconfDocumentedException {
         return isOKMessage(message.getDocument());
     }
 
-    public static boolean isOKMessage(Document document) throws NetconfDocumentedException {
+    public static boolean isOKMessage(final Document document) throws NetconfDocumentedException {
         return isOKMessage(XmlElement.fromDomDocument(document));
     }
 
-    public static boolean isOKMessage(XmlElement xmlElement) throws NetconfDocumentedException {
+    public static boolean isOKMessage(final XmlElement xmlElement) throws NetconfDocumentedException {
         if (xmlElement.getChildElements().size() != 1) {
             return false;
         }
@@ -48,15 +47,15 @@ public final class NetconfMessageUtil {
         }
     }
 
-    public static boolean isErrorMessage(NetconfMessage message) throws NetconfDocumentedException {
+    public static boolean isErrorMessage(final NetconfMessage message) throws NetconfDocumentedException {
         return isErrorMessage(message.getDocument());
     }
 
-    public static boolean isErrorMessage(Document document) throws NetconfDocumentedException {
+    public static boolean isErrorMessage(final Document document) throws NetconfDocumentedException {
         return isErrorMessage(XmlElement.fromDomDocument(document));
     }
 
-    public static boolean isErrorMessage(XmlElement xmlElement) throws NetconfDocumentedException {
+    public static boolean isErrorMessage(final XmlElement xmlElement) throws NetconfDocumentedException {
         if (xmlElement.getChildElements().size() != 1) {
             return false;
         }
@@ -67,7 +66,8 @@ public final class NetconfMessageUtil {
         }
     }
 
-    public static Collection<String> extractCapabilitiesFromHello(Document doc) throws NetconfDocumentedException {
+    public static Collection<String> extractCapabilitiesFromHello(final Document doc)
+            throws NetconfDocumentedException {
         XmlElement responseElement = XmlElement.fromDomDocument(doc);
         // Extract child element <capabilities> from <hello> with or without(fallback) the same namespace
         Optional<XmlElement> capabilitiesElement = responseElement
@@ -76,17 +76,13 @@ public final class NetconfMessageUtil {
                         .getOnlyChildElementOptionally(XmlNetconfConstants.CAPABILITIES));
 
         List<XmlElement> caps = capabilitiesElement.get().getChildElements(XmlNetconfConstants.CAPABILITY);
-        return Collections2.transform(caps, new Function<XmlElement, String>() {
-
-            @Override
-            public String apply(@Nonnull XmlElement input) {
-                // Trim possible leading/tailing whitespace
-                try {
-                    return input.getTextContent().trim();
-                } catch (DocumentedException e) {
-                    LOG.trace("Error fetching input text content",e);
-                    return null;
-                }
+        return Collections2.transform(caps, (@Nonnull final XmlElement input) -> {
+            // Trim possible leading/tailing whitespace
+            try {
+                return input.getTextContent().trim();
+            } catch (DocumentedException e) {
+                LOG.trace("Error fetching input text content",e);
+                return null;
             }
         });
 
index 11efe5a25b1aedf45353003476623d43ce794cb6..6452cfae415b093dbbf8ffac59e7549cbfae42da 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.connect.netconf;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicates;
@@ -20,6 +19,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -80,10 +80,6 @@ public class NetconfDevice
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfDevice.class);
 
-    public static final Function<QName, SourceIdentifier> QNAME_TO_SOURCE_ID_FUNCTION =
-        input -> RevisionSourceIdentifier.create(input.getLocalName(),
-                    Optional.fromNullable(input.getFormattedRevision()));
-
     protected final RemoteDeviceId id;
     private final boolean reconnectOnSchemasChange;
 
@@ -95,7 +91,7 @@ public class NetconfDevice
     private final NetconfDeviceSchemasResolver stateSchemasResolver;
     private final NotificationHandler notificationHandler;
     protected final List<SchemaSourceRegistration<? extends SchemaSourceRepresentation>> sourceRegistrations =
-            Lists.newArrayList();
+            new ArrayList<>();
     @GuardedBy("this")
     private boolean connected = false;
 
@@ -423,16 +419,21 @@ public class NetconfDevice
         }
 
         public Collection<SourceIdentifier> getRequiredSources() {
-            return Collections2.transform(requiredSources, QNAME_TO_SOURCE_ID_FUNCTION);
+            return Collections2.transform(requiredSources, DeviceSources::toSourceId);
         }
 
         public Collection<SourceIdentifier> getProvidedSources() {
-            return Collections2.transform(providedSources, QNAME_TO_SOURCE_ID_FUNCTION);
+            return Collections2.transform(providedSources, DeviceSources::toSourceId);
         }
 
         public SchemaSourceProvider<YangTextSchemaSource> getSourceProvider() {
             return sourceProvider;
         }
+
+        private static SourceIdentifier toSourceId(final QName input) {
+            return RevisionSourceIdentifier.create(input.getLocalName(),
+                Optional.fromNullable(input.getFormattedRevision()));
+        }
     }
 
     /**
index de51f47165502323e109b8c939cbe9f9a5d29024..6f42761afecacd0af3751bfa539243a2fcfcadfa 100644 (file)
@@ -14,7 +14,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
@@ -82,13 +81,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas {
 
     @Override
     public Set<QName> getAvailableYangSchemasQNames() {
-        return Sets.newHashSet(Collections2.transform(getAvailableYangSchemas(),
-                new Function<RemoteYangSchema, QName>() {
-                    @Override
-                    public QName apply(final RemoteYangSchema input) {
-                        return input.getQName();
-                    }
-                }));
+        return Sets.newHashSet(Collections2.transform(getAvailableYangSchemas(), RemoteYangSchema::getQName));
     }
 
     /**
index 2e33b57beb86f484d147b43d3982c74a7d397cd4..917b8241e6c17a6e720edd09da5dce0cc7d98d1c 100644 (file)
@@ -266,7 +266,7 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
      * DOMRpcService proxy that attaches reset-keepalive-task and schedule
      * request-timeout-task to each RPC invocation.
      */
-    private static final class KeepaliveDOMRpcService implements DOMRpcService {
+    public static final class KeepaliveDOMRpcService implements DOMRpcService {
 
         private final DOMRpcService deviceRpc;
         private ResetKeepalive resetKeepaliveTask;
@@ -281,6 +281,10 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
             this.executor = executor;
         }
 
+        public DOMRpcService getDeviceRpc() {
+            return deviceRpc;
+        }
+
         @Nonnull
         @Override
         public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final SchemaPath type,
index cd9311b9c32ada42988e6d96d63530beefdabf5b..e34b885787709215c4c0777741c1c27c4262765d 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.collect.Collections2;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -28,7 +29,6 @@ import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
@@ -37,14 +37,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
  */
 public final class NetconfDeviceRpc implements DOMRpcService {
 
-    private static final Function<RpcDefinition, DOMRpcIdentifier> RPC_TO_RPC_IDENTIFIER =
-        new Function<RpcDefinition, DOMRpcIdentifier>() {
-            @Override
-            public DOMRpcIdentifier apply(final RpcDefinition input) {
-                return DOMRpcIdentifier.create(input.getPath());
-            }
-        };
-
     private final RemoteDeviceCommunicator<NetconfMessage> listener;
     private final MessageTransformer<NetconfMessage> transformer;
     private final Collection<DOMRpcIdentifier> availableRpcs;
@@ -54,7 +46,8 @@ public final class NetconfDeviceRpc implements DOMRpcService {
         this.listener = listener;
         this.transformer = transformer;
 
-        availableRpcs = Collections2.transform(schemaContext.getOperations(), RPC_TO_RPC_IDENTIFIER);
+        availableRpcs = Collections2.transform(schemaContext.getOperations(),
+            input -> DOMRpcIdentifier.create(input.getPath()));
     }
 
     @Nonnull
@@ -66,16 +59,13 @@ public final class NetconfDeviceRpc implements DOMRpcService {
                 listener.sendRequest(message, type.getLastComponent());
 
         final ListenableFuture<DOMRpcResult> transformed =
-            Futures.transform(delegateFutureWithPureResult, new Function<RpcResult<NetconfMessage>, DOMRpcResult>() {
-                @Override
-                public DOMRpcResult apply(final RpcResult<NetconfMessage> input) {
-                    if (input.isSuccessful()) {
-                        return transformer.toRpcResult(input.getResult(), type);
-                    } else {
-                        return new DefaultDOMRpcResult(input.getErrors());
-                    }
+            Futures.transform(delegateFutureWithPureResult, input1 -> {
+                if (input1.isSuccessful()) {
+                    return transformer.toRpcResult(input1.getResult(), type);
+                } else {
+                    return new DefaultDOMRpcResult(input1.getErrors());
                 }
-            });
+            }, MoreExecutors.directExecutor());
 
         return Futures.makeChecked(transformed, new Function<Exception, DOMRpcException>() {
             @Nullable
index 8d068bb5487a40ac5994406ec218c5b273c44179..7667ba28bcb924a904175e9e32fd3e7dbebead17 100644 (file)
@@ -8,15 +8,13 @@
 
 package org.opendaylight.netconf.sal.connect.netconf.sal;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.FluentIterable;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map.Entry;
+import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
@@ -34,7 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilitiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapability.FailureReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
@@ -57,10 +54,6 @@ import org.slf4j.LoggerFactory;
 public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceTopologyAdapter.class);
-    public static final Function<Entry<QName, FailureReason>, UnavailableCapability>
-            UNAVAILABLE_CAPABILITY_TRANSFORMER =
-                input -> new UnavailableCapabilityBuilder()
-                        .setCapability(input.getKey().toString()).setFailureReason(input.getValue()).build();
 
     private final RemoteDeviceId id;
     private BindingTransactionChain txChain;
@@ -94,20 +87,13 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         nodeBuilder.addAugmentation(NetconfNode.class, netconfNodeBuilder.build());
         Node node = nodeBuilder.build();
 
-        LOG.trace(
-                "{}: Init device state transaction {} putting if absent operational data started.",
+        LOG.trace("{}: Init device state transaction {} putting if absent operational data started.",
                 id, writeTx.getIdentifier());
         writeTx.put(LogicalDatastoreType.OPERATIONAL, path, node);
-        LOG.trace(
-                "{}: Init device state transaction {} putting operational data ended.",
-                id, writeTx.getIdentifier());
-
-        LOG.trace(
-                "{}: Init device state transaction {} putting if absent config data started.",
-                id, writeTx.getIdentifier());
-        LOG.trace(
-                "{}: Init device state transaction {} putting config data ended.",
+        LOG.trace("{}: Init device state transaction {} putting operational data ended.", id, writeTx.getIdentifier());
+        LOG.trace("{}: Init device state transaction {} putting if absent config data started.",
                 id, writeTx.getIdentifier());
+        LOG.trace("{}: Init device state transaction {} putting config data ended.", id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "init");
     }
@@ -116,13 +102,11 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         final NetconfNode data = buildDataForNetconfNode(up, capabilities);
 
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
-        LOG.trace(
-                "{}: Update device state transaction {} merging operational data started.",
+        LOG.trace("{}: Update device state transaction {} merging operational data started.",
                 id, writeTx.getIdentifier());
-        writeTx.put(LogicalDatastoreType.OPERATIONAL,
-                id.getTopologyBindingPath().augmentation(NetconfNode.class), data, true);
-        LOG.trace(
-                "{}: Update device state transaction {} merging operational data ended.",
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath().augmentation(NetconfNode.class),
+            data, true);
+        LOG.trace("{}: Update device state transaction {} merging operational data ended.",
                 id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "update");
@@ -133,20 +117,18 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         final NetconfNode data = buildDataForNetconfClusteredNode(up, masterAddress, capabilities);
 
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
-        LOG.trace(
-                "{}: Update device state transaction {} merging operational data started.",
+        LOG.trace("{}: Update device state transaction {} merging operational data started.",
                 id, writeTx.getIdentifier());
         writeTx.put(LogicalDatastoreType.OPERATIONAL,
                 id.getTopologyBindingPath().augmentation(NetconfNode.class), data, true);
-        LOG.trace(
-                "{}: Update device state transaction {} merging operational data ended.",
+        LOG.trace("{}: Update device state transaction {} merging operational data ended.",
                 id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "update");
     }
 
     public void setDeviceAsFailed(final Throwable throwable) {
-        String reason = (throwable != null && throwable.getMessage() != null) ? throwable.getMessage() : UNKNOWN_REASON;
+        String reason = throwable != null && throwable.getMessage() != null ? throwable.getMessage() : UNKNOWN_REASON;
 
         final NetconfNode data = new NetconfNodeBuilder()
                 .setConnectionStatus(ConnectionStatus.UnableToConnect).setConnectedMessage(reason).build();
@@ -172,16 +154,12 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         final AvailableCapabilitiesBuilder avCapabalitiesBuilder = new AvailableCapabilitiesBuilder();
         avCapabalitiesBuilder.setAvailableCapability(capabilityList);
 
-        final UnavailableCapabilities unavailableCapabilities = new UnavailableCapabilitiesBuilder()
-                .setUnavailableCapability(FluentIterable.from(capabilities.getUnresolvedCapabilites().entrySet())
-                        .transform(UNAVAILABLE_CAPABILITY_TRANSFORMER).toList()).build();
-
         final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder()
                 .setHost(id.getHost())
                 .setPort(new PortNumber(id.getAddress().getPort()))
                 .setConnectionStatus(up ? ConnectionStatus.Connected : ConnectionStatus.Connecting)
                 .setAvailableCapabilities(avCapabalitiesBuilder.build())
-                .setUnavailableCapabilities(unavailableCapabilities);
+                .setUnavailableCapabilities(unavailableCapabilities(capabilities.getUnresolvedCapabilites()));
 
         return netconfNodeBuilder.build();
     }
@@ -194,23 +172,24 @@ public final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         final AvailableCapabilitiesBuilder avCapabalitiesBuilder = new AvailableCapabilitiesBuilder();
         avCapabalitiesBuilder.setAvailableCapability(capabilityList);
 
-        final UnavailableCapabilities unavailableCapabilities =
-                new UnavailableCapabilitiesBuilder().setUnavailableCapability(capabilities.getUnresolvedCapabilites()
-                        .entrySet().stream().map(UNAVAILABLE_CAPABILITY_TRANSFORMER::apply)
-                        .collect(Collectors.toList())).build();
-
         final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder()
                 .setHost(id.getHost())
                 .setPort(new PortNumber(id.getAddress().getPort()))
                 .setConnectionStatus(up ? ConnectionStatus.Connected : ConnectionStatus.Connecting)
                 .setAvailableCapabilities(avCapabalitiesBuilder.build())
-                .setUnavailableCapabilities(unavailableCapabilities)
+                .setUnavailableCapabilities(unavailableCapabilities(capabilities.getUnresolvedCapabilites()))
                 .setClusteredConnectionStatus(
                         new ClusteredConnectionStatusBuilder().setNetconfMasterNode(masterNodeAddress).build());
 
         return netconfNodeBuilder.build();
     }
 
+    private static UnavailableCapabilities unavailableCapabilities(final Map<QName, FailureReason> input) {
+        return new UnavailableCapabilitiesBuilder().setUnavailableCapability(input.entrySet().stream().map(
+            e -> new UnavailableCapabilityBuilder().setCapability(e.getKey().toString()).setFailureReason(
+                e.getValue()).build()).collect(Collectors.toList())).build();
+    }
+
     public void removeDeviceConfiguration() {
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
 
index 4856e1178df76f2231f8a923c00ced57f68dfd28..84b824000eacc78103d9874e9bf7a36f97fb0ec1 100644 (file)
@@ -84,17 +84,11 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService {
                 }
             });
 
-        return Futures.makeChecked(transformed, new Function<Exception, DOMRpcException>() {
-            @Nullable
-            @Override
-            public DOMRpcException apply(@Nullable final Exception exception) {
-                return new DOMRpcImplementationNotAvailableException(
-                        exception, "Unable to invoke rpc %s on device %s", type, deviceId);
-            }
-        });
+        return Futures.makeChecked(transformed,
+            e -> new DOMRpcImplementationNotAvailableException(e,
+                "Unable to invoke rpc %s on device %s", type, deviceId));
     }
 
-
     private static boolean isBaseRpc(final SchemaPath type) {
         return NetconfMessageTransformUtil.NETCONF_URI.equals(type.getLastComponent().getNamespace());
     }
index 2038d10ee4484ed283af39c1515af6018f100879..febbff6cec99aebe12942a64b0935ea64129a612 100644 (file)
@@ -96,22 +96,14 @@ public class WriteCandidateTx extends AbstractWriteTx {
     @Override
     public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
         final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commit(),
-                new Function<RpcResult<TransactionStatus>, Void>() {
-                    @Override
-                    public Void apply(final RpcResult<TransactionStatus> input) {
-                        Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
-                                "Submit failed with errors: %s", input.getErrors());
-                        return null;
-                    }
-                });
-
-        return Futures.makeChecked(commitFutureAsVoid, new Function<Exception, TransactionCommitFailedException>() {
-            @Override
-            public TransactionCommitFailedException apply(final Exception input) {
-                return new TransactionCommitFailedException(
-                        "Submit of transaction " + getIdentifier() + " failed", input);
-            }
-        });
+            (Function<RpcResult<TransactionStatus>, Void>) input -> {
+                Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
+                        "Submit failed with errors: %s", input.getErrors());
+                return null;
+            });
+
+        return Futures.makeChecked(commitFutureAsVoid, input -> new TransactionCommitFailedException(
+                "Submit of transaction " + getIdentifier() + " failed", input));
     }
 
     /**
index 01b82c9e8b7e77376cf59b391975b81651407751..af51c824ef1883eac9b2252756a1df309afbe351 100644 (file)
@@ -73,20 +73,11 @@ public class WriteRunningTx extends AbstractWriteTx {
     @Override
     public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
         final ListenableFuture<Void> commmitFutureAsVoid = Futures.transform(commit(),
-                new Function<RpcResult<TransactionStatus>, Void>() {
-                    @Override
-                    public Void apply(final RpcResult<TransactionStatus> input) {
-                        return null;
-                    }
-                });
-
-        return Futures.makeChecked(commmitFutureAsVoid, new Function<Exception, TransactionCommitFailedException>() {
-            @Override
-            public TransactionCommitFailedException apply(final Exception input) {
-                return new TransactionCommitFailedException("Submit of transaction " + getIdentifier() + " failed",
-                        input);
-            }
-        });
+                (Function<RpcResult<TransactionStatus>, Void>) input -> null);
+
+        return Futures.makeChecked(commmitFutureAsVoid,
+            input -> new TransactionCommitFailedException("Submit of transaction " + getIdentifier() + " failed",
+                input));
     }
 
     @Override
@@ -125,8 +116,8 @@ public class WriteRunningTx extends AbstractWriteTx {
                                                        final boolean rollbackSupport) {
             final NetconfRpcFutureCallback editConfigCallback = new NetconfRpcFutureCallback("Edit running", id);
             if (defaultOperation.isPresent()) {
-                return netOps.editConfigRunning(
-                        editConfigCallback, editStructure, defaultOperation.get(), rollbackSupport);
+                return netOps.editConfigRunning(editConfigCallback, editStructure, defaultOperation.get(),
+                    rollbackSupport);
             } else {
                 return netOps.editConfigRunning(editConfigCallback, editStructure, rollbackSupport);
             }
index 4367d8cf0ab097d09298af911f190104f0d6d303..734abb7978b910f0d5c3bf0ca4a069926674026c 100644 (file)
@@ -11,7 +11,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_URI;
 import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
@@ -57,11 +56,6 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageTransformer.class);
 
-    private static final Function<SchemaNode, QName> QNAME_FUNCTION = rpcDefinition -> rpcDefinition.getQName();
-
-    private static final Function<SchemaNode, QName> QNAME_NOREV_FUNCTION =
-        notification -> QNAME_FUNCTION.apply(notification).withoutRevision();
-
     private final SchemaContext schemaContext;
     private final BaseSchema baseSchema;
     private final MessageCounter counter;
@@ -79,8 +73,9 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
         this.schemaContext = schemaContext;
         parserFactory = DomToNormalizedNodeParserFactory
                 .getInstance(XmlUtils.DEFAULT_XML_CODEC_PROVIDER, schemaContext, strictParsing);
-        mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), QNAME_FUNCTION);
-        mappedNotifications = Multimaps.index(schemaContext.getNotifications(), QNAME_NOREV_FUNCTION);
+        mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), SchemaNode::getQName);
+        mappedNotifications = Multimaps.index(schemaContext.getNotifications(),
+            node -> node.getQName().withoutRevision());
         this.baseSchema = baseSchema;
     }
 
@@ -158,7 +153,7 @@ public class NetconfMessageTransformer implements MessageTransformer<NetconfMess
             // use default pre build context with just the base model
             // This way operations like lock/unlock are supported even if the source for base model was not provided
             SchemaContext ctx = needToUseBaseCtx ? baseSchema.getSchemaContext() : schemaContext;
-            NetconfMessageTransformUtil.writeNormalizedRpc(((ContainerNode) payload), result, rpc, ctx);
+            NetconfMessageTransformUtil.writeNormalizedRpc((ContainerNode) payload, result, rpc, ctx);
         } catch (final XMLStreamException | IOException | IllegalStateException e) {
             throw new IllegalStateException("Unable to serialize " + rpc, e);
         }
index d12a97c8bd4979d7a2f87942f39d5e54d7d11d20..debd460936ecfb524da81fd2385688a47138fd28 100644 (file)
@@ -35,6 +35,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade.KeepaliveDOMRpcService;
 import org.opendaylight.netconf.sal.connect.netconf.sal.SchemalessNetconfDeviceRpc;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.copy.config.input.target.ConfigTarget;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent;
@@ -63,7 +64,9 @@ public final class NetconfBaseOps {
     public NetconfBaseOps(final DOMRpcService rpc, final SchemaContext schemaContext) {
         this.rpc = rpc;
         this.schemaContext = schemaContext;
-        if (rpc instanceof SchemalessNetconfDeviceRpc) {
+
+        if ((rpc instanceof KeepaliveDOMRpcService)
+                && (((KeepaliveDOMRpcService) rpc).getDeviceRpc() instanceof SchemalessNetconfDeviceRpc)) {
             this.transformer = new SchemalessRpcStructureTransformer();
         } else {
             this.transformer = new NetconfRpcStructureTransformer(schemaContext);
index c54da2a25a032f8a7a3a7455b9235a70527311ec..07163bbaadcb50e706a0de0293750e29a45b0690 100644 (file)
@@ -54,12 +54,7 @@ public final class NodeContainerProxy implements ContainerSchemaNode {
     }
 
     private static Map<QName, DataSchemaNode> asMap(final Collection<DataSchemaNode> childNodes) {
-        return Maps.uniqueIndex(childNodes, new Function<DataSchemaNode, QName>() {
-            @Override
-            public QName apply(final DataSchemaNode input) {
-                return input.getQName();
-            }
-        });
+        return Maps.uniqueIndex(childNodes, (Function<DataSchemaNode, QName>) DataSchemaNode::getQName);
     }
 
     @Override
index 0496ec92a4e6229a3c27a5073ff0dfe78dcbc71c..e91ede353a73cd88e34869028c42532a3074ee60 100644 (file)
                   <type>xml</type>
                   <classifier>configrestconfservice</classifier>
                 </artifact>
+                <artifact>
+                  <file>${project.build.directory}/classes/initial/restconf.cfg</file>
+                  <type>cfg</type>
+                  <classifier>restconf</classifier>
+                </artifact>
               </artifacts>
             </configuration>
           </execution>
index 3be423c35628d06378ead78b344059a15dcc3ed6..1c0ff41031c883a15aaee6001fa85c907d16b558 100644 (file)
@@ -5,6 +5,9 @@ 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for backwards
+      compatibility and runtime modifications will not be honored.
 -->
 <snapshot>
   <configuration>
@@ -14,11 +17,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <module>
           <type xmlns:rest="urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector">rest:rest-connector-impl</type>
           <name>rest-connector-default-impl</name>
-          <websocket-port>8185</websocket-port>
-          <dom-broker>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-            <name>dom-broker</name>
-          </dom-broker>
         </module>
       </modules>
 
index 5863a159287affeb3aa91efb7f40cc46bc58076c..dc42295a6a0ceba920e257c91a30d1a617ceb2f7 100644 (file)
@@ -5,6 +5,9 @@ Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights
 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for backwards
+      compatibility and runtime modifications will not be honored.
 -->
 <snapshot>
   <configuration>
diff --git a/restconf/sal-rest-connector-config/src/main/resources/initial/restconf.cfg b/restconf/sal-rest-connector-config/src/main/resources/initial/restconf.cfg
new file mode 100644 (file)
index 0000000..088d976
--- /dev/null
@@ -0,0 +1,2 @@
+# The port for the web socket server.
+#websocket-port=8185
index 97b93bc7844cd037a3bdee7c5c01a3f83fe5d823..0b0f52ef4fa5dbdd8d45e6129bcc64945809c43a 100644 (file)
             <Private-Package>org.opendaylight.netconf.sal.rest.*,
               org.opendaylight.restconf.*,
               org.opendaylight.netconf.sal.restconf.rpc.*,
-              org.opendaylight.netconf.sal.restconf.impl,
+              org.opendaylight.netconf.sal.restconf.impl.*,
               org.opendaylight.netconf.md.sal.rest.common.*,
               org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.rest.connector.rev140724.*,
             </Private-Package>
               org.opendaylight.aaa.shiro.realm,
               org.opendaylight.aaa.shiro.web.env,
               org.opendaylight.aaa.filterchain.filters,
+              org.opendaylight.aaa.api,
               org.apache.shiro.web.env
             </Import-Package>
             <Web-ContextPath>/restconf</Web-ContextPath>
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/RestconfWrapperProviders.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/RestconfWrapperProviders.java
deleted file mode 100644 (file)
index fa3d4d7..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2016 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;
-
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeRegistration;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeRegistrator;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.netconf.sal.rest.api.RestConnector;
-import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
-import org.opendaylight.restconf.RestConnectorProvider;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-
-/**
- * Wrapping providers from restconf draft02 and draft18.
- *
- */
-public class RestconfWrapperProviders implements AutoCloseable, RestConnector {
-
-    // DRAFT02
-    private final RestconfProviderImpl providerDraft02;
-    // DRAFT18
-    private final RestConnectorProvider providerDraft18;
-
-    /**
-     * Init both providers.
-     * <ul>
-     * <li>draft02 - {@link RestconfProviderImpl}
-     * <li>draft18 - {@link RestConnectorProvider}
-     * </ul>
-     *
-     * @param port port for web sockets in provider for draft02
-     */
-    public RestconfWrapperProviders(final PortNumber port) {
-        // Init draft02 provider
-        this.providerDraft02 = new RestconfProviderImpl();
-        this.providerDraft02.setWebsocketPort(port);
-
-        this.providerDraft18 = new RestConnectorProvider();
-    }
-
-    /**
-     * Register both providers, which will use the SAL layer.
-     * <ul>
-     * <li>draft02 - {@link RestconfProviderImpl}
-     * <li>draft18 - {@link RestConnectorProvider}
-     * </ul>
-     *
-     * @param broker
-     *             {@link Broker}
-     */
-    public void registerProviders(final Broker broker) {
-        // Register draft02 provider
-        broker.registerProvider(this.providerDraft02);
-
-        // Register draft18 provider
-        broker.registerProvider(this.providerDraft18);
-    }
-
-    /**
-     * Register runtime beans from restconf draft02 {@link RestconfProviderImpl}.
-     *
-     * @param runtimeRegistration for register runtime beans
-     * @return {@link RestConnectorRuntimeRegistration}
-     */
-    public RestConnectorRuntimeRegistration runtimeRegistration(
-            final RestConnectorRuntimeRegistrator runtimeRegistration) {
-        return runtimeRegistration.register(this.providerDraft02);
-    }
-
-    @Override
-    public void close() throws Exception {
-        this.providerDraft02.close();
-        this.providerDraft18.close();
-    }
-
-}
index 5ed25ebe3fb3f0548fed77ac5900ffddf5935323..100340d0103ce8c22b0241789f97b90b3f31f8ad 100644 (file)
@@ -8,17 +8,14 @@
 
 package org.opendaylight.controller.config.yang.md.sal.rest.connector;
 
-import org.opendaylight.RestconfWrapperProviders;
-import org.opendaylight.aaa.api.AAAService;
 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.netconf.sal.rest.api.RestConnector;
 import org.osgi.framework.BundleContext;
 
-
+@Deprecated
 public class RestConnectorModule
         extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModule {
 
-    private static RestConnectorRuntimeRegistration runtimeRegistration;
-
     private BundleContext bundleContext;
 
     public RestConnectorModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
@@ -41,21 +38,18 @@ public class RestConnectorModule
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-
-        final WaitingServiceTracker<AAAService> aaaServiceWaitingServiceTracker =
-                WaitingServiceTracker.create(AAAService.class, bundleContext);
-        aaaServiceWaitingServiceTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-
-        final RestconfWrapperProviders wrapperProviders = new RestconfWrapperProviders(getWebsocketPort());
-        wrapperProviders.registerProviders(getDomBrokerDependency());
-
-        if (runtimeRegistration != null) {
-            runtimeRegistration.close();
+        final WaitingServiceTracker<RestConnector> tracker =
+                WaitingServiceTracker.create(RestConnector.class, bundleContext);
+        tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        final class AutoCloseableRestConnector implements RestConnector, AutoCloseable {
+            @Override
+            public void close() {
+                tracker.close();
+            }
         }
 
-        runtimeRegistration = wrapperProviders.runtimeRegistration(getRootRuntimeBeanRegistratorWrapper());
-
-        return wrapperProviders;
+        return new AutoCloseableRestConnector();
     }
 
     public void setBundleContext(final BundleContext bundleContext) {
index 4cc00d1393ad0f9f5fbf5af642a4fb1ac1ce0dd9..06b2487e5ca6bdcec6859166c4d67f275dcea0bc 100644 (file)
@@ -23,6 +23,7 @@ import org.osgi.framework.BundleContext;
 * <p>
 * Do not modify this file unless it is present under src/main directory
 */
+@Deprecated
 public class RestConnectorModuleFactory
         extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModuleFactory {
 
index 21f3ee1a608d67df919053312d318b31c80b7735..0ab720c3bc1200cec9b595cf4ba6fb9bcd5f4c99 100644 (file)
@@ -8,10 +8,19 @@
 
 package org.opendaylight.controller.config.yang.sal.restconf.service;
 
-import org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl;
+import com.google.common.base.Optional;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.netconf.sal.restconf.api.JSONRestconfService;
+import org.opendaylight.yangtools.yang.common.OperationFailedException;
+import org.osgi.framework.BundleContext;
 
+@Deprecated
 public class JSONRestconfServiceModule
         extends org.opendaylight.controller.config.yang.sal.restconf.service.AbstractJSONRestconfServiceModule {
+
+    private BundleContext bundleContext;
+
     public JSONRestconfServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
                                      org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
@@ -26,12 +35,49 @@ public class JSONRestconfServiceModule
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
+    public java.lang.AutoCloseable createInstance() {
+        final WaitingServiceTracker<JSONRestconfService> tracker =
+                WaitingServiceTracker.create(JSONRestconfService.class, bundleContext);
+        final JSONRestconfService service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        final class AutoCloseableJSONRestconfService implements JSONRestconfService, AutoCloseable {
+            @Override
+            public void close() {
+                tracker.close();
+            }
+
+            @Override
+            public void delete(String uriPath) throws OperationFailedException {
+                service.delete(uriPath);
+            }
+
+
+            @Override
+            public void put(String uriPath, String payload) throws OperationFailedException {
+                service.put(uriPath, payload);
+            }
+
+            @Override
+            public void post(String uriPath, String payload) throws OperationFailedException {
+                service.post(uriPath, payload);
+            }
+
+            @Override
+            public Optional<String> get(String uriPath, LogicalDatastoreType datastoreType)
+                    throws OperationFailedException {
+                return service.get(uriPath, datastoreType);
+            }
+
+            @Override
+            public Optional<String> invokeRpc(String uriPath, Optional<String> input) throws OperationFailedException {
+                return service.invokeRpc(uriPath, input);
+            }
+        }
+
+        return new AutoCloseableJSONRestconfService();
     }
 
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        return new JSONRestconfServiceImpl();
+    public void setBundleContext(final BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
     }
 }
index 2be3286d58e766e5eb88204f9d902625d3095d16..52fbbf64951c012831918faa98e619a52eaab73e 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.controller.config.yang.sal.restconf.service;
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
 /**
 * Generated file.
 *
@@ -19,7 +22,25 @@ package org.opendaylight.controller.config.yang.sal.restconf.service;
 * <p>
 * Do not modify this file unless it is present under src/main directory
 */
+@Deprecated
 public class JSONRestconfServiceModuleFactory
         extends org.opendaylight.controller.config.yang.sal.restconf.service.AbstractJSONRestconfServiceModuleFactory {
+    @Override
+    public JSONRestconfServiceModule instantiateModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
+        final JSONRestconfServiceModule restConnectorModule = super.instantiateModule(instanceName,
+                dependencyResolver, bundleContext);
+        restConnectorModule.setBundleContext(bundleContext);
+        return restConnectorModule;
+    }
 
+    @Override
+    public JSONRestconfServiceModule instantiateModule(final String instanceName,
+            final DependencyResolver dependencyResolver, final JSONRestconfServiceModule oldModule,
+            final AutoCloseable oldInstance, final BundleContext bundleContext) {
+        final JSONRestconfServiceModule restConnectorModule = super.instantiateModule(instanceName,
+                dependencyResolver, oldModule, oldInstance, bundleContext);
+        restConnectorModule.setBundleContext(bundleContext);
+        return restConnectorModule;
+    }
 }
index 0f558fa229743c088398f22591363dcbd4d8a9d9..db2b3188322432d0e8768a227c79beea52ee370f 100644 (file)
@@ -169,7 +169,7 @@ public class JsonNormalizedNodeBodyReader
             LOG.debug("Error parsing json input:", exception);
 
             throw new RestconfDocumentedException("Error parsing json input: Failed to create new parse result data. "
-                    + "Are you creating multiple resources/subresources in POST request?");
+                    + "Are you creating multiple resources/subresources in POST request?", exception);
         }
 
         LOG.debug("Error parsing json input", exception);
index 3addde0ae0d9556634e1fd9a7aa9b131dfeea88b..6f248f413f5b967009a436401b01b8b7e149e2ca 100644 (file)
@@ -92,7 +92,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro
             LOG.debug("Error parsing xml input", e);
 
             throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
-                    ErrorTag.MALFORMED_MESSAGE);
+                    ErrorTag.MALFORMED_MESSAGE, e);
         }
     }
 
index 9ca8137aee27e780434e0a2e2692679a8141fe25..6b4787064c1dc2e2e572c8aa818c49ab28d8032c 100644 (file)
@@ -40,7 +40,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
 import org.opendaylight.netconf.sal.streams.listeners.ListenerAdapter;
@@ -84,7 +83,6 @@ public class BrokerFacade {
     private static final BrokerFacade INSTANCE = new BrokerFacade();
 
     private volatile DOMRpcService rpcService;
-    private volatile ConsumerSession context;
 
     private DOMDataBroker domDataBroker;
     private DOMNotificationService domNotification;
@@ -99,16 +97,12 @@ public class BrokerFacade {
         this.domNotification = domNotification;
     }
 
-    public void setContext(final ConsumerSession context) {
-        this.context = context;
-    }
-
     public static BrokerFacade getInstance() {
         return BrokerFacade.INSTANCE;
     }
 
     private void checkPreconditions() {
-        if (this.context == null || this.domDataBroker == null) {
+        if (this.domDataBroker == null) {
             throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
         }
     }
index 40a50cfacb26e9406114c888d0a510adabc15cd9..248863dca8ebf9d061e8844450ec47e6918546a5 100644 (file)
@@ -7,74 +7,83 @@
  */
 package org.opendaylight.netconf.sal.restconf.impl;
 
+import com.google.common.base.Preconditions;
 import java.math.BigInteger;
-import java.util.Collection;
-import java.util.Collections;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Config;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Delete;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Get;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Operational;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Post;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Put;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeMXBean;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.Rpcs;
+import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.netconf.sal.rest.api.RestConnector;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Config;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Delete;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Get;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Operational;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Post;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Put;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.RestConnectorRuntimeMXBean;
+import org.opendaylight.netconf.sal.restconf.impl.jmx.Rpcs;
 import org.opendaylight.netconf.sal.streams.websockets.WebSocketServer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 
-public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnector, RestConnectorRuntimeMXBean {
-
+public class RestconfProviderImpl extends AbstractMXBean
+        implements AutoCloseable, RestConnector, RestConnectorRuntimeMXBean {
+    private final DOMDataBroker domDataBroker;
+    private final SchemaService schemaService;
+    private final DOMRpcService rpcService;
+    private final DOMNotificationService notificationService;
+    private final DOMMountPointService mountPointService;
+    private final PortNumber websocketPort;
     private final StatisticsRestconfServiceWrapper stats = StatisticsRestconfServiceWrapper.getInstance();
     private ListenerRegistration<SchemaContextListener> listenerRegistration;
-    private PortNumber port;
     private Thread webSocketServerThread;
 
-    public void setWebsocketPort(final PortNumber port) {
-        this.port = port;
+    public RestconfProviderImpl(DOMDataBroker domDataBroker, SchemaService schemaService, DOMRpcService rpcService,
+            DOMNotificationService notificationService, DOMMountPointService mountPointService,
+            PortNumber websocketPort) {
+        super("Draft02ProviderStatistics", "restconf-connector", null);
+        this.domDataBroker = Preconditions.checkNotNull(domDataBroker);
+        this.schemaService = Preconditions.checkNotNull(schemaService);
+        this.rpcService = Preconditions.checkNotNull(rpcService);
+        this.notificationService = Preconditions.checkNotNull(notificationService);
+        this.mountPointService = Preconditions.checkNotNull(mountPointService);
+        this.websocketPort = Preconditions.checkNotNull(websocketPort);
     }
 
-    @Override
-    public void onSessionInitiated(final ProviderSession session) {
-        final DOMDataBroker domDataBroker = session.getService(DOMDataBroker.class);
+    public void start() {
+        this.listenerRegistration = schemaService.registerSchemaContextListener(ControllerContext.getInstance());
 
-        BrokerFacade.getInstance().setContext(session);
         BrokerFacade.getInstance().setDomDataBroker(domDataBroker);
-        final SchemaService schemaService = session.getService(SchemaService.class);
-        this.listenerRegistration = schemaService.registerSchemaContextListener(ControllerContext.getInstance());
-        BrokerFacade.getInstance().setRpcService(session.getService(DOMRpcService.class));
-        BrokerFacade.getInstance().setDomNotificationService(session.getService(DOMNotificationService.class));
+        BrokerFacade.getInstance().setRpcService(rpcService);
+        BrokerFacade.getInstance().setDomNotificationService(notificationService);
 
         ControllerContext.getInstance().setSchemas(schemaService.getGlobalContext());
-        ControllerContext.getInstance().setMountService(session.getService(DOMMountPointService.class));
+        ControllerContext.getInstance().setMountService(mountPointService);
 
-        this.webSocketServerThread = new Thread(WebSocketServer.createInstance(this.port.getValue().intValue()));
-        this.webSocketServerThread.setName("Web socket server on port " + this.port);
+        this.webSocketServerThread = new Thread(WebSocketServer.createInstance(websocketPort.getValue().intValue()));
+        this.webSocketServerThread.setName("Web socket server on port " + websocketPort);
         this.webSocketServerThread.start();
-    }
 
-    @Override
-    public Collection<ProviderFunctionality> getProviderFunctionality() {
-        return Collections.emptySet();
+        registerMBean();
     }
 
     @Override
     public void close() {
+        BrokerFacade.getInstance().setDomDataBroker(null);
 
         if (this.listenerRegistration != null) {
             this.listenerRegistration.close();
         }
 
         WebSocketServer.destroyInstance();
-        this.webSocketServerThread.interrupt();
+        if (this.webSocketServerThread != null) {
+            this.webSocketServerThread.interrupt();
+        }
+
+        unregisterMBean();
     }
 
     @Override
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Config.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Config.java
new file mode 100644 (file)
index 0000000..a48d962
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+public class Config {
+    private Delete delete;
+
+    private Post post;
+
+    private Get get;
+
+    private Put put;
+
+    public Delete getDelete() {
+        return delete;
+    }
+
+    public void setDelete(Delete delete) {
+        this.delete = delete;
+    }
+
+    public Post getPost() {
+        return post;
+    }
+
+    public void setPost(Post post) {
+        this.post = post;
+    }
+
+    public Get getGet() {
+        return get;
+    }
+
+    public void setGet(Get get) {
+        this.get = get;
+    }
+
+    public Put getPut() {
+        return put;
+    }
+
+    public void setPut(Put put) {
+        this.put = put;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(delete, post, get, put);
+
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Config that = (Config) obj;
+        if (!java.util.Objects.equals(delete, that.delete)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(post, that.post)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(get, that.get)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(put, that.put)) {
+            return false;
+        }
+
+        return true;
+
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Delete.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Delete.java
new file mode 100644 (file)
index 0000000..dd3c4fc
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+import java.math.BigInteger;
+
+public class Delete {
+    private BigInteger successfulResponses;
+
+    private BigInteger receivedRequests;
+
+    private BigInteger failedResponses;
+
+    public BigInteger getSuccessfulResponses() {
+        return successfulResponses;
+    }
+
+    public void setSuccessfulResponses(BigInteger successfulResponses) {
+        this.successfulResponses = successfulResponses;
+    }
+
+    public BigInteger getReceivedRequests() {
+        return receivedRequests;
+    }
+
+    public void setReceivedRequests(BigInteger receivedRequests) {
+        this.receivedRequests = receivedRequests;
+    }
+
+    public BigInteger getFailedResponses() {
+        return failedResponses;
+    }
+
+    public void setFailedResponses(BigInteger failedResponses) {
+        this.failedResponses = failedResponses;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(successfulResponses, receivedRequests, failedResponses);
+
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Delete that = (Delete) obj;
+        if (!java.util.Objects.equals(successfulResponses, that.successfulResponses)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(receivedRequests, that.receivedRequests)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
+            return false;
+        }
+
+        return true;
+
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Get.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Get.java
new file mode 100644 (file)
index 0000000..d2b4b62
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+import java.math.BigInteger;
+
+public class Get {
+    private BigInteger successfulResponses;
+
+    private BigInteger receivedRequests;
+
+    private BigInteger failedResponses;
+
+    public BigInteger getSuccessfulResponses() {
+        return successfulResponses;
+    }
+
+    public void setSuccessfulResponses(BigInteger successfulResponses) {
+        this.successfulResponses = successfulResponses;
+    }
+
+    public BigInteger getReceivedRequests() {
+        return receivedRequests;
+    }
+
+    public void setReceivedRequests(BigInteger receivedRequests) {
+        this.receivedRequests = receivedRequests;
+    }
+
+    public BigInteger getFailedResponses() {
+        return failedResponses;
+    }
+
+    public void setFailedResponses(BigInteger failedResponses) {
+        this.failedResponses = failedResponses;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(successfulResponses, receivedRequests, failedResponses);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Get that = (Get) obj;
+        if (!java.util.Objects.equals(successfulResponses, that.successfulResponses)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(receivedRequests, that.receivedRequests)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
+            return false;
+        }
+
+        return true;
+
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Operational.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Operational.java
new file mode 100644 (file)
index 0000000..a831854
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+public class Operational {
+    private Get get;
+
+    public Get getGet() {
+        return get;
+    }
+
+    public void setGet(Get get) {
+        this.get = get;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(get);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Operational that = (Operational) obj;
+        if (!java.util.Objects.equals(get, that.get)) {
+            return false;
+        }
+
+        return true;
+
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Post.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Post.java
new file mode 100644 (file)
index 0000000..8a46008
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+import java.math.BigInteger;
+
+public class Post {
+    private BigInteger successfulResponses;
+
+    private BigInteger receivedRequests;
+
+    private BigInteger failedResponses;
+
+    public BigInteger getSuccessfulResponses() {
+        return successfulResponses;
+    }
+
+    public void setSuccessfulResponses(BigInteger successfulResponses) {
+        this.successfulResponses = successfulResponses;
+    }
+
+    public BigInteger getReceivedRequests() {
+        return receivedRequests;
+    }
+
+    public void setReceivedRequests(BigInteger receivedRequests) {
+        this.receivedRequests = receivedRequests;
+    }
+
+    public BigInteger getFailedResponses() {
+        return failedResponses;
+    }
+
+    public void setFailedResponses(BigInteger failedResponses) {
+        this.failedResponses = failedResponses;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(successfulResponses, receivedRequests, failedResponses);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Post that = (Post) obj;
+        if (!java.util.Objects.equals(successfulResponses, that.successfulResponses)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(receivedRequests, that.receivedRequests)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
+            return false;
+        }
+
+        return true;
+
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Put.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Put.java
new file mode 100644 (file)
index 0000000..2eb6bae
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+import java.math.BigInteger;
+
+public class Put {
+    private BigInteger successfulResponses;
+
+    private BigInteger receivedRequests;
+
+    private BigInteger failedResponses;
+
+    public BigInteger getSuccessfulResponses() {
+        return successfulResponses;
+    }
+
+    public void setSuccessfulResponses(BigInteger successfulResponses) {
+        this.successfulResponses = successfulResponses;
+    }
+
+    public BigInteger getReceivedRequests() {
+        return receivedRequests;
+    }
+
+    public void setReceivedRequests(BigInteger receivedRequests) {
+        this.receivedRequests = receivedRequests;
+    }
+
+    public BigInteger getFailedResponses() {
+        return failedResponses;
+    }
+
+    public void setFailedResponses(BigInteger failedResponses) {
+        this.failedResponses = failedResponses;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(successfulResponses, receivedRequests, failedResponses);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Put that = (Put) obj;
+        if (!java.util.Objects.equals(successfulResponses, that.successfulResponses)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(receivedRequests, that.receivedRequests)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
+            return false;
+        }
+
+        return true;
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/RestConnectorRuntimeMXBean.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/RestConnectorRuntimeMXBean.java
new file mode 100644 (file)
index 0000000..cafcb8f
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+public interface RestConnectorRuntimeMXBean  {
+    Operational getOperational();
+
+    Rpcs getRpcs();
+
+    Config getConfig();
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Rpcs.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/Rpcs.java
new file mode 100644 (file)
index 0000000..6a4596e
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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.netconf.sal.restconf.impl.jmx;
+
+import java.math.BigInteger;
+
+public class Rpcs {
+    private BigInteger successfulResponses;
+
+    private BigInteger receivedRequests;
+
+    private BigInteger failedResponses;
+
+    public BigInteger getSuccessfulResponses() {
+        return successfulResponses;
+    }
+
+    public void setSuccessfulResponses(BigInteger successfulResponses) {
+        this.successfulResponses = successfulResponses;
+    }
+
+    public BigInteger getReceivedRequests() {
+        return receivedRequests;
+    }
+
+    public void setReceivedRequests(BigInteger receivedRequests) {
+        this.receivedRequests = receivedRequests;
+    }
+
+    public BigInteger getFailedResponses() {
+        return failedResponses;
+    }
+
+    public void setFailedResponses(BigInteger failedResponses) {
+        this.failedResponses = failedResponses;
+    }
+
+    @Override
+    public int hashCode() {
+        return java.util.Objects.hash(successfulResponses, receivedRequests, failedResponses);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final Rpcs that = (Rpcs) obj;
+        if (!java.util.Objects.equals(successfulResponses, that.successfulResponses)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(receivedRequests, that.receivedRequests)) {
+            return false;
+        }
+
+        if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
+            return false;
+        }
+
+        return true;
+    }
+}
diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/package-info.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/jmx/package-info.java
new file mode 100644 (file)
index 0000000..d67ee37
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies 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
+ */
+
+/**
+ * This package contains the statistical JMX classes for the Draft02 restconf implementation. Originally these classes
+ * were generated by the CSS code generator and were moved to this package on conversion to blueprint.
+ */
+package org.opendaylight.netconf.sal.restconf.impl.jmx;
index 620193690fa9e61a1ac026e2a6664e8e4a699db7..9e1e8cd7c205b3a7adda6a5f32dbb450de9ee799 100644 (file)
@@ -9,8 +9,6 @@
 package org.opendaylight.restconf;
 
 import com.google.common.base.Preconditions;
-import java.util.Collection;
-import java.util.Collections;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
@@ -18,8 +16,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.netconf.sal.rest.api.RestConnector;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
@@ -39,7 +35,7 @@ import org.slf4j.LoggerFactory;
  * Provider for restconf draft18.
  *
  */
-public class RestConnectorProvider implements Provider, RestConnector, AutoCloseable {
+public class RestConnectorProvider implements RestConnector, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class);
 
@@ -58,35 +54,43 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
         }
     };
 
-    private ListenerRegistration<SchemaContextListener> listenerRegistration;
-
-    private SchemaContextHandler schemaCtxHandler;
     private static TransactionChainHandler transactionChainHandler;
     private static DOMDataBroker dataBroker;
     private static DOMMountPointServiceHandler mountPointServiceHandler;
 
-    @Override
-    public void onSessionInitiated(final ProviderSession session) {
-        final SchemaService schemaService = Preconditions.checkNotNull(session.getService(SchemaService.class));
+    private final SchemaService schemaService;
+    private final DOMRpcService rpcService;
+    private final DOMNotificationService notificationService;
+    private final DOMMountPointService mountPointService;
+    private ListenerRegistration<SchemaContextListener> listenerRegistration;
+
+    private SchemaContextHandler schemaCtxHandler;
 
+    public RestConnectorProvider(DOMDataBroker domDataBroker, SchemaService schemaService, DOMRpcService rpcService,
+            DOMNotificationService notificationService, DOMMountPointService mountPointService) {
+        this.schemaService = Preconditions.checkNotNull(schemaService);
+        this.rpcService = Preconditions.checkNotNull(rpcService);
+        this.notificationService = Preconditions.checkNotNull(notificationService);
+        this.mountPointService = Preconditions.checkNotNull(mountPointService);
+
+        RestConnectorProvider.dataBroker = Preconditions.checkNotNull(domDataBroker);
+    }
+
+    public void start() {
         final ServicesWrapperImpl wrapperServices = ServicesWrapperImpl.getInstance();
 
-        RestConnectorProvider.mountPointServiceHandler = new DOMMountPointServiceHandler(
-                session.getService(DOMMountPointService.class));
+        mountPointServiceHandler = new DOMMountPointServiceHandler(mountPointService);
 
-        RestConnectorProvider.dataBroker = session.getService(DOMDataBroker.class);
-        final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(RestConnectorProvider.dataBroker);
+        final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(dataBroker);
 
-        RestConnectorProvider.transactionChainHandler = new TransactionChainHandler(RestConnectorProvider.dataBroker
+        RestConnectorProvider.transactionChainHandler = new TransactionChainHandler(dataBroker
                 .createTransactionChain(RestConnectorProvider.TRANSACTION_CHAIN_LISTENER));
 
         this.schemaCtxHandler = new SchemaContextHandler(transactionChainHandler);
         this.listenerRegistration = schemaService.registerSchemaContextListener(this.schemaCtxHandler);
 
-        final DOMRpcService rpcService = session.getService(DOMRpcService.class);
         final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService);
 
-        final DOMNotificationService notificationService = session.getService(DOMNotificationService.class);
         final NotificationServiceHandler notificationServiceHandler =
                 new NotificationServiceHandler(notificationService);
 
@@ -105,7 +109,7 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
         LOG.trace("Resetting TransactionChain({})", chain);
         chain.close();
         RestConnectorProvider.transactionChainHandler.update(
-                Preconditions.checkNotNull(RestConnectorProvider.dataBroker).createTransactionChain(
+                Preconditions.checkNotNull(dataBroker).createTransactionChain(
                         RestConnectorProvider.TRANSACTION_CHAIN_LISTENER)
         );
     }
@@ -115,12 +119,7 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
      * @return {@link DOMMountPointService}
      */
     public static DOMMountPointService getMountPointService() {
-        return RestConnectorProvider.mountPointServiceHandler.get();
-    }
-
-    @Override
-    public Collection<ProviderFunctionality> getProviderFunctionality() {
-        return Collections.emptySet();
+        return mountPointServiceHandler.get();
     }
 
     @Override
@@ -131,8 +130,12 @@ public class RestConnectorProvider implements Provider, RestConnector, AutoClose
         }
 
         // close transaction chain
-        if ((transactionChainHandler != null) && (transactionChainHandler.get() != null)) {
+        if (transactionChainHandler != null && transactionChainHandler.get() != null) {
             transactionChainHandler.get().close();
         }
+
+        transactionChainHandler = null;
+        mountPointServiceHandler = null;
+        dataBroker = null;
     }
 }
index 72df65958f60a61da6f31058201309e943539bbf..a14cec0d0479c2d3e2340b2b6ec7848872c99be0 100644 (file)
@@ -129,7 +129,7 @@ public class JsonNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyRead
             LOG.debug("Error parsing json input:", exception);
 
             throw new RestconfDocumentedException("Error parsing json input: Failed to create new parse result data. "
-                    + "Are you creating multiple resources/subresources in POST request?");
+                    + "Are you creating multiple resources/subresources in POST request?", exception);
         }
 
         LOG.debug("Error parsing json input", exception);
index e3ace7c02b86ad49f877c4981dfe9fe2a8c994c2..4458995e7766182481eb1554a91bca38efe9ab8b 100644 (file)
@@ -69,7 +69,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReade
             LOG.debug("Error parsing xml input", e);
 
             throw new RestconfDocumentedException("Error parsing input: " + e.getMessage(), ErrorType.PROTOCOL,
-                    ErrorTag.MALFORMED_MESSAGE);
+                    ErrorTag.MALFORMED_MESSAGE, e);
         }
     }
 
diff --git a/restconf/sal-rest-connector/src/main/resources/org/opendaylight/blueprint/restconf-config.xml b/restconf/sal-rest-connector/src/main/resources/org/opendaylight/blueprint/restconf-config.xml
new file mode 100644 (file)
index 0000000..e09adb6
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2017 Inocybe Technologies 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+           xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.4.0"
+           odl:use-default-for-reference-types="true">
+
+  <!-- JSONRestconfService -->
+
+  <bean id="jsonRestconfService"
+      class="org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl"
+      destroy-method="close"/>
+
+  <service ref="jsonRestconfService"
+      interface="org.opendaylight.netconf.sal.restconf.api.JSONRestconfService" />
+
+  <!-- Restconf providers -->
+
+  <cm:property-placeholder persistent-id="org.opendaylight.restconf" update-strategy="reload">
+    <cm:default-properties>
+      <cm:property name="websocket-port" value="8185"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <!--
+    This cfg file defines the type of the DOMDataBroker service to use. 'default' indicates to use
+    the default DOMDataBroker provided by MD-SAL. This setting is useful for providing a custom
+    DOMDataBroker implementation that does, e.g., validation or additional security checking on
+    top of the default DOMDataBroker.
+  -->
+  <cm:property-placeholder persistent-id="org.opendaylight.restconf.databroker"
+        placeholder-prefix = "@{" placeholder-suffix = "}" update-strategy="reload">
+    <cm:default-properties>
+      <cm:property name="databroker-service-type" value="default"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <!-- We need the AAAService available even though we don't use it -->
+  <reference interface="org.opendaylight.aaa.api.AAAService"/>
+
+  <reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService"/>
+  <reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
+  <reference id="domMountPointService" interface="org.opendaylight.controller.md.sal.dom.api.DOMMountPointService"/>
+  <reference id="domNotificationService" interface="org.opendaylight.controller.md.sal.dom.api.DOMNotificationService"/>
+  <reference id="domDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
+          ext:filter="(type=@{databroker-service-type})"/>
+
+  <bean id="webSocketPort" class="org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber">
+    <argument value="${websocket-port}"/>
+  </bean>
+
+  <bean id="restconfProviderDraft02" class="org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl"
+          init-method="start" destroy-method="close">
+    <argument ref="domDataBroker"/>
+    <argument ref="schemaService"/>
+    <argument ref="domRpcService"/>
+    <argument ref="domNotificationService"/>
+    <argument ref="domMountPointService"/>
+    <argument ref="webSocketPort"/>
+  </bean>
+
+  <bean id="restconfProviderDraft18" class="org.opendaylight.restconf.RestConnectorProvider"
+          init-method="start" destroy-method="close">
+    <argument ref="domDataBroker"/>
+    <argument ref="schemaService"/>
+    <argument ref="domRpcService"/>
+    <argument ref="domNotificationService"/>
+    <argument ref="domMountPointService"/>
+  </bean>
+
+  <service ref="restconfProviderDraft18"
+      interface="org.opendaylight.netconf.sal.rest.api.RestConnector" />
+
+</blueprint>
index cfdd1130c6a7b345f8055ae36e3331def1348fe4..098102b2f9922e84afd14882faf0a2af35e436f4 100644 (file)
@@ -7,88 +7,44 @@ module opendaylight-rest-connector {
     import opendaylight-md-sal-dom {prefix dom; revision-date 2013-10-28;}
     import opendaylight-md-sal-binding {prefix sal; revision-date 2013-10-28;}
     import ietf-inet-types {prefix inet; revision-date 2013-07-15;}
+
     description
         "Service definition for Rest Connector";
+
     revision "2014-07-24" {
         description
             "Initial revision";
     }
-    
+
     identity rest-connector {
+        status deprecated;
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.sal.rest.api.RestConnector";
+        config:disable-osgi-service-registration;
     }
-    
+
     identity rest-connector-impl {
+        status deprecated;
         base config:module-type;
         config:provided-service rest-connector;
         config:java-name-prefix RestConnector;
     }
-    
-    grouping statistics {
-        leaf received-requests {
-           type uint64;
-        }
-
-        leaf successful-responses {
-            type uint64;
-        }
-
-        leaf failed-responses {
-            type uint64;
-        }
-    }
 
     augment "/config:modules/config:module/config:configuration" {
         case rest-connector-impl {
             when "/config:modules/config:module/config:type = 'rest-connector-impl'";
             leaf websocket-port {
-                mandatory true;
+                mandatory false;
                 type inet:port-number;
             }
             container dom-broker {
                 uses config:service-ref {
                     refine type {
-                        mandatory true;
+                        mandatory false;
                         config:required-identity dom:dom-broker-osgi-registry;
                     }
                 }
             }
         }
     }
-    
-    augment "/config:modules/config:module/config:state" {
-        case rest-connector-impl {
-            when "/config:modules/config:module/config:type = 'rest-connector-impl'";
-            container rpcs {
-                uses statistics;
-            }
-
-            container config {
-                container get {
-                    uses statistics;
-                }
-                
-                container post {
-                    uses statistics;
-                }
-                
-                container put {
-                    uses statistics;
-                }
-                
-                container delete {
-                    uses statistics;
-                }
-            }
-
-            container operational {
-                container get {
-                    uses statistics;
-                }
-            }
-        }
-    }
 }
index e918b3f38f656e69bec8d1a85b023644f872e4b3..9ce28e998c42dab892fdda2e3e5930f1c6380bc7 100644 (file)
@@ -12,11 +12,14 @@ module sal-restconf-service {
     }
 
     identity json-restconf-service {
+        status deprecated;
         base "config:service-type";
         config:java-class "org.opendaylight.netconf.sal.restconf.api.JSONRestconfService";
+        config:disable-osgi-service-registration;
     }
 
     identity json-restconf-service-impl {
+        status deprecated;
         base config:module-type;
         config:provided-service json-restconf-service;
         config:java-name-prefix JSONRestconfService;
@@ -27,4 +30,4 @@ module sal-restconf-service {
             when "/config:modules/config:module/config:type = 'json-restconf-service-impl'";
         }
     }
-}
\ No newline at end of file
+}
diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/RestconfWrapperProvidersTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/RestconfWrapperProvidersTest.java
deleted file mode 100644 (file)
index c342195..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2017 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.lang.reflect.Field;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeRegistration;
-import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeRegistrator;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
-import org.opendaylight.restconf.RestConnectorProvider;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-
-public class RestconfWrapperProvidersTest {
-
-    private static final PortNumber PORT = new PortNumber(8181);
-
-    private RestconfWrapperProviders rwp;
-
-    @Before
-    public void setUp() throws Exception {
-        rwp = new RestconfWrapperProviders(PORT);
-        assertNotNull(rwp);
-    }
-
-    @Test
-    public void registerTest() {
-        final Broker broker = mock(Broker.class);
-        rwp.registerProviders(broker);
-
-        Mockito.verify(broker, times(2)).registerProvider(Mockito.any(Provider.class));
-    }
-
-    @Test
-    public void runtimeRegistrationTest() {
-        final RestConnectorRuntimeRegistrator runtimeRegistrator = mock(RestConnectorRuntimeRegistrator.class);
-        final RestConnectorRuntimeRegistration value = mock(RestConnectorRuntimeRegistration.class);
-        when(runtimeRegistrator.register(any())).thenReturn(value);
-        final RestConnectorRuntimeRegistration runtimeRegistration = rwp.runtimeRegistration(runtimeRegistrator);
-
-        assertEquals(value, runtimeRegistration);
-    }
-
-    @Test
-    public void closeTest() throws Exception {
-        final RestconfProviderImpl draft2 = mock(RestconfProviderImpl.class);
-        final RestConnectorProvider draft18 = mock(RestConnectorProvider.class);
-
-        setDeclaredField(rwp, "providerDraft02", draft2);
-        setDeclaredField(rwp, "providerDraft18", draft18);
-
-        rwp.close();
-
-        verify(draft2, times(1)).close();
-        verify(draft18, times(1)).close();
-    }
-
-    private static void setDeclaredField(final Object rwp, final String name, final Object value) throws Exception {
-        final Field declaredField = rwp.getClass().getDeclaredField(name);
-        declaredField.setAccessible(true);
-        declaredField.set(rwp, value);
-    }
-}
index a2485dfc81aa7adb0a9e95fa63caec6ece7032f8..b52689f1c889e6b4b49a32092d0a25c3298dfb0a 100644 (file)
@@ -50,7 +50,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
 import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
@@ -90,8 +89,6 @@ public class BrokerFacadeTest {
     @Mock
     private DOMNotificationService domNotification;
     @Mock
-    private ConsumerSession context;
-    @Mock
     private DOMRpcService mockRpcService;
     @Mock
     private DOMMountPoint mockMountInstance;
@@ -116,7 +113,6 @@ public class BrokerFacadeTest {
         this.brokerFacade.setDomDataBroker(this.domDataBroker);
         this.brokerFacade.setDomNotificationService(this.domNotification);
         this.brokerFacade.setRpcService(this.mockRpcService);
-        this.brokerFacade.setContext(this.context);
         when(this.domDataBroker.newReadOnlyTransaction()).thenReturn(this.readTransaction);
         when(this.domDataBroker.newWriteOnlyTransaction()).thenReturn(this.writeTransaction);
         when(this.domDataBroker.newReadWriteTransaction()).thenReturn(this.rwTransaction);
@@ -204,7 +200,7 @@ public class BrokerFacadeTest {
 
     @Test(expected = RestconfDocumentedException.class)
     public void testInvokeRpcWithNoConsumerSession() {
-        this.brokerFacade.setContext(null);
+        brokerFacade.setDomDataBroker(null);
         this.brokerFacade.invokeRpc(this.type, this.dummyNode);
     }
 
index a916e1f4683a0e702f46ba828a1bdb335aea64d1..f63dd325117c784e71df63b523e42a4a757bc413 100644 (file)
@@ -8,10 +8,8 @@
 
 package org.opendaylight.restconf;
 
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -22,8 +20,9 @@ import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.restconf.handlers.SchemaContextHandler;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -36,9 +35,12 @@ public class RestConnectorProviderTest {
     // service under test
     private RestConnectorProvider connectorProvider;
 
-    @Mock private Broker.ProviderSession mockSession;
     @Mock private SchemaService mockSchemaService;
     @Mock private DOMMountPointService mockMountPointService;
+    @Mock private DOMDataBroker mockDataBroker;
+    @Mock private DOMRpcService mockRpcService;
+    @Mock private DOMNotificationService mockNotificationService;
+    @Mock DOMTransactionChain mockTransactionChain;
     @Mock private ListenerRegistration<SchemaContextListener> mockRegistration;
 
     @Rule
@@ -47,99 +49,26 @@ public class RestConnectorProviderTest {
     @Before
     public void init() {
         MockitoAnnotations.initMocks(this);
-        this.connectorProvider = new RestConnectorProvider();
-    }
-
-    /**
-     * Test of successful initialization of {@link RestConnectorProvider}.
-     */
-    @Test
-    public void restConnectorProviderInitTest() {
-        assertNotNull("Connector provider should be initialized and not null", this.connectorProvider);
-    }
-
-    /**
-     * Test for successful registration with {@link RestConnectorProvider#onSessionInitiated(Broker.ProviderSession)}
-     * when all conditions are satisfied.
-     *
-     * <p>
-     * Condition 1: <code>Broker.ProviderSession</code> contains <code>SchemaService</code>
-     * Condition 2: <code>Broker.ProviderSession</code> contains <code>DOMMountPointService</code>
-     */
-    @Test
-    public void successfulRegistrationTest() {
-        // prepare conditions
-        when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService);
-        when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(this.mockMountPointService);
-        final DOMDataBroker mockDataBroker = Mockito.mock(DOMDataBroker.class);
-        when(this.mockSession.getService(DOMDataBroker.class)).thenReturn(mockDataBroker);
-        final DOMTransactionChain mockTransactionChain = Mockito.mock(DOMTransactionChain.class);
-        when(mockDataBroker.createTransactionChain(Mockito.any())).thenReturn(mockTransactionChain);
 
-        // test
-        this.connectorProvider.onSessionInitiated(this.mockSession);
+        doReturn(mockTransactionChain).when(mockDataBroker).createTransactionChain(Mockito.any());
+        doReturn(mockRegistration).when(mockSchemaService).registerSchemaContextListener(
+                Mockito.any(SchemaContextHandler.class));
 
-        // verify interactions
-        verify(this.mockSession, times(1)).getService(SchemaService.class);
-        verify(this.mockSession, times(1)).getService(DOMMountPointService.class);
-        verify(this.mockSchemaService, times(1)).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
+        this.connectorProvider = new RestConnectorProvider(mockDataBroker, mockSchemaService, mockRpcService,
+                mockNotificationService, mockMountPointService);
     }
 
     /**
-     * Test for successful registration with {@link RestConnectorProvider#onSessionInitiated(Broker.ProviderSession)}
-     * without <code>DOMMountPointService</code>.
-     *
-     * <p>
-     * Condition 1: <code>Broker.ProviderSession</code> contains <code>SchemaService</code>
-     * Condition 2: <code>Broker.ProviderSession</code> does not contain <code>DOMMountPointService</code>
+     * Test for successful start when all conditions are satisfied.
      */
     @Test
-    public void successfulRegistrationWithoutMountPointTest() {
-        // prepare conditions
-        when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService);
-        when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(null);
-        final DOMDataBroker mockDataBroker = Mockito.mock(DOMDataBroker.class);
-        when(this.mockSession.getService(DOMDataBroker.class)).thenReturn(mockDataBroker);
-        final DOMTransactionChain mockTransactionChain = Mockito.mock(DOMTransactionChain.class);
-        when(mockDataBroker.createTransactionChain(Mockito.any())).thenReturn(mockTransactionChain);
-        final DOMMountPointService mockDomMountPoint = Mockito.mock(DOMMountPointService.class);
-        when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(mockDomMountPoint);
-
+    public void successfulStartTest() {
         // test
-        this.connectorProvider.onSessionInitiated(this.mockSession);
+        this.connectorProvider.start();
 
         // verify interactions
-        verify(this.mockSession, times(1)).getService(SchemaService.class);
-        verify(this.mockSession, times(1)).getService(DOMMountPointService.class);
-        verify(this.mockSchemaService, times(1)).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
-    }
-
-    /**
-     * Negative test of registration with {@link RestConnectorProvider#onSessionInitiated(Broker.ProviderSession)} with
-     * null input. Test is expected to fail with <code>NullPointerException</code>.
-     */
-    @Test
-    public void nullSessionRegistrationNegativeTest() {
-        this.thrown.expect(NullPointerException.class);
-        this.connectorProvider.onSessionInitiated(null);
-    }
-
-    /**
-     * Negative test of registration with {@link RestConnectorProvider#onSessionInitiated(Broker.ProviderSession)} when
-     * <code>Broker.ProviderSession</code> does not contain <code>SchemaService</code>. Test is expected to fail with
-     * <code>NullPointerException</code>.
-     */
-    @Test
-    public void withoutSchemaServiceRegistrationNegativeTest() {
-        // prepare conditions
-        when(this.mockSession.getService(SchemaService.class)).thenReturn(null);
-
-        // test
-        this.thrown.expect(NullPointerException.class);
-        this.connectorProvider.onSessionInitiated(this.mockSession);
-
-        // verify interaction
-        verify(this.mockSession, times(1)).getService(SchemaService.class);
+        verify(mockDataBroker).createTransactionChain(Mockito.any());
+        verify(mockSchemaService).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
     }
 
     /**
@@ -155,24 +84,14 @@ public class RestConnectorProviderTest {
      */
     @Test
     public void closeOpenTest() throws Exception {
-        // prepare conditions
-        when(this.mockSession.getService(SchemaService.class)).thenReturn(this.mockSchemaService);
-        when(this.mockSession.getService(DOMMountPointService.class)).thenReturn(this.mockMountPointService);
-        when(this.mockSchemaService.registerSchemaContextListener(Mockito.any(SchemaContextHandler.class)))
-                .thenReturn(this.mockRegistration);
-        final DOMDataBroker mockDataBroker = Mockito.mock(DOMDataBroker.class);
-        when(this.mockSession.getService(DOMDataBroker.class)).thenReturn(mockDataBroker);
-        final DOMTransactionChain mockTransactionChain = Mockito.mock(DOMTransactionChain.class);
-        when(mockDataBroker.createTransactionChain(Mockito.any())).thenReturn(mockTransactionChain);
-
-        // register
-        this.connectorProvider.onSessionInitiated(this.mockSession);
+        // start
+        this.connectorProvider.start();
 
-        // close registration
+        // close
         this.connectorProvider.close();
 
         // verify interaction
-        verify(this.mockRegistration, times(1)).close();
-        verify(mockTransactionChain, times(1)).close();
+        verify(this.mockRegistration).close();
+        verify(mockTransactionChain).close();
     }
 }