KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > notification > servant > FilterStageListManager


1 package org.jacorb.notification.servant;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collections JavaDoc;
25
26 import org.jacorb.notification.interfaces.FilterStage;
27
28 /**
29  * @author Alphonse Bendt
30  * @version $Id: FilterStageListManager.java,v 1.7 2005/04/10 14:26:55 alphonse.bendt Exp $
31  */

32
33 abstract public class FilterStageListManager {
34
35     public interface List {
36         void add(FilterStage d);
37     }
38
39     ////////////////////////////////////////
40

41     private final Object JavaDoc lock_ = new Object JavaDoc();
42
43     private java.util.List JavaDoc checkedList_ = Collections.EMPTY_LIST;
44
45     private boolean sourceModified_;
46
47     private java.util.List JavaDoc readOnlyView_ = Collections.EMPTY_LIST;
48
49     ////////////////////////////////////////
50

51     public void actionSourceModified() {
52         synchronized(lock_) {
53             sourceModified_ = true;
54         }
55     }
56
57
58     public java.util.List JavaDoc getList() {
59         synchronized(lock_) {
60             if (sourceModified_) {
61                 final java.util.List JavaDoc _newList = new ArrayList JavaDoc();
62
63                 List JavaDoc _listProxy = new List JavaDoc() {
64                         public void add(FilterStage d) {
65                             if (!d.isDisposed()) {
66                                 _newList.add(d);
67                             }
68                         }
69                     };
70
71                 fetchListData(_listProxy);
72
73                 checkedList_ = _newList;
74                 readOnlyView_ = Collections.unmodifiableList(checkedList_);
75                 sourceModified_ = false;
76             }
77             sortCheckedList(checkedList_);
78             
79             return readOnlyView_;
80         }
81     }
82
83     protected void sortCheckedList(java.util.List JavaDoc list)
84     {
85         // No OP
86
}
87
88     abstract protected void fetchListData(List JavaDoc listProxy);
89 }
90
Popular Tags