KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > encoding > BufferManagerReadGrow


1 /*
2  * @(#)BufferManagerReadGrow.java 1.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.encoding;
9
10 import java.nio.ByteBuffer JavaDoc;
11 import com.sun.corba.se.spi.orb.ORB;
12 import com.sun.corba.se.spi.logging.CORBALogDomains;
13 import com.sun.corba.se.impl.protocol.giopmsgheaders.FragmentMessage;
14 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
15 import com.sun.corba.se.impl.logging.ORBUtilSystemException;
16
17 public class BufferManagerReadGrow
18     implements BufferManagerRead, MarkAndResetHandler
19 {
20     // REVISIT - This should go in an abstract class called
21
// BufferManagerReadBase which should implement
22
// BufferManagerRead. Then, this class should extend
23
// BufferManagerReadBase.
24
private ORB orb ;
25
26     private ORBUtilSystemException wrapper ;
27
28     BufferManagerReadGrow( ORB orb )
29     {
30     this.orb = orb ;
31     this.wrapper = ORBUtilSystemException.get( orb,
32         CORBALogDomains.RPC_ENCODING ) ;
33     }
34
35     public void processFragment (ByteBuffer JavaDoc byteBuffer, FragmentMessage header)
36     {
37         // REVISIT - should we consider throwing an exception similar to what's
38
// done for underflow()???
39
}
40
41     public void init(Message msg) {}
42
43     public ByteBufferWithInfo underflow (ByteBufferWithInfo bbwi)
44     {
45     throw wrapper.unexpectedEof() ;
46     }
47
48     public void cancelProcessing(int requestId) {}
49     
50     // Mark and reset handler -------------------------
51

52     private Object JavaDoc streamMemento;
53     private RestorableInputStream inputStream;
54     private boolean markEngaged = false;
55
56     public MarkAndResetHandler getMarkAndResetHandler() {
57         return this;
58     }
59
60     public void mark(RestorableInputStream is) {
61         markEngaged = true;
62         inputStream = is;
63         streamMemento = inputStream.createStreamMemento();
64     }
65
66     // This will never happen
67
public void fragmentationOccured(ByteBufferWithInfo newFragment) {}
68
69     public void reset() {
70
71         if (!markEngaged)
72             return;
73
74         markEngaged = false;
75         inputStream.restoreInternalState(streamMemento);
76         streamMemento = null;
77     }
78
79     // Nothing to close and cleanup.
80
public void close(ByteBufferWithInfo bbwi) {}
81 }
82
Popular Tags