Source Code Cross Referenced for DataContainer.java in  » Chart » cewolf-1.0 » de » laures » cewolf » taglib » 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 » Chart » cewolf 1.0 » de.laures.cewolf.taglib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 13.04.2003
003:         *
004:         * To change the template for this generated file go to
005:         * Window>Preferences>Java>Code Generation>Code and Comments
006:         */
007:        package de.laures.cewolf.taglib;
008:
009:        import java.io.Serializable;
010:        import java.util.Date;
011:        import java.util.Map;
012:
013:        import org.apache.commons.logging.Log;
014:        import org.apache.commons.logging.LogFactory;
015:        import org.jfree.data.general.Dataset;
016:
017:        import de.laures.cewolf.DatasetProduceException;
018:        import de.laures.cewolf.DatasetProducer;
019:        import de.laures.cewolf.taglib.util.DatasetProductionTimeStore;
020:        import de.laures.cewolf.taglib.util.KeyGenerator;
021:        import de.laures.cewolf.util.Assert;
022:
023:        /**
024:         * @author guido
025:         *
026:         * To change the template for this generated type comment go to
027:         * Window>Preferences>Java>Code Generation>Code and Comments
028:         */
029:        public class DataContainer implements  DataAware, Serializable {
030:
031:            private static transient final Log log = LogFactory
032:                    .getLog(ChartImageDefinition.class);
033:
034:            private transient Dataset data;
035:            private transient DatasetProducer producer;
036:
037:            private Map datasetProductionParams;
038:            private long datasetProduceTime;
039:            private boolean useCache = true;
040:
041:            public void setDataProductionConfig(DatasetProducer dsp,
042:                    Map params, boolean useCache) {
043:                log.debug("setDataProductionConfig");
044:                producer = dsp;
045:                datasetProductionParams = params;
046:                this .useCache = useCache;
047:                checkDataProductionNeed();
048:            }
049:
050:            public Object getDataset() throws DatasetProduceException {
051:                Assert
052:                        .check(producer != null,
053:                                "you need to specifiy a producer for the data of the chart.");
054:                log.debug("getting data..");
055:                if (data == null) {
056:                    log.debug("producing new dataset for "
057:                            + producer.getProducerId());
058:                    data = (Dataset) producer
059:                            .produceDataset(datasetProductionParams);
060:                    DatasetProductionTimeStore dataCache = DatasetProductionTimeStore
061:                            .getInstance();
062:                    dataCache.addEntry(producer.getProducerId(),
063:                            datasetProductionParams, new Date(
064:                                    datasetProduceTime));
065:                }
066:                Assert.check(data != null, "your producer of type "
067:                        + producer.getClass().getName()
068:                        + " produced a null dataset.");
069:                return data;
070:            }
071:
072:            /**
073:             * This method checks if there has been a dataset production 
074:             * for the same DatasetProvider and parameters. If so the DatasetProducer
075:             * is consulted to check the expiry of this data.
076:             * If the data has expired the retrieval of a cached image of this
077:             * ChartDefinition is avoided by setting the datasetProduceTime to the
078:             * actual time. After this the hash code of this object can not be
079:             * present in the image cache and so a new image with new data will
080:             * be rendered.
081:             * If the data did not expire the last dataset production time is stored
082:             * as a memeber to reach the same hash code for this object as the one
083:             * before if possible.
084:             * This method is called during serialization to ensure the same serialized
085:             * representation of this and a eventually formally stored object.
086:             */
087:            private void checkDataProductionNeed() {
088:                log.debug("checking data actuality..." + producer + ", "
089:                        + datasetProductionParams);
090:                final String prodId = producer.getProducerId();
091:                log
092:                        .debug(prodId
093:                                + ", "
094:                                + KeyGenerator
095:                                        .generateKey((Serializable) datasetProductionParams));
096:                log.debug("useCache = " + useCache);
097:                DatasetProductionTimeStore dataCache = DatasetProductionTimeStore
098:                        .getInstance();
099:                if (useCache
100:                        && dataCache.containsEntry(prodId,
101:                                datasetProductionParams)) {
102:                    Date produceTime = dataCache.getProductionTime(prodId,
103:                            datasetProductionParams);
104:                    log.debug("cached data available.");
105:                    // cached data available
106:                    if (!producer.hasExpired(datasetProductionParams,
107:                            produceTime)) {
108:                        log.debug("cached data is still valid.");
109:                        this.datasetProduceTime = produceTime.getTime();
110:                        return;
111:                    }
112:                    dataCache.removeEntry(prodId, datasetProductionParams);
113:                }
114:                datasetProduceTime = System.currentTimeMillis();
115:            }
116:
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.