_BindingIteratorStub.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* _BindingIteratorStub.java --
  2. Copyright (C) 2005, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package org.omg.CosNaming;
  32. import org.omg.CORBA.MARSHAL;
  33. import org.omg.CORBA.portable.ApplicationException;
  34. import org.omg.CORBA.portable.Delegate;
  35. import org.omg.CORBA.portable.InputStream;
  36. import org.omg.CORBA.portable.ObjectImpl;
  37. import org.omg.CORBA.portable.OutputStream;
  38. import org.omg.CORBA.portable.RemarshalException;
  39. /**
  40. * The binding interator stub (proxy), used on the client side.
  41. * The BindingIterator methods contains the code for remote invocaton.
  42. *
  43. * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  44. */
  45. public class _BindingIteratorStub
  46. extends ObjectImpl
  47. implements BindingIterator
  48. {
  49. /**
  50. * Use serialVersionUID (v1.4) for interoperability.
  51. */
  52. private static final long serialVersionUID = 8969257760771186704L;
  53. /**
  54. * The object can be destroyed only once.
  55. */
  56. private boolean destroyed;
  57. /**
  58. * Create the stub.
  59. */
  60. public _BindingIteratorStub()
  61. {
  62. super();
  63. }
  64. /**
  65. * Create the stub that used the given delegate.
  66. */
  67. _BindingIteratorStub(Delegate delegate)
  68. {
  69. super();
  70. _set_delegate(delegate);
  71. }
  72. /**
  73. * Get an array of repository ids for this object.
  74. */
  75. public String[] _ids()
  76. {
  77. return new String[] { BindingIteratorHelper.id() };
  78. }
  79. /**
  80. * Returns true if the object has been destroyed.
  81. */
  82. public boolean _non_existent()
  83. {
  84. return destroyed;
  85. }
  86. /**
  87. * Destroys the object on the server side.
  88. * The destruction message is sent only once, even if the method is
  89. * called repeatedly.
  90. */
  91. public void destroy()
  92. {
  93. if (destroyed)
  94. return;
  95. InputStream _in = null;
  96. try
  97. {
  98. OutputStream _out = _request("destroy", true);
  99. _in = _invoke(_out);
  100. destroyed = true;
  101. }
  102. catch (ApplicationException _ex)
  103. {
  104. _in = _ex.getInputStream();
  105. throw new MARSHAL(_ex.getId());
  106. }
  107. catch (RemarshalException _rm)
  108. {
  109. destroy();
  110. }
  111. finally
  112. {
  113. _releaseReply(_in);
  114. }
  115. }
  116. /** {@inheritDoc} */
  117. public boolean next_n(int amount, BindingListHolder a_list)
  118. {
  119. InputStream _in = null;
  120. try
  121. {
  122. OutputStream _out = _request("next_n", true);
  123. _out.write_ulong(amount);
  124. _in = _invoke(_out);
  125. boolean result = _in.read_boolean();
  126. a_list.value = BindingListHelper.read(_in);
  127. return result;
  128. }
  129. catch (ApplicationException _ex)
  130. {
  131. _in = _ex.getInputStream();
  132. throw new MARSHAL(_ex.getId());
  133. }
  134. catch (RemarshalException _rm)
  135. {
  136. return next_n(amount, a_list);
  137. }
  138. finally
  139. {
  140. _releaseReply(_in);
  141. }
  142. }
  143. /** {@inheritDoc} */
  144. public boolean next_one(BindingHolder a_binding)
  145. {
  146. InputStream _in = null;
  147. try
  148. {
  149. OutputStream _out = _request("next_one", true);
  150. _in = _invoke(_out);
  151. boolean result = _in.read_boolean();
  152. a_binding.value = BindingHelper.read(_in);
  153. return result;
  154. }
  155. catch (ApplicationException _ex)
  156. {
  157. _in = _ex.getInputStream();
  158. throw new MARSHAL(_ex.getId());
  159. }
  160. catch (RemarshalException _rm)
  161. {
  162. return next_one(a_binding);
  163. }
  164. finally
  165. {
  166. _releaseReply(_in);
  167. }
  168. }
  169. /**
  170. * Destroys the iterator instance on the server side, calling
  171. * {@link #destroy()}.
  172. *
  173. * @throws java.lang.Throwable
  174. */
  175. protected void finalize()
  176. throws java.lang.Throwable
  177. {
  178. destroy();
  179. super.finalize();
  180. }
  181. }