Author: michiel
Date: 2010-07-01 14:28:59 +0200 (Thu, 01 Jul 2010)
New Revision: 42770
Modified:
mmbase/trunk/utils/src/main/java/org/mmbase/core/event/EventManager.java
Log:
some exceptions were happening e.g. in bridge junit tests
Modified:
mmbase/trunk/utils/src/main/java/org/mmbase/core/event/EventManager.java
===================================================================
--- mmbase/trunk/utils/src/main/java/org/mmbase/core/event/EventManager.java
2010-07-01 11:57:03 UTC (rev 42769)
+++ mmbase/trunk/utils/src/main/java/org/mmbase/core/event/EventManager.java
2010-07-01 12:28:59 UTC (rev 42770)
@@ -31,7 +31,12 @@
* @version $Id$
*/
public class EventManager implements SystemEventListener {
+ /**
+ * the instance that this singleton will manage
+ */
+ private static final EventManager eventManager = new EventManager();
+
private static final Logger log =
Logging.getLoggerInstance(EventManager.class);
private static final UUID INSTANCEID = UUID.randomUUID();
@@ -45,10 +50,6 @@
org.mmbase.util.xml.EntityResolver.registerPublicID(PUBLIC_ID_EVENTMANAGER,
DTD_EVENTMANAGER, EventManager.class);
}
- /**
- * the instance that this singleton will manage
- */
- private static final EventManager eventManager = new EventManager();
/**
* The collection of event brokers. There is one for every event type that
can be sent/received
@@ -57,11 +58,15 @@
private long numberOfPropagatedEvents = 0;
private long duration = 0;
+ private boolean setup = false;
/**
* use this metod to get an instance of the event manager
*/
public static EventManager getInstance() {
+ if (eventManager == null) {
+ throw new IllegalStateException();
+ }
return eventManager;
}
@@ -92,16 +97,9 @@
}
- protected ResourceWatcher watcher = new ResourceWatcher() {
- public void onChange(String w) {
- configure(w);
- }
- };
+ protected ResourceWatcher watcher;
private EventManager() {
- watcher.add("eventmanager.xml");
- watcher.onChange();
- watcher.start();
}
@@ -182,6 +180,21 @@
* @param listener
*/
public synchronized void addEventListener(EventListener listener) {
+ if (! setup) {
+ setup = true;
+ // this is procrasted as long as possible to avoid
+ // circular dependencies on bootstrap
+ watcher = new ResourceWatcher() {
+ public void onChange(String w) {
+ configure(w);
+ }
+ };
+ watcher.add("eventmanager.xml");
+ watcher.onChange();
+ watcher.start();
+
+ }
+
BrokerIterator i = findBrokers(listener);
boolean notifiedReceived = false;
while (i.hasNext()) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs