Source Code Cross Referenced for RequestCacheObject.java in  » Database-JDBC-Connection-Pool » xapool » org » enhydra » jdbc » util » 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 » Database JDBC Connection Pool » xapool » org.enhydra.jdbc.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jdbc.util;
002:
003:        import java.util.regex.Pattern;
004:
005:        import org.enhydra.jdbc.util.Logger;
006:        import org.apache.commons.logging.impl.Log4JLogger;
007:        import org.apache.commons.logging.Log;
008:
009:        /**
010:         * one RequestCacheObject for one sql request found in the 
011:         * configuration file
012:         */
013:        public class RequestCacheObject {
014:
015:            // the sql request (sql or pattern)
016:            private String request_ = null;
017:
018:            // time is the beginning of the first ResulSet computing
019:            private long time_ = 0;
020:
021:            // the Object to cache
022:            private Object result_ = null;
023:
024:            // pattern, compiled from the configuration source file
025:            private Pattern pattern_ = null;
026:
027:            // the current object must be live timeToLive_
028:            private long timeToLive_ = 0;
029:
030:            private static Logger logger;
031:
032:            public RequestCacheObject(long ttl) {
033:                logger = new Logger((Log) (new Log4JLogger(
034:                        "org.enhydra.jdbc.util")));
035:                timeToLive_ = ttl;
036:            }
037:
038:            public RequestCacheObject(String req, Pattern pattern, long ttl) {
039:                logger = new Logger((Log) (new Log4JLogger(
040:                        "org.enhydra.jdbc.util")));
041:                logger.debug("RequestCacheObject:RequestCacheObject req=<"
042:                        + req + "> ttl=<" + ttl + ">");
043:                request_ = req;
044:                pattern_ = pattern;
045:                timeToLive_ = ttl;
046:            }
047:
048:            public void setResult(Object rset) {
049:                logger.debug("RequestCacheObject:setResult for=<" + request_
050:                        + ">");
051:                result_ = rset;
052:                time_ = System.currentTimeMillis();
053:            }
054:
055:            public boolean isAlive() {
056:                long now = System.currentTimeMillis();
057:                if (now - time_ > timeToLive_) {
058:                    logger.debug("RequestCacheObject:isAlive out of live");
059:                    return false;
060:                } else {
061:                    if (result_ == null) {
062:                        logger
063:                                .debug("RequestCacheObject:isAlive Object is null ");
064:                        return false;
065:                    } else {
066:                        logger
067:                                .debug("RequestCacheObject:isAlive Object is not null");
068:                        return true;
069:                    }
070:                }
071:            }
072:
073:            public Object getResult() {
074:                if (result_ == null)
075:                    logger
076:                            .debug("RequestCacheObject:getResult result_ is null");
077:
078:                return result_;
079:            }
080:
081:            public Pattern getPattern() {
082:                return pattern_;
083:            }
084:
085:            public String getRequest() {
086:                return request_;
087:            }
088:
089:            public String toString() {
090:                StringBuffer sbuf = new StringBuffer();
091:                sbuf.append("request=<" + request_ + "> time=<" + time_
092:                        + "> time to live=<" + timeToLive_ + "> pattern=<"
093:                        + pattern_.pattern() + ">");
094:                return sbuf.toString();
095:            }
096:
097:            public void close() {
098:                request_ = null;
099:                /* TBD
100:                   try {
101:                   result_.close();
102:                   } catch (Exception e) {
103:                    e.printStackTrace();
104:                    }
105:                 */
106:                result_ = null;
107:                pattern_ = null;
108:            }
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.