package fi.csc.microarray.messaging;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import fi.csc.microarray.messaging.message.ChipsterMessage;
import fi.csc.microarray.messaging.message.SuccessMessage;

public class SuccessMessageListener extends TempTopicMessagingListenerBase {

	private SuccessMessage message;;
	private CountDownLatch latch = new CountDownLatch(1);

	public void onChipsterMessage(ChipsterMessage msg) {
		System.out.println("tuli viesti");
		if (msg instanceof SuccessMessage) {
			System.out.println("on success");
			this.message = (SuccessMessage) msg;
			latch.countDown();
		}
	}

	/**
	 * @param timeout in given units
	 * @param unit unit of the timeout
	 * @return null if no reply before timeout
	 * @throws RuntimeException if interrupted
	 */
	public SuccessMessage waitForReply(long timeout, TimeUnit unit) {
		try {
			latch.await(timeout, unit);
		} catch (InterruptedException e) {
			throw new RuntimeException(e);
		}
		return this.message;
	}
}

@@ -462,118 +462,44 @@
 %7B%0A%09%09
-System.out.println(%22tuli viesti%22);%0A%09%09if (msg instanceof SuccessMessage) %7B%0A%09%09%09System.out.println(%22on success%22);
+if (msg instanceof SuccessMessage) %7B
 %0A%09%09%09

Remove debug printing