[Bprocessor-commit] kernel/src/net/sourceforge/bprocessor/kernel/notification Notifier.java,1.3,1.4
Status: Pre-Alpha
Brought to you by:
henryml
From: Jesper P. <je...@us...> - 2005-09-23 06:53:18
|
Update of /cvsroot/bprocessor/kernel/src/net/sourceforge/bprocessor/kernel/notification In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20606/src/net/sourceforge/bprocessor/kernel/notification Modified Files: Notifier.java Log Message: Added support for both async (default) and sync notifications Index: Notifier.java =================================================================== RCS file: /cvsroot/bprocessor/kernel/src/net/sourceforge/bprocessor/kernel/notification/Notifier.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Notifier.java 17 Aug 2005 10:08:08 -0000 1.3 --- Notifier.java 23 Sep 2005 06:53:10 -0000 1.4 *************** *** 7,13 **** --- 7,15 ---- package net.sourceforge.bprocessor.kernel.notification; + import java.io.FileInputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import java.util.Properties; import org.apache.log4j.Logger; *************** *** 23,26 **** --- 25,31 ---- private static Notifier instance; + /** Use async communication */ + private boolean async; + /** The listeners */ private List listeners; *************** *** 31,34 **** --- 36,56 ---- private Notifier() { listeners = new ArrayList(); + async = true; + try { + Properties prop = new Properties(); + prop.load(new FileInputStream("bprocessor.properties")); + + String asyncStr = prop.getProperty("notification.async"); + if (asyncStr != null && asyncStr.trim().equals("0")) { + async = false; + } + } catch (Exception e) { + // Use default value + } + if (async) { + log.info("Using async notifications"); + } else { + log.info("Using sync notifications"); + } } *************** *** 77,81 **** while (it.hasNext()) { NotificationListener l = (NotificationListener)it.next(); ! new NotificationThread(l, n).start(); } } --- 99,107 ---- while (it.hasNext()) { NotificationListener l = (NotificationListener)it.next(); ! if (async) { ! new NotificationThread(l, n).start(); ! } else { ! l.handleNotification(n); ! } } } |