Source Code Cross Referenced for SmbNamedPipe.java in  » Groupware » hipergate » com » knowgate » jcifs » smb » 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 » Groupware » hipergate » com.knowgate.jcifs.smb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* jcifs smb client library in Java
002:         * Copyright (C) 2000  "Michael B. Allen" <jcifs at samba dot org>
003:         *                     "Paul Walker" <jcifs at samba dot org>
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:
020:        package com.knowgate.jcifs.smb;
021:
022:        import java.net.URL;
023:        import java.io.IOException;
024:        import java.io.InputStream;
025:        import java.io.OutputStream;
026:        import java.net.MalformedURLException;
027:        import java.net.UnknownHostException;
028:
029:        /**
030:         * This class will allow a Java program to read and write data to Named
031:         * Pipes and Transact NamedPipes.
032:         *
033:         * <p>There are three Win32 function calls provided by the Windows SDK
034:         * that are important in the context of using jCIFS. They are:
035:         *
036:         * <ul>
037:         * <li> <code>CallNamedPipe</code> A message-type pipe call that opens,
038:         *      writes to, reads from, and closes the pipe in a single operation.
039:         * <li> <code>TransactNamedPipe</code> A message-type pipe call that
040:         *      writes to and reads from an existing pipe descriptor in one operation.
041:         * <li> <code>CreateFile</code>, <code>ReadFile</code>,
042:         *      <code>WriteFile</code>, and <code>CloseFile</code> A byte-type pipe can
043:         *      be opened, written to, read from and closed using the standard Win32
044:         *      file operations.
045:         * </ul>
046:         *
047:         * <p>The jCIFS API maps all of these operations into the standard Java
048:         * <code>XxxputStream</code> interface. A special <code>PIPE_TYPE</code>
049:         * flags is necessary to distinguish which type of Named Pipe behavior
050:         * is desired.
051:         *
052:         * <p><table border="1" cellpadding="3" cellspacing="0" width="100%">
053:         * <tr bgcolor="#ccccff">
054:         * <td colspan="2"><b><code>SmbNamedPipe</code> Constructor Examples</b></td>
055:         * <tr><td width="20%"><b>Code Sample</b></td><td><b>Description</b></td></tr>
056:         * <tr><td width="20%"><pre>
057:         * new SmbNamedPipe( "smb://server/IPC$/PIPE/foo",
058:         *         SmbNamedPipe.PIPE_TYPE_RDWR |
059:         *         SmbNamedPipe.PIPE_TYPE_CALL );
060:         * </pre></td><td>
061:         * Open the Named Pipe foo for reading and writing. The pipe will behave like the <code>CallNamedPipe</code> interface.
062:         * </td></tr>
063:         * <tr><td width="20%"><pre>
064:         * new SmbNamedPipe( "smb://server/IPC$/foo",
065:         *         SmbNamedPipe.PIPE_TYPE_RDWR |
066:         *         SmbNamedPipe.PIPE_TYPE_TRANSACT );
067:         * </pre></td><td>
068:         * Open the Named Pipe foo for reading and writing. The pipe will behave like the <code>TransactNamedPipe</code> interface.
069:         * </td></tr>
070:         * <tr><td width="20%"><pre>
071:         * new SmbNamedPipe( "smb://server/IPC$/foo",
072:         *         SmbNamedPipe.PIPE_TYPE_RDWR );
073:         * </pre></td><td>
074:         * Open the Named Pipe foo for reading and writing. The pipe will
075:         * behave as though the <code>CreateFile</code>, <code>ReadFile</code>,
076:         * <code>WriteFile</code>, and <code>CloseFile</code> interface was
077:         * being used.
078:         * </td></tr>
079:         * </table>
080:         *
081:         * <p>See <a href="../../../pipes.html">Using jCIFS to Connect to Win32
082:         * Named Pipes</a> for a detailed description of how to use jCIFS with
083:         * Win32 Named Pipe server processes.
084:         *
085:         */
086:
087:        public class SmbNamedPipe extends SmbFile {
088:
089:            /**
090:             * The pipe should be opened read-only.
091:             */
092:
093:            public static final int PIPE_TYPE_RDONLY = O_RDONLY;
094:
095:            /**
096:             * The pipe should be opened only for writing.
097:             */
098:
099:            public static final int PIPE_TYPE_WRONLY = O_WRONLY;
100:
101:            /**
102:             * The pipe should be opened for both reading and writing.
103:             */
104:
105:            public static final int PIPE_TYPE_RDWR = O_RDWR;
106:
107:            /**
108:             * Pipe operations should behave like the <code>CallNamedPipe</code> Win32 Named Pipe function.
109:             */
110:
111:            public static final int PIPE_TYPE_CALL = 0x01;
112:
113:            /**
114:             * Pipe operations should behave like the <code>TransactNamedPipe</code> Win32 Named Pipe function.
115:             */
116:
117:            public static final int PIPE_TYPE_TRANSACT = 0x02;
118:
119:            InputStream pipeIn;
120:            OutputStream pipeOut;
121:            int pipeType;
122:
123:            /**
124:             * Open the Named Pipe resource specified by the url
125:             * parameter. The pipeType parameter should be at least one of
126:             * the <code>PIPE_TYPE</code> flags combined with the bitwise OR
127:             * operator <code>|</code>. See the examples listed above.
128:             */
129:
130:            public SmbNamedPipe(String url, int pipeType)
131:                    throws MalformedURLException, UnknownHostException {
132:                super (url);
133:                this .pipeType = pipeType;
134:                type = TYPE_NAMED_PIPE;
135:            }
136:
137:            public SmbNamedPipe(String url, int pipeType,
138:                    NtlmPasswordAuthentication auth)
139:                    throws MalformedURLException, UnknownHostException {
140:                super (url, auth);
141:                this .pipeType = pipeType;
142:                type = TYPE_NAMED_PIPE;
143:            }
144:
145:            public SmbNamedPipe(URL url, int pipeType,
146:                    NtlmPasswordAuthentication auth)
147:                    throws MalformedURLException, UnknownHostException {
148:                super (url, auth);
149:                this .pipeType = pipeType;
150:                type = TYPE_NAMED_PIPE;
151:            }
152:
153:            /**
154:             * Return the <code>InputStream</code> used to read information
155:             * from this pipe instance. Presumably data would first be written
156:             * to the <code>OutputStream</code> associated with this Named
157:             * Pipe instance although this is not a requirement (e.g. a
158:             * read-only named pipe would write data to this stream on
159:             * connection). Reading from this stream may block. Therefore it
160:             * may be necessary that an addition thread be used to read and
161:             * write to a Named Pipe.
162:             */
163:
164:            public InputStream getNamedPipeInputStream() throws IOException {
165:                if (pipeIn == null) {
166:                    if ((pipeType & PIPE_TYPE_CALL) == PIPE_TYPE_CALL
167:                            || (pipeType & PIPE_TYPE_TRANSACT) == PIPE_TYPE_TRANSACT) {
168:                        pipeIn = new TransactNamedPipeInputStream(this );
169:                    } else {
170:                        pipeIn = new SmbFileInputStream(this ,
171:                                (pipeType & 0xFF0000) | SmbFile.O_EXCL);
172:                    }
173:                }
174:                return pipeIn;
175:            }
176:
177:            /**
178:             * Return the <code>OutputStream</code> used to write
179:             * information to this pipe instance. The act of writing data
180:             * to this stream will result in response data recieved in the
181:             * <code>InputStream</code> associated with this Named Pipe
182:             * instance (unless of course it does not elicite a response or the pipe is write-only).
183:             */
184:
185:            public OutputStream getNamedPipeOutputStream() throws IOException {
186:                if (pipeOut == null) {
187:                    if ((pipeType & PIPE_TYPE_CALL) == PIPE_TYPE_CALL
188:                            || (pipeType & PIPE_TYPE_TRANSACT) == PIPE_TYPE_TRANSACT) {
189:                        pipeOut = new TransactNamedPipeOutputStream(this );
190:                    } else {
191:                        pipeOut = new SmbFileOutputStream(this , false,
192:                                (pipeType & 0xFF0000) | SmbFile.O_EXCL);
193:                    }
194:                }
195:                return pipeOut;
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.