Java Doc for StreamDemultiplexor.java in  » Net » SkunkDAV » HTTPClient » 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 » Net » SkunkDAV » HTTPClient 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   HTTPClient.StreamDemultiplexor

StreamDemultiplexor
class StreamDemultiplexor implements GlobalConstants(Code)
This class handles the demultiplexing of input stream. This is needed for things like keep-alive in HTTP/1.0, persist in HTTP/1.1 and in HTTP-NG.
version:
   0.3-2 18/06/1999
author:
   Ronald Tschalär



Constructor Summary
 StreamDemultiplexor(int protocol, Socket sock, HTTPConnection connection)
     a simple contructor.

Method Summary
 voidabort()
     Emergency stop.
synchronized  intavailable(ResponseHandler resph)
     Determines the number of available bytes.
synchronized  voidclose(IOException exception, boolean was_reset)
     Closes the socket and all associated streams.
synchronized  voidclose(ResponseHandler resph)
     Closes the associated stream.
synchronized  voidcloseSocketIfAllStreamsClosed()
     Close the socket if all the streams have been closed.

When a stream reaches eof it is removed from the response handler list, but when somebody close()'s the response stream it is just marked as such.

protected  voidfinalize()
     A safety net to close the connection.
synchronized  SocketgetSocket()
    
 RespInputStreamgetStream(Response resp)
     creates an input stream for the response.
synchronized  voidmarkForClose(Response resp)
     Mark this demux to not accept any more request and to close the stream after this response or all requests have been processed, or close immediately if no requests are registered.
 intread(byte[] b, int off, int len, ResponseHandler resph, int timeout)
     reads an array of bytes from the master stream.
 voidregister(Response resp_handler, Request req)
     Each Response must register with us.
 voidrestartTimer()
     Restarts the timer thread that will close an unused socket after 60 seconds.
synchronized  longskip(long num, ResponseHandler resph)
     skips a number of bytes in the master stream.
public  StringtoString()
     produces a string.


Constructor Detail
StreamDemultiplexor
StreamDemultiplexor(int protocol, Socket sock, HTTPConnection connection) throws IOException(Code)
a simple contructor.
Parameters:
  protocol - the protocol used on this stream.
Parameters:
  sock - the socket which we're to demux.
Parameters:
  connection - the http-connection this socket belongs to.




Method Detail
abort
void abort()(Code)
Emergency stop. Closes the socket and notifies the responses that the requests are aborted.
since:
   V0.3



available
synchronized int available(ResponseHandler resph) throws IOException(Code)
Determines the number of available bytes.



close
synchronized void close(IOException exception, boolean was_reset)(Code)
Closes the socket and all associated streams. If exception is not null then all active requests are retried.

There are five ways this method may be activated. 1) if an exception occurs during read or write. 2) if the stream is marked for close but no responses are outstanding (e.g. due to a timeout). 3) when the markedForClose response is closed. 4) if all response streams up until and including the markedForClose response have been closed. 5) if this demux is finalized.
Parameters:
  exception - the IOException to be sent to the streams.
Parameters:
  was_reset - if true then the exception is due to a connectionreset; otherwise it means we generated the exceptionourselves and this is a "normal" close.




close
synchronized void close(ResponseHandler resph)(Code)
Closes the associated stream. If this one has been markedForClose then the socket is closed; else closeSocketIfAllStreamsClosed is invoked.



closeSocketIfAllStreamsClosed
synchronized void closeSocketIfAllStreamsClosed()(Code)
Close the socket if all the streams have been closed.

When a stream reaches eof it is removed from the response handler list, but when somebody close()'s the response stream it is just marked as such. This means that all responses in the list have either not been read at all or only partially read, but they might have been close()'d meaning that nobody is interested in the data. So If all the response streams up till and including the one markedForClose have been close()'d then we can remove them from our list and close the socket.

Note: if the response list is emtpy or if no response is markedForClose then this method does nothing. Specifically it does not close the socket. We only want to close the socket if we've been told to do so.

Also note that there might still be responses in the list after the markedForClose one. These are due to us having pipelined more requests to the server than it's willing to serve on a single connection. These requests will be retried if possible.




finalize
protected void finalize() throws Throwable(Code)
A safety net to close the connection.



getSocket
synchronized Socket getSocket()(Code)
returns the socket associated with this demux



getStream
RespInputStream getStream(Response resp)(Code)
creates an input stream for the response.
Parameters:
  resp - the response structure requesting the stream an InputStream



markForClose
synchronized void markForClose(Response resp)(Code)
Mark this demux to not accept any more request and to close the stream after this response or all requests have been processed, or close immediately if no requests are registered.
Parameters:
  response - the Response after which the connection shouldbe closed.



read
int read(byte[] b, int off, int len, ResponseHandler resph, int timeout) throws IOException(Code)
reads an array of bytes from the master stream.



register
void register(Response resp_handler, Request req) throws RetryException(Code)
Each Response must register with us.



restartTimer
void restartTimer()(Code)
Restarts the timer thread that will close an unused socket after 60 seconds.



skip
synchronized long skip(long num, ResponseHandler resph) throws IOException(Code)
skips a number of bytes in the master stream. This is done via a dummy read, as the socket input stream doesn't like skip()'s.



toString
public String toString()(Code)
produces a string. a string containing the class name and protocol number



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.