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. package com.sun.corba.se.impl.encoding;
  8. import java.nio.ByteBuffer;
  9. import com.sun.corba.se.spi.orb.ORB;
  10. import com.sun.corba.se.spi.logging.CORBALogDomains;
  11. import com.sun.corba.se.impl.protocol.giopmsgheaders.FragmentMessage;
  12. import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
  13. import com.sun.corba.se.impl.logging.ORBUtilSystemException;
  14. public class BufferManagerReadGrow
  15. implements BufferManagerRead, MarkAndResetHandler
  16. {
  17. // REVISIT - This should go in an abstract class called
  18. // BufferManagerReadBase which should implement
  19. // BufferManagerRead. Then, this class should extend
  20. // BufferManagerReadBase.
  21. private ORB orb ;
  22. private ORBUtilSystemException wrapper ;
  23. BufferManagerReadGrow( ORB orb )
  24. {
  25. this.orb = orb ;
  26. this.wrapper = ORBUtilSystemException.get( orb,
  27. CORBALogDomains.RPC_ENCODING ) ;
  28. }
  29. public void processFragment (ByteBuffer byteBuffer, FragmentMessage header)
  30. {
  31. // REVISIT - should we consider throwing an exception similar to what's
  32. // done for underflow()???
  33. }
  34. public void init(Message msg) {}
  35. public ByteBufferWithInfo underflow (ByteBufferWithInfo bbwi)
  36. {
  37. throw wrapper.unexpectedEof() ;
  38. }
  39. public void cancelProcessing(int requestId) {}
  40. // Mark and reset handler -------------------------
  41. private Object streamMemento;
  42. private RestorableInputStream inputStream;
  43. private boolean markEngaged = false;
  44. public MarkAndResetHandler getMarkAndResetHandler() {
  45. return this;
  46. }
  47. public void mark(RestorableInputStream is) {
  48. markEngaged = true;
  49. inputStream = is;
  50. streamMemento = inputStream.createStreamMemento();
  51. }
  52. // This will never happen
  53. public void fragmentationOccured(ByteBufferWithInfo newFragment) {}
  54. public void reset() {
  55. if (!markEngaged)
  56. return;
  57. markEngaged = false;
  58. inputStream.restoreInternalState(streamMemento);
  59. streamMemento = null;
  60. }
  61. // Nothing to close and cleanup.
  62. public void close(ByteBufferWithInfo bbwi) {}
  63. }