Move internal classes under .impl package (1/2)

Change-Id: I72ed933ecd5ae7ffb268967f80fb395e90f7d8e9
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java
index ee0c94c..ba4d7ae 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java
@@ -24,7 +24,7 @@
 import org.onosproject.netconf.NetconfDevice;
 import org.onosproject.netconf.NetconfDeviceInfo;
 import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.ctl.NetconfControllerImpl;
+import org.onosproject.netconf.ctl.impl.NetconfControllerImpl;
 
 import java.util.ArrayList;
 import java.util.Arrays;
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/FilteringNetconfDeviceOutputEventListener.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/FilteringNetconfDeviceOutputEventListener.java
new file mode 100644
index 0000000..da5d51d
--- /dev/null
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/FilteringNetconfDeviceOutputEventListener.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.netconf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener to listen for event about specific Device.
+ */
+public class FilteringNetconfDeviceOutputEventListener
+        implements NetconfDeviceOutputEventListener {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(FilteringNetconfDeviceOutputEventListener.class);
+
+    private final NetconfDeviceInfo deviceInfo;
+
+    public FilteringNetconfDeviceOutputEventListener(NetconfDeviceInfo deviceInfo) {
+        this.deviceInfo = checkNotNull(deviceInfo);
+    }
+
+    @Override
+    public void event(NetconfDeviceOutputEvent event) {
+        switch (event.type()) {
+            case DEVICE_REPLY:
+                log.debug("Device {} has reply: {}", deviceInfo, event.getMessagePayload());
+                break;
+            case DEVICE_NOTIFICATION:
+                log.info("Device {} has notification: {}", deviceInfo, event.getMessagePayload());
+                break;
+            case DEVICE_UNREGISTERED:
+                log.warn("Device {} has closed session", deviceInfo);
+                break;
+            case DEVICE_ERROR:
+                log.warn("Device {} has error: {}", deviceInfo, event.getMessagePayload());
+                break;
+            case SESSION_CLOSED:
+                log.warn("Device {} has closed Session: {}", deviceInfo, event.getMessagePayload());
+                break;
+            default:
+                log.warn("Wrong event type {} ", event.type());
+        }
+
+    }
+
+    @Override
+    public boolean isRelevant(NetconfDeviceOutputEvent event) {
+        return deviceInfo.equals(event.getDeviceInfo());
+    }
+}
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
index be76056..8ff65bf 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
@@ -41,6 +41,7 @@
     private int port;
     private char[] key;
     //File keyFile @deprecated 1.9.0
+    @Deprecated
     private File keyFile;
     private DeviceId deviceId;
 
