

Public Methods | |
| Chunk | prepare () throws JonathanException |
| void | close () |
| Chunk | duplicate () throws JonathanException |
| Chunk | duplicate (int off, int t) throws JonathanException |
| void | release () |
Protected Methods | |
| void | finalize () |
Private Methods | |
| TcpIpChunkProvider (TcpIpProtocol.Session session) | |
| TcpIpChunkProvider (TcpIpChunkProvider message) | |
| final void | delete () |
Private Attributes | |
| TcpIpProtocol Session | session |
| IpConnection | connection |
| int | max |
| Chunk | cache |
Static Private Attributes | |
| final byte [] | empty_data = new byte[0] |
| final Chunk | empty_chunk = new Chunk(empty_data,0,0) |
Definition at line 629 of file TcpIpProtocol.java.
|
|
Definition at line 642 of file TcpIpProtocol.java. 00642 {
00643 super(empty_data,0,0);
00644 max = 0;
00645 this.session = session;
00646 connection = session.connection;
00647 cache = empty_chunk;
00648 }
|
|
|
Definition at line 650 of file TcpIpProtocol.java. 00650 {
00651 super(message.data,message.offset,message.top);
00652 cache = message.cache;
00653 max = message.max;
00654 session = message.session;
00655 connection = message.connection;
00656 message.cache = null;
00657 }
|
|
|
Closes the chunk provider. This method must be called if the target provider is no longer used. Reimplemented from ChunkProvider. Definition at line 699 of file TcpIpProtocol.java. Referenced by TcpIpProtocol::CltSession::send(), and TcpIpProtocol::SrvSession::send(). 00699 {
00700 if (cache != null) {
00701 session.closeNotify(this);
00702 }
00703 }
|
|
|
Definition at line 713 of file TcpIpProtocol.java. Referenced by TcpIpProtocol::Session::closeNotify(). 00713 {
00714 if (cache != null) {
00715 cache.release();
00716 cache = null;
00717 }
00718
00719 session.deleteNotify(this);
00720 }
|
|
|
Partially duplicates this chunk. 'offset' must be greater than the target chunk's offset, 'top' must be less or equal than the target's top. The default implementation copies the appropriate portion of the buffer, and creates a new chunk with it.
Reimplemented from Chunk. Definition at line 727 of file TcpIpProtocol.java. 00727 {
00728 cache.top = top;
00729 return cache.duplicate(off,t);
00730 }
|
|
|
Duplicates the whole chunk. The default implementation copies the buffer, and creates a new chunk with it.
Reimplemented from Chunk. Definition at line 722 of file TcpIpProtocol.java. 00722 {
00723 cache.top = top;
00724 return cache.duplicate(offset,top);
00725 }
|
|
|
Definition at line 705 of file TcpIpProtocol.java. 00705 {
00706 if (cache != null) {
00707 System.err.println("Resource management error. message " + this +
00708 " has not been properly closed.");
00709 delete();
00710 }
00711 }
|
|
|
Returns a chunk to read data from. When done with the chunk, its user must update its offset and top members and release it. ChunkProviders should not be used concurrently.
Reimplemented from ChunkProvider. Definition at line 659 of file TcpIpProtocol.java. 00659 {
00660 TcpIpProtocol protocol = session.getProtocol();
00661 if (top == offset) {
00662 // there is nothing left to read from this message
00663 try {
00664 int to_read = connection.available();
00665 if (to_read > 1) {
00666 if (to_read > max - top) {
00667 cache.release();
00668 cache = protocol.chunk_factory.newChunk(to_read);
00669 data = cache.data;
00670 offset = cache.offset;
00671 top = cache.top;
00672 max = data.length;
00673 }
00674 connection.receive(this,to_read);
00675 return this;
00676 } else {
00677 if (max - top == 0) {
00678 cache.release();
00679 cache = protocol.chunk_factory.newChunk();
00680 data = cache.data;
00681 offset = cache.offset;
00682 top = cache.top;
00683 max = data.length;
00684 }
00685 connection.receive(this,1);
00686 return this;
00687 }
00688 } catch (IOException e) {
00689 delete();
00690 connection.delete();
00691 connection = null;
00692 throw new JonathanException(e);
00693 }
00694 } else {
00695 return this;
00696 }
00697 }
|
|
|
Releases the chunk. The data of a chunk may be obtained from managed buffers. It may thus be necessary to tell when the data encapsulated by a chunk may be reused. The default implementation resets offset and top to 0. Reimplemented from Chunk. Definition at line 732 of file TcpIpProtocol.java. 00732 {}
|
|
|
the data of this chunk provider are the cache data. Definition at line 640 of file TcpIpProtocol.java. |
|
|
The network connection Definition at line 636 of file TcpIpProtocol.java. |
|
|
Definition at line 631 of file TcpIpProtocol.java. |
|
|
Definition at line 630 of file TcpIpProtocol.java. |
|
|
Definition at line 637 of file TcpIpProtocol.java. |
|
|
Reader associated with the chunk Definition at line 634 of file TcpIpProtocol.java. |
1.2.6 written by Dimitri van Heesch,
© 1997-2001