You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fu...@apache.org on 2008/09/23 18:51:36 UTC
svn commit: r698239 -
/felix/sandbox/furfari/Bug-642/tester/src/main/java/org/apache/felix/upnp/tester/Activator.java
Author: furfari
Date: Tue Sep 23 09:51:36 2008
New Revision: 698239
URL: http://svn.apache.org/viewvc?rev=698239&view=rev
Log:
Added subscription removal
Modified:
felix/sandbox/furfari/Bug-642/tester/src/main/java/org/apache/felix/upnp/tester/Activator.java
Modified: felix/sandbox/furfari/Bug-642/tester/src/main/java/org/apache/felix/upnp/tester/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/furfari/Bug-642/tester/src/main/java/org/apache/felix/upnp/tester/Activator.java?rev=698239&r1=698238&r2=698239&view=diff
==============================================================================
--- felix/sandbox/furfari/Bug-642/tester/src/main/java/org/apache/felix/upnp/tester/Activator.java (original)
+++ felix/sandbox/furfari/Bug-642/tester/src/main/java/org/apache/felix/upnp/tester/Activator.java Tue Sep 23 09:51:36 2008
@@ -22,6 +22,7 @@
import java.util.Dictionary;
import java.util.HashMap;
+import java.util.Iterator;
import org.apache.felix.upnp.basedriver.importer.core.event.thread.SubScriber;
import org.apache.felix.upnp.tester.discovery.DeviceNode;
@@ -56,18 +57,28 @@
}
- public void doTest(){
+ private DeviceNodeListener deviceListener;
+ private HashMap map = new HashMap();
+
+// private long discoveryStart;
+// private long discoveryStop;
+// private long notifyStop;
+ public void doTest(){
System.out.println("starting test");
- listener = new RootDeviceListener();
- listener.setDeviceNodeListener(new DeviceNodeListener(){
- HashMap map = new HashMap();
+ deviceListener = new DeviceNodeListener(){
int countNotify = 1;
int countDevices = 1;
+
+
public void deviceDetected(DeviceNode d) {
+// if (countDevices == 1) discoveryStart = System.currentTimeMillis();
+// discoveryStop = System.currentTimeMillis();
String udn = d.toString();
System.out.println("device DETECTED " + udn + " ### " + countDevices++);
UPnPSubscriber subscriber = new UPnPSubscriber(context, new UPnPEventListener(){
+
public void notifyUPnPEvent(String arg0, String arg1, Dictionary arg2) {
+// notifyStop = System.currentTimeMillis();
System.out.println(arg0 + " " + arg1 + arg2.toString() + " " + countNotify++);
}
});
@@ -80,17 +91,32 @@
UPnPSubscriber subscriber = (UPnPSubscriber)map.remove(udn);
subscriber.unsubscribeAllServicesOF(udn);
if (countDevices==1) countNotify =1;
- }
-
- });
+ }
+ };
+
+
+ listener = new RootDeviceListener();
+ listener.setDeviceNodeListener(deviceListener);
listener.activate();
}
/**
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
+ public void clearSubscriptions(){
+ System.out.println("removing subscripions ...");
+ Iterator i = map.keySet().iterator();
+ while (i.hasNext()){
+ String udn = (String) i.next();
+ UPnPSubscriber subscriber = (UPnPSubscriber)map.get(udn);
+ subscriber.unsubscribeAllServicesOF(udn);
+ }
+ map.clear();
+ }
public void stop(BundleContext context) throws Exception {
+// System.out.println("Device discovery time : " +(discoveryStop - discoveryStart) /*+ "\nNotify time: " + (notifyStop - discoveryStart )*/);
cp.close();
+ clearSubscriptions();
Activator.context=null;
}
}