@@ -121,7 +122,7 @@
     /**
      * Exposes the port of the controller.
      *
-     * @return int port address
+     * @return port number
      */
     public int port() {
         return port;
diff --git a/protocols/netconf/ctl/pom.xml b/protocols/netconf/ctl/pom.xml
index 666c933..90c77a8 100644
--- a/protocols/netconf/ctl/pom.xml
+++ b/protocols/netconf/ctl/pom.xml
@@ -35,6 +35,11 @@
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-netconf-api</artifactId>
             <version>${project.version}</version>
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java
index 63a95ba..a68b1c7 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.netconf.ctl;
 
+import org.onosproject.netconf.FilteringNetconfDeviceOutputEventListener;
 import org.onosproject.netconf.NetconfDeviceInfo;
 import org.onosproject.netconf.NetconfDeviceOutputEvent;
 import org.onosproject.netconf.NetconfDeviceOutputEventListener;
@@ -25,7 +26,10 @@
 /**
  * Example of a listener for events that happen a Netconf session established
  * for a particular NETCONF device.
+ *
+ * @deprecated in 1.10.0 use {@link FilteringNetconfDeviceOutputEventListener}
  */
+@Deprecated
 public class NetconfDeviceOutputEventListenerImpl implements NetconfDeviceOutputEventListener {
 
     private static final Logger log =
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
similarity index 96%
rename from protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
rename to protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
index 27c2654..c29b895 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import org.onosproject.netconf.NetconfDevice;
 import org.onosproject.netconf.NetconfDeviceInfo;
@@ -39,6 +39,7 @@
     protected NetconfSessionFactory sessionFactory = new SshNetconfSessionFactory();
     private NetconfSession netconfSession;
 
+    // will block until hello RPC handshake completes
     /**
      * Creates a new default NETCONF device with the information provided.
      * The device gets created only if no exception is thrown while connecting to
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
similarity index 99%
rename from protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
rename to protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
index 59ed7d4..9b4d7fc 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionDelegate.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionDelegate.java
similarity index 95%
rename from protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionDelegate.java
rename to protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionDelegate.java
index 2204184..fd492f3 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionDelegate.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionDelegate.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import org.onosproject.netconf.NetconfDeviceOutputEvent;
 
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
similarity index 98%
rename from protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
rename to protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
index 457bcf2..fc8ac3e 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import com.google.common.annotations.Beta;
 import ch.ethz.ssh2.Connection;
@@ -22,6 +22,7 @@
 import ch.ethz.ssh2.channel.Channel;
 import com.google.common.base.Preconditions;
 import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.FilteringNetconfDeviceOutputEventListener;
 import org.onosproject.netconf.NetconfDeviceInfo;
 import org.onosproject.netconf.NetconfDeviceOutputEvent;
 import org.onosproject.netconf.NetconfDeviceOutputEventListener;
@@ -180,7 +181,7 @@
                                                     sshSession.getStderr(), deviceInfo,
                                                     new NetconfSessionDelegateImpl(),
                                                     replies);
-            this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo));
+            this.addDeviceOutputListener(new FilteringNetconfDeviceOutputEventListener(deviceInfo));
             sendHello();
         } catch (IOException e) {
             log.error("Failed to create ch.ethz.ssh2.Session session {} ", e.getMessage());
@@ -284,6 +285,7 @@
 
     }
 
+    @Override
     public void checkAndReestablish() throws NetconfException {
         if (sshSession.getState() != Channel.STATE_OPEN) {
             try {
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamHandler.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamHandler.java
similarity index 98%
rename from protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamHandler.java
rename to protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamHandler.java
index 98ebf3f..ac959e8 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamHandler.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamHandler.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import com.google.common.annotations.Beta;
 import org.onosproject.netconf.NetconfDeviceOutputEventListener;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java
similarity index 99%
rename from protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
rename to protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java
index e78f9fa..212a4e6 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/package-info.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/package-info.java
new file mode 100644
index 0000000..2cf6838
--- /dev/null
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * NETCONF controller implementations.
+ */
+package org.onosproject.netconf.ctl.impl;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java
index cd80952..f5ba5f4 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java
@@ -17,4 +17,5 @@
 /**
  * NETCONF controller implementations.
  */
+@java.lang.Deprecated
 package org.onosproject.netconf.ctl;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java
similarity index 99%
rename from protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java
rename to protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java
index 25e14ae..8287e6d 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfControllerImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfControllerImplTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import org.easymock.EasyMock;
 import org.junit.After;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceKeyServiceMock.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfDeviceKeyServiceMock.java
similarity index 98%
rename from protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceKeyServiceMock.java
rename to protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfDeviceKeyServiceMock.java
index 6017571..cfe845d 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceKeyServiceMock.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfDeviceKeyServiceMock.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import org.onlab.packet.IpAddress;
 import org.onosproject.net.key.DeviceKey;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceServiceMock.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfDeviceServiceMock.java
similarity index 98%
rename from protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceServiceMock.java
rename to protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfDeviceServiceMock.java
index e008285..ba7ade7 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfDeviceServiceMock.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfDeviceServiceMock.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfSessionImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
similarity index 99%
rename from protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfSessionImplTest.java
rename to protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
index 86822a6..27223b8 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfSessionImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.junit.Assert.assertNotNull;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfSshdTestSubsystem.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java
similarity index 98%
rename from protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfSshdTestSubsystem.java
rename to protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java
index f959038..af1134c 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/NetconfSshdTestSubsystem.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.netconf.ctl;
+package org.onosproject.netconf.ctl.impl;
 
 import java.io.BufferedReader;
 import java.io.EOFException;
@@ -35,7 +35,7 @@
 import org.apache.sshd.server.ExitCallback;
 import org.apache.sshd.server.SessionAware;
 import org.apache.sshd.server.session.ServerSession;
-import org.onosproject.netconf.ctl.NetconfStreamThread.NetconfMessageState;
+import org.onosproject.netconf.ctl.impl.NetconfStreamThread.NetconfMessageState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -94,10 +94,12 @@
             return shutdownExecutor;
         }
 
+        @Override
         public Command create() {
             return new NetconfSshdTestSubsystem(getExecutorService(), isShutdownOnExit());
         }
 
+        @Override
         public String getName() {
             return NAME;
         }
diff --git a/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java b/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java
index 241eb8d..f203884 100644
--- a/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java
+++ b/providers/netconf/alarm/src/main/java/org/onosproject/provider/netconf/alarm/NetconfAlarmProvider.java
@@ -30,6 +30,7 @@
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.provider.AbstractProvider;
 import org.onosproject.net.provider.ProviderId;
+import org.onosproject.netconf.FilteringNetconfDeviceOutputEventListener;
 import org.onosproject.netconf.NetconfController;
 import org.onosproject.netconf.NetconfDevice;
 import org.onosproject.netconf.NetconfDeviceInfo;
@@ -37,7 +38,6 @@
 import org.onosproject.netconf.NetconfDeviceOutputEvent;
 import org.onosproject.netconf.NetconfDeviceOutputEventListener;
 import org.onosproject.netconf.NetconfSession;
-import org.onosproject.netconf.ctl.NetconfDeviceOutputEventListenerImpl;
 import org.slf4j.Logger;
 
 import java.io.ByteArrayInputStream;
@@ -111,7 +111,8 @@
         triggerProbe(deviceId);
     }
 
-    private class InternalNotificationListener extends NetconfDeviceOutputEventListenerImpl
+    private class InternalNotificationListener
+            extends FilteringNetconfDeviceOutputEventListener
             implements NetconfDeviceOutputEventListener {
 
         InternalNotificationListener(NetconfDeviceInfo deviceInfo) {