Index: src/org/netbeans/mdr/storagemodel/MdrStorage.java =================================================================== RCS file: /cvs/mdr/src/org/netbeans/mdr/storagemodel/MdrStorage.java,v retrieving revision 1.45 diff -u -r1.45 MdrStorage.java --- src/org/netbeans/mdr/storagemodel/MdrStorage.java 28 Nov 2002 19:50:33 -0000 1.45 +++ src/org/netbeans/mdr/storagemodel/MdrStorage.java 12 Dec 2002 09:51:19 -0000 @@ -513,6 +513,7 @@ Storage s = (Storage)it.next(); s.shutDown(); } + eventNotifier.shutdown(); } /* -------------------------------------------------------------------- */ Index: src/org/netbeans/mdr/util/EventNotifier.java =================================================================== RCS file: /cvs/mdr/src/org/netbeans/mdr/util/EventNotifier.java,v retrieving revision 1.9 diff -u -r1.9 EventNotifier.java --- src/org/netbeans/mdr/util/EventNotifier.java 6 Sep 2002 17:01:23 -0000 1.9 +++ src/org/netbeans/mdr/util/EventNotifier.java 12 Dec 2002 09:51:20 -0000 @@ -1,11 +1,11 @@ /* * Sun Public License Notice - * + * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ - * + * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. @@ -24,14 +24,14 @@ * * @author mmatula * @author Holger Krug. - * @version + * @version */ public final class EventNotifier { - + /* -------------------------------------------------------------------- */ /* -- Constants ------------------------------------------------------- */ /* -------------------------------------------------------------------- */ - + /** Bitmask representing all event types which may be received by listeners * listening on associations. */ public static final int EVENTMASK_BY_ASSOCIATION = MDRChangeEvent.EVENTMASK_ON_ASSOCIATION; @@ -47,7 +47,7 @@ /** Bitmask representing all event types which may be received by listeners * listening on repository proxies. */ public static final int EVENTMASK_BY_REPOSITORY = EVENTMASK_BY_CLASS | MDRChangeEvent.EVENTMASK_ON_REPOSITORY; - + /* -------------------------------------------------------------------- */ /* -- Methods for debugging purposes (static) ------------------------- */ /* -------------------------------------------------------------------- */ @@ -77,7 +77,7 @@ else return ""; } /** - * Pretty prints a event type mask. + * Pretty prints a event type mask. * *

[XXX]: Probably this method should be used to a test utility * class ?!

@@ -102,7 +102,7 @@ if ( buf.length() > 0 ) buf.deleteCharAt(buf.length()-1); return buf.toString(); } - + /* -------------------------------------------------------------------- */ /* -- Public attributes ----------------------------------------------- */ /* -------------------------------------------------------------------- */ @@ -116,11 +116,11 @@ /* -------------------------------------------------------------------- */ /* -- Private attributes ---------------------------------------------- */ /* -------------------------------------------------------------------- */ - + /** * Thread for the dispatching of events after transaction success. */ - private final Thread dispatcher = new Thread(new EventsDelivery()); + private final Thread dispatcher = new Thread(new EventsDelivery(), "MDR event dispatcher"); /** * Maps: event => set of pre-change listeners. @@ -131,14 +131,14 @@ * Maps: event => set of change listeners. */ private final Hashtable changeListeners = new Hashtable(); - + /** * Queue for the events of the currently running write transaction. * The events are stored to inform their listeners either about * rollback or success. */ private final LinkedList localQueue = new LinkedList(); - + /** * Queue for the events of successfully finished transactions, the * listeners of which still have to be informed. @@ -148,7 +148,7 @@ /* -------------------------------------------------------------------- */ /* -- Constructor (public) -------------------------------------------- */ /* -------------------------------------------------------------------- */ - + /** * Starts the dispatcher thread as daemon. */ @@ -183,8 +183,8 @@ Logger.getDefault().notify(Logger.INFORMATIONAL, e); } } - } - + } + /** * Calls {@link MDRPreChangeListener.changeCancelled(MDRChangeEvent)} * on all pre-change listeners of all events of the transaction to be @@ -210,6 +210,14 @@ localQueue.clear(); } + private boolean shuttingDown = false; + public void shutdown() { + synchronized (globalQueue) { + shuttingDown = true; + globalQueue.notify(); + } + } + /* -------------------------------------------------------------------- */ /* -- EventNotifier.EventDelivery (inner class, private) -------------- */ /* -------------------------------------------------------------------- */ @@ -229,10 +237,15 @@ public void run() { Collection collected; MDRChangeEvent event; - + while (true) { synchronized (globalQueue) { - while (globalQueue.isEmpty()) { + for (;;) { + if (!globalQueue.isEmpty()) + break; + else if (shuttingDown) + return; + try { globalQueue.wait(); } catch (InterruptedException e) {