Source Code Cross Referenced for InMemoryTSH.java in  » Web-Framework » RSF » uk » org » ponder » rsf » state » 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 » Web Framework » RSF » uk.org.ponder.rsf.state 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:         * Created on Aug 5, 2005
03:         */
04:        package uk.org.ponder.rsf.state;
05:
06:        import java.util.Date;
07:        import java.util.Map;
08:
09:        import uk.org.ponder.reflect.ReflectiveCache;
10:        import uk.org.ponder.rsac.GlobalBeanAccessor;
11:        import uk.org.ponder.util.Logger;
12:
13:        /**
14:         * The repository of all inter-request state in RSF. This is held in entries of
15:         * TokenRequestState in a (probably very large) ConcurrentHashMap which is
16:         * perpetually expired on a TTL basis. More rapid expiry may occur through
17:         * explicit session-closing and wizard-ending procedures.
18:         * <p>
19:         * High-requirement applications would presumably reimplement this class to push
20:         * this state into a database or some sort of clustered broadcast.
21:         * 
22:         * NB!! Expiry not yet implemented! Do not use this class in production!
23:         * @author Antranig Basman (antranig@caret.cam.ac.uk)
24:         */
25:        public class InMemoryTSH implements  TokenStateHolder {
26:
27:            // a map of String error token IDs to ErrorStateEntries.
28:            // the idea is that this be a timeout cache which is cleared out every
29:            // hour or so... all this functionality to be moved to another class.
30:            private Map tokencache;
31:
32:            private int expiryseconds;
33:
34:            public void setReflectiveCache(ReflectiveCache reflectiveCache) {
35:                //this.reflectiveCache = reflectiveCache;
36:                reflectiveCache.getConcurrentMap(16);
37:            }
38:
39:            TokenState getTokenStateRaw(String tokenID) {
40:                return (TokenState) tokencache.get(tokenID);
41:            }
42:
43:            // TODO: The plan is that this thread is JVM-wide, and InMemoryTSH
44:            // are in charge of attaching and detaching their caches to it on init and
45:            // destruction. Managing the necessary IPC will be an annoyance. ANDY!!
46:            private void launchExpirralThread() {
47:
48:            }
49:
50:            /**
51:             * Returns any TokenRequestState object with the specified ID.
52:             * 
53:             * @return The required TRS object, or <code>null</code> if none is stored.
54:             */
55:            public Object getTokenState(String tokenID) {
56:                TokenState state = getTokenStateRaw(tokenID);
57:                return state == null ? null : state.payload;
58:            }
59:
60:            /** Stores the supplied TokenRequestState object in the repository */
61:            public void putTokenState(String tokenID, Object payload) {
62:
63:                TokenState trs = new TokenState();
64:                trs.payload = payload;
65:                trs.tokenID = tokenID;
66:                Date current = new Date();
67:                long forwardsecs = current.getTime() + expiryseconds * 1000;
68:                trs.expiry = new Date(forwardsecs);
69:                tokencache.put(trs.tokenID, trs);
70:            }
71:
72:            public void clearTokenState(String tokenID) {
73:
74:                Logger.log
75:                        .info("Token state cleared from InMemoryTSH for token "
76:                                + tokenID);
77:                tokencache.remove(tokenID);
78:            }
79:
80:            public void setExpirySeconds(int seconds) {
81:                this .expiryseconds = seconds;
82:            }
83:
84:            public String getId() {
85:                return null;
86:            }
87:
88:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.