package org.osgi.test.cases.wireadmin.tbc;

import org.osgi.service.wireadmin.*;

public class FilteredProducerImpl implements Producer {
	protected Wire	wire	= null;

	/**
	 * This method should not be called in the test.
	 * 
	 * @return value out of range to indicate the wrong call
	 */
	public Object polled(Wire wire) {
		return new Integer(100);
	}

	public void consumersConnected(Wire[] wires) {
		if (wires != null)
			this.wire = wires[0];
	}

	public void updateWire(int delta, boolean wait) {
		for (int i = 0; i < 10; i += delta) {
			if (wait) {
				try {
					Thread.sleep(100 * i);
				}
				catch (Exception e) {
				}
			}
			wire.update(new Integer(i));
		}
	}
}

@@ -444,25 +444,26 @@
 res%5B0%5D;%0A%09%7D%0A%0A
-%09
+  
 public void 
@@ -500,18 +500,46 @@
 wait) %7B%0A
-%09%09
+    long processTime = 0;%0A    
 for (int
@@ -568,19 +568,22 @@
 elta) %7B%0A
-%09%09%09
+      
 if (wait
@@ -590,23 +590,75 @@
 ) %7B%0A
-%09%09%09%09try %7B%0A%09%09%09%09%09
+        try %7B%0A          if (100*i - processTime %3E 0) %7B%0A            
 Thre
@@ -670,16 +670,17 @@
 eep(
+(
 100 * i)
 ;%0A%09%09
@@ -679,90 +679,248 @@
 * i)
-;%0A%09%09%09%09%7D%0A%09%09%09%09catch (Exception e) %7B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09wire.update(new Integer(i));%0A%09%09%7D%0A%09
+ - processTime);%0A          %7D%0A        %7D%0A        catch (Exception e) %7B%0A        %7D%0A      %7D%0A      processTime = System.currentTimeMillis();%0A      wire.update(new Integer(i));%0A      processTime = System.currentTimeMillis() - processTime;%0A    %7D%0A  
 %7D%0A%7D%0A

Fix failure when run on really slow devices/PCs