Source Code Cross Referenced for FileTunnel.java in  » XML » activexml » org » xdev » base » xssl » io » 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 » XML » activexml » org.xdev.base.xssl.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Feb 12, 2004
003:         *
004:         * To change the template for this generated file go to
005:         * Window>Preferences>Java>Code Generation>Code and Comments
006:         */
007:        package org.xdev.base.xssl.io;
008:
009:        import java.io.File;
010:        import java.io.FileInputStream;
011:        import java.io.OutputStream;
012:        import java.io.PipedWriter;
013:        import java.io.PipedReader;
014:        import java.io.Writer;
015:        import java.io.BufferedOutputStream;
016:        import java.lang.reflect.Method;
017:        import java.util.HashMap;
018:
019:        import org.xdev.base.xssl.XSSLReturn;
020:        import org.xdev.base.xssl.manage.ITransactionFinalizable;
021:
022:        /**
023:         * @author AYegorov
024:         *
025:         * To change the template for this generated type comment go to
026:         * Window>Preferences>Java>Code Generation>Code and Comments
027:         */
028:        public class FileTunnel extends AbstractFile implements 
029:                ITransactionFinalizable {
030:            private Object objStream = null;
031:
032:            public final static int WRITE = 0;
033:            public final static int FLUSH = 1;
034:            public final static int CLOSE = 2;
035:
036:            /**
037:             * @param id
038:             */
039:            public FileTunnel(String id) {
040:                super (id);
041:                // XXX Auto-generated constructor stub
042:            }
043:
044:            /**
045:             * @param id
046:             * @param properties
047:             */
048:            public FileTunnel(String id, HashMap properties) {
049:                super (id, properties);
050:                // XXX Auto-generated constructor stub
051:            }
052:
053:            /* (non-Javadoc)
054:             * @see org.xdev.base.xssl.io.AbstractFile#processFile(java.io.File)
055:             */
056:            protected Object processFile(File f) throws Exception {
057:                byte[] buffer = new byte[this .hasProperty("buffer-size") ? this 
058:                        .getIntegerProperty("buffer-size") : new Long(f
059:                        .length()).intValue()];
060:
061:                FileInputStream in = new FileInputStream(f);
062:
063:                XSSLReturn w = (XSSLReturn) this .getElement(0);
064:
065:                if (w.execute(this )) {
066:
067:                    this .objStream = w.getObjectValue();
068:
069:                    if (this .objStream instanceof  OutputStream) {
070:                        this .objStream = new BufferedOutputStream(
071:                                (OutputStream) this .objStream);
072:                    }
073:
074:                    int c;
075:
076:                    while ((c = in.read(buffer)) != -1) {
077:
078:                        //this.objStream.getClass().getMethod("write", new Class[] {byte[].class}).invoke(this.objStream, new Object[]{});
079:
080:                        this .doStreamAction(this .objStream, FileTunnel.WRITE,
081:                                new Object[] { buffer });
082:                    }
083:                }
084:
085:                return null;
086:            }
087:
088:            protected Object doStreamAction(Object stream, int action,
089:                    Object[] params) throws Exception {
090:
091:                Class streamClass = stream.getClass();
092:
093:                Method streamMethod = null;
094:
095:                Class[] signature = null;
096:
097:                String methodName = null;
098:
099:                switch (action) {
100:                case FileTunnel.WRITE:
101:                    methodName = "write";
102:
103:                    signature = new Class[] { byte[].class };
104:                    break;
105:
106:                case FileTunnel.FLUSH:
107:                    methodName = "flush";
108:                    break;
109:
110:                case FileTunnel.CLOSE:
111:                    methodName = "close";
112:                    break;
113:                }
114:
115:                return streamMethod.invoke(stream, params);
116:            }
117:
118:            public void doFinalize() throws Exception {
119:                this.doStreamAction(this.objStream, FileTunnel.FLUSH, null);
120:                this.doStreamAction(this.objStream, FileTunnel.CLOSE, null);
121:            }
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.