Source Code Cross Referenced for NetletGroupManager.java in  » Portal » Open-Portal » com » sun » portal » netlet » eproxy » 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.portal.netlet.eproxy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.netlet.eproxy;
002:
003:        /*
004:         * Manages the creation/deletion and modification of the NetletGroups
005:         * Ensures that there will be only one NetletGroup Associated with a
006:         * single user session at any instance of time
007:         *
008:         * @ see com.iplanet.sso.SSOToken
009:         * @ see com.sun.portal.netlet.eproxy.NetletGroup
010:         * @ see com.sun.portal.netlet.econnection.ReaderWriterLock
011:         *
012:         * @ Created 31-08-2001
013:         * @ Author Rajesh T
014:         */
015:
016:        import java.util.Enumeration;
017:        import java.util.Hashtable;
018:        import java.util.logging.Level;
019:        import java.util.logging.Logger;
020:
021:        import com.iplanet.sso.SSOException;
022:        import com.iplanet.sso.SSOToken;
023:        import com.iplanet.sso.SSOTokenID;
024:        import com.iplanet.sso.SSOTokenManager;
025:        import com.sun.portal.log.common.PortalLogger;
026:        import com.sun.portal.netlet.econnection.ReaderWriterLock;
027:        import com.sun.portal.util.GWThreadPool;
028:
029:        public class NetletGroupManager {
030:
031:            private static Hashtable userNetlets = new Hashtable();
032:
033:            private static NetletGroupManager manager = null;
034:
035:            private static SessionKeepAlive ska = null;
036:
037:            // private static Logger logger =
038:            // Logger.getLogger("com.sun.portal.sra.netlet");
039:            private static Logger logger = PortalLogger
040:                    .getLogger(NetletGroupManager.class);
041:
042:            // Singleton Class
043:            private NetletGroupManager() {
044:            }
045:
046:            /*
047:             * Provides access to the NetletGroupManager Creates a Manager it there
048:             * exists none
049:             */
050:
051:            public static NetletGroupManager getNetletGroupManager() {
052:                if (manager == null)
053:                    manager = new NetletGroupManager();
054:                return manager;
055:            }
056:
057:            /*
058:             * Checks the internal structure if there already exists a NetletGroup for
059:             * this session if so reuses it. else creates a new NetletGroup and and adds
060:             * to the interanal structure @ see
061:             * com.sun.portal.netlet.eproxy.ReaderWriterLock @ see
062:             * com.iplanet.sso.SSOToken
063:             */
064:
065:            public static void registerReaderWriter(ReaderWriterLock r,
066:                    SSOToken ssoToken) throws SSOException {
067:                String ssoTokenID = ssoToken.getTokenID().toString();
068:                init(ssoToken);
069:                safeAddToUserNetlets(r, ssoToken, ssoTokenID);
070:            }
071:
072:            /*
073:             * Checks the internal structure if there already exists a NetletGroup for
074:             * this session if so reuses it. else creates a new NetletGroup and and adds
075:             * to the interanal structure
076:             *  @ see com.sun.portal.netlet.eproxy.ReaderWriterLock @ see
077:             * com.iplanet.sso.SSOTokenID
078:             */
079:
080:            /**
081:             * @param r
082:             * @param ssoToken
083:             * @param ssoTokenID
084:             * @throws SSOException
085:             */
086:            private static void safeAddToUserNetlets(ReaderWriterLock r,
087:                    SSOToken ssoToken, String ssoTokenID) throws SSOException {
088:                synchronized (userNetlets) {
089:                    NetletGroup ng = (NetletGroup) userNetlets.get(ssoTokenID);
090:                    if (ng == null) {
091:                        ng = new NetletGroup(manager, ssoToken);
092:                    }
093:                    ng.add(r);
094:                    manager.userNetlets.put(ssoTokenID, ng);
095:
096:                }
097:            }
098:
099:            /*
100:             * Checks the internal structure if there already exists a NetletGroup for
101:             * this session if so reuses it. else creates a new NetletGroup and and adds
102:             * to the interanal structure @ see
103:             * com.sun.portal.netlet.eproxy.ReaderWriterLock @ see
104:             * com.iplanet.sso.SSOTokenID
105:             */
106:
107:            public static void registerReaderWriter(ReaderWriterLock r,
108:                    SSOTokenID ssoTokenId) throws SSOException {
109:                String ssoTokenID = ssoTokenId.toString();
110:                SSOTokenManager ssoTokenManager = SSOTokenManager.getInstance();
111:                SSOToken ssoToken = ssoTokenManager.createSSOToken(ssoTokenID);
112:                init(ssoToken);
113:                safeAddToUserNetlets(r, ssoToken, ssoTokenID);
114:
115:            }
116:
117:            /*
118:             * Checks the internal structure if there already exists a NetletGroup for
119:             * this session if so reuses it. else creates a new NetletGroup and and adds
120:             * to the interanal structure @ see
121:             * com.sun.portal.netlet.eproxy.ReaderWriterLock @ see String
122:             */
123:
124:            public static void registerReaderWriter(ReaderWriterLock r,
125:                    String ssoTokenID) throws SSOException {
126:                SSOTokenManager ssoTokenManager = SSOTokenManager.getInstance();
127:                SSOToken ssoToken = ssoTokenManager.createSSOToken(ssoTokenID);
128:                init(ssoToken);
129:                safeAddToUserNetlets(r, ssoToken, ssoTokenID);
130:
131:            }
132:
133:            /*
134:             * Removes the NetletGroup from the internal structure @ see
135:             * com.iplanet.sso.SSOToken
136:             */
137:            public static void unregister(SSOToken ssoToken) {
138:                String ssoTokenID = ssoToken.getTokenID().toString();
139:                clean(ssoTokenID);
140:                manager.userNetlets.remove(ssoTokenID);
141:            }
142:
143:            /*
144:             * Removes the NetletGroup from the internal structure @ see
145:             * com.iplanet.sso.SSOTokenID
146:             */
147:            public static void unregister(SSOTokenID ssoTokenId) {
148:                String ssoTokenID = ssoTokenId.toString();
149:                clean(ssoTokenID);
150:                manager.userNetlets.remove(ssoTokenID);
151:            }
152:
153:            /*
154:             * Removes the NetletGroup from the internal structure @ see
155:             * com.iplanet.sso.SSOTokenID
156:             */
157:            public static void unregister(String ssoTokenID) {
158:                clean(ssoTokenID);
159:                manager.userNetlets.remove(ssoTokenID);
160:            }
161:
162:            /*
163:             * Provides proper shutdown of the ReaderWriterLocks associated with the
164:             * Session which is present inside the NetletGroup
165:             */
166:            public static void clean(String ssoTokenID) {
167:                NetletGroup ng = (NetletGroup) manager.userNetlets
168:                        .get(ssoTokenID);
169:                ng.clean();
170:            }
171:
172:            /*
173:             * public static synchronized void clean(SSOToken ssoToken) { NetletGroup ng
174:             * =(NetletGroup) manager.userNetlets.get(ssoToken.getTokenID().toString());
175:             * ng.clean(); }
176:             */
177:
178:            /*
179:             * Returns all the user sessions that are currently managed by the
180:             * NetletGroupManager
181:             * 
182:             * @see com.iplanet.sso.SSOToken
183:             */
184:            public static String[] getRegisteredSessions() {
185:
186:                Enumeration enumeration = null;
187:                String[] keys = null;
188:
189:                synchronized (userNetlets) {
190:                    enumeration = manager.userNetlets.keys();
191:                    keys = new String[manager.userNetlets.size()];
192:                }
193:
194:                int i = 0;
195:
196:                while (enumeration.hasMoreElements()) {
197:                    keys[i] = (String) enumeration.nextElement();
198:                    i++;
199:                }
200:                return keys;
201:            }
202:
203:            /*
204:             * public synchronized static SSOToken[] getRegisteredSessions() { public
205:             * synchronized static String[] getRegisteredSessions() { Enumeration enum =
206:             * manager.userNetlets.keys(); int i = 0; String[] keys = new
207:             * String[manager.userNetlets.size()]; while (enum.hasMoreElements()) {
208:             * keys[i] = (String) enum.nextElement(); i++; } return keys; }
209:             *  /* public synchronized static SSOToken[] getRegisteredSessions() {
210:             * Enumeration enum = manager.userNetlets.keys(); int i=0; SSOToken[] keys =
211:             * new SSOToken[manager.userNetlets.size()]; while (enum.hasMoreElements()){
212:             * keys[i] = (SSOToken) enum.nextElement(); i++; } return keys; }
213:             */
214:
215:            /*
216:             * Returns the NetletGroup associated with the user Session @ param
217:             * com.iplanet.sso.SSOToken @ see com.sun.portal.netlet.eproxy.NetletGroup
218:             */
219:
220:            public static NetletGroup getNetletGroup(String ssoTokenID) {
221:                return ((NetletGroup) manager.userNetlets.get(ssoTokenID));
222:            }
223:
224:            /*
225:             * public static synchronized NetletGroup getNetletGroup(SSOToken ssoToken) {
226:             * return
227:             * ((NetletGroup)manager.userNetlets.get(ssoToken.getTokenID().toString())); }
228:             */
229:
230:            /*
231:             * Ensures that there is always a SessionKeepAlive thread to extend the
232:             * maxIdleTime for the registered session @ see
233:             * com.sun.portal.netlet.eproxy.SessionKeepAlive
234:             */
235:
236:            private static void init(SSOToken ssoToken) {
237:                if (manager.ska == null) {
238:                    try {
239:                        manager.ska = new SessionKeepAlive(manager, ssoToken
240:                                .getMaxIdleTime());
241:                        GWThreadPool.run(ska);
242:                    } catch (InterruptedException ie) {
243:                        // logger.log(Level.SEVERE, "Unable to start Session Keep Alive
244:                        // Thread from Netlet Group manager", ie);
245:                        logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX047");
246:                    } catch (SSOException se) {
247:                        // logger.log(Level.SEVERE, "Unable to start Session Keep Alive
248:                        // Thread from Netlet Group manager", se);
249:                        logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX048");
250:                    }
251:                }
252:            }
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.