This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 29504
Collapse All | Expand All

(-)src/org/netbeans/mdr/storagemodel/MdrStorage.java (+1 lines)
Lines 513-518 Link Here
513
            Storage s = (Storage)it.next();
513
            Storage s = (Storage)it.next();
514
            s.shutDown();
514
            s.shutDown();
515
        }
515
        }
516
        eventNotifier.shutdown();
516
    }
517
    }
517
    
518
    
518
    /* -------------------------------------------------------------------- */
519
    /* -------------------------------------------------------------------- */
(-)src/org/netbeans/mdr/util/EventNotifier.java (-17 / +30 lines)
Lines 1-11 Link Here
1
/*
1
/*
2
 *                 Sun Public License Notice
2
 *                 Sun Public License Notice
3
 * 
3
 *
4
 * The contents of this file are subject to the Sun Public License
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
7
 * http://www.sun.com/
8
 * 
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
Lines 24-37 Link Here
24
 *
24
 *
25
 * @author  mmatula
25
 * @author  mmatula
26
 * @author <a href="mailto:hkrug@rationalizer.com">Holger Krug</a>.
26
 * @author <a href="mailto:hkrug@rationalizer.com">Holger Krug</a>.
27
 * @version 
27
 * @version
28
 */
28
 */
29
public final class EventNotifier {
29
public final class EventNotifier {
30
    
30
31
    /* -------------------------------------------------------------------- */
31
    /* -------------------------------------------------------------------- */
32
    /* -- Constants ------------------------------------------------------- */
32
    /* -- Constants ------------------------------------------------------- */
33
    /* -------------------------------------------------------------------- */
33
    /* -------------------------------------------------------------------- */
34
    
34
35
    /** Bitmask representing all event types which may be received by listeners
35
    /** Bitmask representing all event types which may be received by listeners
36
     * listening on associations. */
36
     * listening on associations. */
37
    public static final int EVENTMASK_BY_ASSOCIATION = MDRChangeEvent.EVENTMASK_ON_ASSOCIATION;
37
    public static final int EVENTMASK_BY_ASSOCIATION = MDRChangeEvent.EVENTMASK_ON_ASSOCIATION;
Lines 47-53 Link Here
47
    /** Bitmask representing all event types which may be received by listeners
47
    /** Bitmask representing all event types which may be received by listeners
48
     * listening on repository proxies. */
48
     * listening on repository proxies. */
49
    public static final int EVENTMASK_BY_REPOSITORY = EVENTMASK_BY_CLASS | MDRChangeEvent.EVENTMASK_ON_REPOSITORY;
49
    public static final int EVENTMASK_BY_REPOSITORY = EVENTMASK_BY_CLASS | MDRChangeEvent.EVENTMASK_ON_REPOSITORY;
50
    
50
51
    /* -------------------------------------------------------------------- */
51
    /* -------------------------------------------------------------------- */
52
    /* -- Methods for debugging purposes (static) ------------------------- */
52
    /* -- Methods for debugging purposes (static) ------------------------- */
53
    /* -------------------------------------------------------------------- */
53
    /* -------------------------------------------------------------------- */
Lines 77-83 Link Here
77
        else return "<UNKNOWN>";
77
        else return "<UNKNOWN>";
78
    }
78
    }
79
    /**
79
    /**
80
     * Pretty prints a event type mask. 
80
     * Pretty prints a event type mask.
81
     *
81
     *
82
     * <p>[XXX]: Probably this method should be used to a test utility
82
     * <p>[XXX]: Probably this method should be used to a test utility
83
     * class ?!</p>
83
     * class ?!</p>
Lines 102-108 Link Here
102
        if ( buf.length() > 0 ) buf.deleteCharAt(buf.length()-1);
102
        if ( buf.length() > 0 ) buf.deleteCharAt(buf.length()-1);
103
        return buf.toString();
103
        return buf.toString();
104
    }
104
    }
105
    
105
106
    /* -------------------------------------------------------------------- */
106
    /* -------------------------------------------------------------------- */
107
    /* -- Public attributes ----------------------------------------------- */
107
    /* -- Public attributes ----------------------------------------------- */
108
    /* -------------------------------------------------------------------- */
108
    /* -------------------------------------------------------------------- */
Lines 116-126 Link Here
116
    /* -------------------------------------------------------------------- */
116
    /* -------------------------------------------------------------------- */
