Source Code Cross Referenced for ResponseBufferGroup.java in  » Portal » Open-Portal » com » sun » mobile » responsebuffer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.mobile.responsebuffer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: ResponseBufferGroup.java,v 1.3 2004/03/03 19:31:28 batchu Exp $
003:         * Copyright 2003 Sun Microsystems, Inc.
004:         * All rights reserved.
005:         * Use of this product is subject to license terms.
006:         * Federal Acquisitions: Commercial Software -- Government Users
007:         * Subject to Standard License Terms and  Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE are trademarks or
010:         * registered trademarks of Sun Microsystems, Inc. in the
011:         * United States and other countries.
012:         */package com.sun.mobile.responsebuffer;
013:
014:        import java.util.SortedMap;
015:        import java.util.TreeMap;
016:
017:        import com.aligo.util.Cache;
018:
019:        /**
020:         * ResponseBufferGroup holds a ResponseBufferEntry object. It also assigns a
021:         * number to each response buffer entry created in this group and also
022:         * remembers the request urls for the just invalidated buffer entries.
023:         *
024:         * The idea behind this grouping is that this would hold all the response_buffer
025:         * entries and request urls for the recently invalidated entries for a particular
026:         * SSOToken and so it is easier to apply the policies which limits the number
027:         * ResponseBufferEntry objects the user associated with this SSOToken is allowed
028:         * to have.
029:         *
030:         * No method in this class is public, they are all package private. The only
031:         * consumers of this class are ResponseBufferService and ResponseBufferEntry
032:         */
033:        class ResponseBufferGroup {
034:            /**
035:             * This constructor is only called from ResponseBufferService.
036:             *
037:             * @see ResponseBufferService
038:             */
039:            ResponseBufferGroup(int max_num_invalidated_entry_urls) {
040:                if (max_num_invalidated_entry_urls > 0) {
041:                    _max_invalidated_entry_url_list_size = max_num_invalidated_entry_urls;
042:                    _invalidated_entry_url_list = new TreeMap();
043:                }
044:            }
045:
046:            /**
047:             * This ResponseBufferGroup is valid as long as the SSOToken associated
048:             * with this group is valid. The mapping between SSOToken and
049:             * ResponseBufferGroup is managed by ResponseBufferService.
050:             *
051:             * @see ResponseBufferService
052:             */
053:            public synchronized boolean isValid() {
054:                return (_is_valid);
055:            }
056:
057:            /**
058:             * Invalidates the ResponseBufferEntry identified by the given response_buffer_entry_number
059:             */
060:            synchronized void invalidate(Integer entry_number) {
061:                invalidate(getEntry(entry_number));
062:            }
063:
064:            /**
065:             * Invalidates the given ResponseBufferEntry
066:             */
067:            synchronized void invalidate(ResponseBufferEntry entry) {
068:                if (entry == null) {
069:                    return;
070:                }
071:
072:                entry.setInvalid();
073:
074:                if (_invalidated_entry_url_list != null) {
075:                    /*
076:                     * Remove the oldest entry if necessary to make room
077:                     */
078:                    if (_invalidated_entry_url_list.size() >= _max_invalidated_entry_url_list_size) {
079:                        Object _lowest_entry_number = _invalidated_entry_url_list
080:                                .firstKey();
081:                        if (_lowest_entry_number != null) {
082:                            _invalidated_entry_url_list
083:                                    .remove(_lowest_entry_number);
084:                        }
085:                    }
086:
087:                    // Add the request url for this entry to _invalidated_entry_url_list
088:                    _invalidated_entry_url_list.put(entry.getEntryNumber(),
089:                            entry.getRequestURL());
090:                }
091:            }
092:
093:            /**
094:             * Invalidate all the ResponseBufferEntries
095:             */
096:            synchronized void invalidate() {
097:                if (!_is_valid) {
098:                    return;
099:                }
100:
101:                _is_valid = false;
102:
103:                if (_entry != null) {
104:                    _entry.setInvalid();
105:                }
106:
107:                if (_invalidated_entry_url_list != null) {
108:                    _invalidated_entry_url_list.clear();
109:                }
110:            }
111:
112:            /**
113:             * Can be used to assign a number to some new ResponseBufferEntry
114:             */
115:            private synchronized Integer getNextEntryNumber() {
116:                return (new Integer(++_counter));
117:            }
118:
119:            /**
120:             * Creates a ResponseBufferEntry
121:             */
122:            synchronized ResponseBufferEntry createEntry(Cache cache) {
123:                invalidate(_entry);
124:
125:                _entry = new ResponseBufferEntry(this , getNextEntryNumber(),
126:                        cache);
127:                return (_entry);
128:            }
129:
130:            /**
131:             * Gets the ResponseBufferEntry for a given entry_number
132:             */
133:            synchronized ResponseBufferEntry getEntry(Integer entry_number) {
134:                if ((entry_number == null)
135:                        || (_entry == null)
136:                        || (entry_number.compareTo(_entry.getEntryNumber()) != 0)) {
137:                    return (null);
138:                }
139:
140:                return (_entry);
141:            }
142:
143:            /**
144:             * Gets the RequestURL which generated a ResponseBufferEntry for a given entry_number
145:             */
146:            synchronized String getRequestURL(Integer entry_number) {
147:                ResponseBufferEntry entry = getEntry(entry_number);
148:                if (entry != null) {
149:                    return (entry.getRequestURL());
150:                }
151:
152:                if (_invalidated_entry_url_list != null) {
153:                    return ((String) _invalidated_entry_url_list
154:                            .get(entry_number));
155:                }
156:
157:                return (null);
158:            }
159:
160:            /**
161:             * Holds the latest ResponseBufferEntry in this group.
162:             */
163:            private ResponseBufferEntry _entry = null;
164:
165:            /**
166:             * Holds the request urls for some recently invalidated ResponseBufferEntries
167:             */
168:            private SortedMap _invalidated_entry_url_list = null;
169:
170:            /**
171:             * Holds the maximum number of request urls for the recently invalidated
172:             * ResponseBufferEntries. The idea is that if a request is made to this entry
173:             * user can be redirected to the corresponding request url.
174:             */
175:            private int _max_invalidated_entry_url_list_size = 0;
176:
177:            /**
178:             * Every ResponseBufferEntry is given a number by the ResponseBufferGroup, this is the
179:             * number used by others to access the ResponseBufferEntry object.
180:             */
181:            private int _counter = 0;
182:
183:            /**
184:             * To mark whether or not the buffers maintained by this group are still valid.
185:             */
186:            private boolean _is_valid = true;
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.