Source Code Cross Referenced for PushEntityCachedResource.java in  » Web-Server » Jigsaw » org » w3c » www » protocol » http » cache » push » 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 Server » Jigsaw » org.w3c.www.protocol.http.cache.push 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        // PushCacheEntityResource.java
02:        // $Id: PushEntityCachedResource.java,v 1.1 2001/10/03 15:00:46 ylafon Exp $
03:        // (c) COPYRIGHT MIT, INRIA and Keio, 2001.
04:        // Please first read the full copyright statement in file COPYRIGHT.html
05:
06:        package org.w3c.www.protocol.http.cache.push;
07:
08:        import org.w3c.www.protocol.http.Request;
09:
10:        import java.io.FileInputStream;
11:        import java.io.FileOutputStream;
12:
13:        import org.w3c.www.protocol.http.cache.CachedResource;
14:        import org.w3c.www.protocol.http.cache.EntityCachedResource;
15:
16:        /**
17:         * PushEntityCachedResource
18:         * EntityCachedResource that reads data from the file rather than attempting
19:         * to use ActiveStream to tee output to a client that is not there.
20:         *
21:         * @author Paul Henshaw, The Fantastic Corporation, Paul.Henshaw@fantastic.com
22:         * @version $Revision: 1.1 $
23:         * $Id: PushEntityCachedResource.java,v 1.1 2001/10/03 15:00:46 ylafon Exp $
24:         */
25:        public class PushEntityCachedResource extends EntityCachedResource {
26:
27:            /**
28:             * This constructor required to handle startup when cache already
29:             * contains PushEntityCachedResources
30:             */
31:            public PushEntityCachedResource() {
32:                super ();
33:            }
34:
35:            /**
36:             * Construct a PushEntityCachedResource 
37:             *
38:             * Used by the PushCacheManager to actually store a PUSH resource.
39:             * Note PushEntityCachedResource are used only when saving 
40:             * resources.  When extracting resources from the cache, 
41:             * EntityCachedResources are used.
42:             * 
43:             * @param filter  the PushCacheFilter that in fact has not done 
44:             *                anything yet, but which knows how to handle a 
45:             *                PUSHed resource
46:             * @param req     the forged request for a URL
47:             * @param rep     the forged reply for the URL
48:             */
49:            protected PushEntityCachedResource(PushCacheFilter filter,
50:                    Request req, PushReply rep) {
51:                try {
52:                    invalidated = false;
53:                    setValue(ATTR_IDENTIFIER, req.getURL().toExternalForm());
54:
55:                    // Keep fast track of the filter:
56:                    this .filter = filter;
57:
58:                    // update the headers
59:                    updateInfo(req, rep);
60:
61:                    // and do some calculation according to the validator
62:                    filter.getValidator().updateExpirationInfo(this , req, rep);
63:
64:                    // Save the content of resource into the content cache:
65:                    java.io.File outfile = filter.getPushCacheStore()
66:                            .getNewEntryFile();
67:
68:                    FileOutputStream os = new FileOutputStream(outfile);
69:                    FileInputStream is = rep.getStream();
70:
71:                    byte[] buffer = new byte[4096];
72:                    int wrote = 0;
73:                    int wantedsize = rep.getContentLength();
74:                    int this time;
75:                    while (wrote < wantedsize) {
76:                        this time = Math.min(is.available(), 4096);
77:                        is.read(buffer, 0, this time);
78:                        os.write(buffer, 0, this time);
79:                        wrote += this time;
80:                    }
81:
82:                    os.close();
83:                    setFile(outfile);
84:                    setLoadState(STATE_LOAD_COMPLETE);
85:                    setCurrentLength(wrote);
86:                } catch (Exception e) {
87:                    e.printStackTrace();
88:                }
89:            }
90:        }
w__w_w__._ja___va__2__s._co_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.