117
    /* -- Private attributes ---------------------------------------------- */
117
    /* -- Private attributes ---------------------------------------------- */
118
    /* -------------------------------------------------------------------- */
118
    /* -------------------------------------------------------------------- */
119
    
119
120
    /**
120
    /**
121
     * Thread for the dispatching of events after transaction success.
121
     * Thread for the dispatching of events after transaction success.
122
     */
122
     */
123
    private final Thread dispatcher = new Thread(new EventsDelivery());
123
    private final Thread dispatcher = new Thread(new EventsDelivery(), "MDR event dispatcher");
124
124
125
    /**
125
    /**
126
     * Maps: event =&gt; set of pre-change listeners.
126
     * Maps: event =&gt; set of pre-change listeners.
Lines 131-144 Link Here
131
     * Maps: event =&gt; set of change listeners.
131
     * Maps: event =&gt; set of change listeners.
132
     */
132
     */
133
    private final Hashtable changeListeners = new Hashtable();
133
    private final Hashtable changeListeners = new Hashtable();
134
    
134
135
    /**
135
    /**
136
     * Queue for the events of the currently running write transaction.
136
     * Queue for the events of the currently running write transaction.
137
     * The events are stored to inform their listeners either about
137
     * The events are stored to inform their listeners either about
138
     * rollback or success.
138
     * rollback or success.
139
     */
139
     */
140
    private final LinkedList localQueue = new LinkedList();
140
    private final LinkedList localQueue = new LinkedList();
141
    
141
142
    /**
142
    /**
143
     * Queue for the events of successfully finished transactions, the
143
     * Queue for the events of successfully finished transactions, the
144
     * listeners of which still have to be informed.
144
     * listeners of which still have to be informed.
Lines 148-154 Link Here
148
    /* -------------------------------------------------------------------- */
148
    /* -------------------------------------------------------------------- */
149
    /* -- Constructor (public) -------------------------------------------- */
149
    /* -- Constructor (public) -------------------------------------------- */
150
    /* -------------------------------------------------------------------- */
150
    /* -------------------------------------------------------------------- */
151
    
151
152
    /**
152
    /**
153
     * Starts the dispatcher thread as daemon.
153
     * Starts the dispatcher thread as daemon.
154
     */
154
     */
Lines 183-190 Link Here
183
                Logger.getDefault().notify(Logger.INFORMATIONAL, e);
183
                Logger.getDefault().notify(Logger.INFORMATIONAL, e);
184
            }
184
            }
185
        }
185
        }
186
    } 
186
    }
187
    
187
188
    /**
188
    /**
189
     * Calls {@link MDRPreChangeListener.changeCancelled(MDRChangeEvent)}
189
     * Calls {@link MDRPreChangeListener.changeCancelled(MDRChangeEvent)}
190
     * on all pre-change listeners of all events of the transaction to be
190
     * on all pre-change listeners of all events of the transaction to be
Lines 210-215 Link Here
210
        localQueue.clear();
210
        localQueue.clear();
211
    }
211
    }
212
    
212
    
213
    private boolean shuttingDown = false;
214
    public void shutdown() {
215
        synchronized (globalQueue) {
216
            shuttingDown = true;
217
            globalQueue.notify();
218
        }
219
    }
220
213
    /* -------------------------------------------------------------------- */
221
    /* -------------------------------------------------------------------- */
214
    /* -- EventNotifier.EventDelivery (inner class, private) -------------- */
222
    /* -- EventNotifier.EventDelivery (inner class, private) -------------- */
215
    /* -------------------------------------------------------------------- */
223
    /* -------------------------------------------------------------------- */
Lines 229-238 Link Here
229
        public void run() {
237
        public void run() {
230
            Collection collected;
238
            Collection collected;
231
            MDRChangeEvent event;
239
            MDRChangeEvent event;
232
            
240
233
            while (true) {
241
            while (true) {
234
                synchronized (globalQueue) {
242
                synchronized (globalQueue) {
235
                    while (globalQueue.isEmpty()) {
243
                    for (;;) {
244
                        if (!globalQueue.isEmpty())
245
                            break;
246
                        else if (shuttingDown)
247
                            return;
248
                        
236
                        try {
249
                        try {
237
                            globalQueue.wait();
250
                            globalQueue.wait();
238
                        } catch (InterruptedException e) {
251
                        } catch (InterruptedException e) {

Return to bug 29504