BindingIteratorPOA.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* BindingIteratorPOA.java --
  2. Copyright (C) 2005 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 gnu.CORBA.Minor;
  33. import org.omg.CORBA.BAD_OPERATION;
  34. import org.omg.CORBA.CompletionStatus;
  35. import org.omg.CORBA.portable.InputStream;
  36. import org.omg.CORBA.portable.InvokeHandler;
  37. import org.omg.CORBA.portable.OutputStream;
  38. import org.omg.CORBA.portable.ResponseHandler;
  39. import org.omg.PortableServer.POA;
  40. import org.omg.PortableServer.Servant;
  41. /**
  42. * The binding iterator servant, used in POA-based naming service
  43. * implementations.
  44. *
  45. * @since 1.4
  46. *
  47. * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  48. */
  49. public abstract class BindingIteratorPOA
  50. extends Servant
  51. implements BindingIteratorOperations, InvokeHandler
  52. {
  53. /** @inheritDoc */
  54. public String[] _all_interfaces(POA poa, byte[] object_ID)
  55. {
  56. return new String[] { BindingIteratorHelper.id() };
  57. }
  58. /**
  59. * Call the required method.
  60. */
  61. public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
  62. {
  63. OutputStream out = null;
  64. // We suppose that the next_n should be the most popular.
  65. if (method.equals("next_n"))
  66. {
  67. // The next_n has been invoked.
  68. int amount = in.read_ulong();
  69. BindingListHolder a_list = new BindingListHolder();
  70. boolean result = next_n(amount, a_list);
  71. out = rh.createReply();
  72. out.write_boolean(result);
  73. BindingListHelper.write(out, a_list.value);
  74. }
  75. else if (method.equals("next_one"))
  76. {
  77. // The next_one has been invoked.
  78. BindingHolder a_binding = new BindingHolder();
  79. boolean result = next_one(a_binding);
  80. out = rh.createReply();
  81. out.write_boolean(result);
  82. BindingHelper.write(out, a_binding.value);
  83. }
  84. else if (method.equals("destroy"))
  85. {
  86. // The destroy has been invoked.
  87. destroy();
  88. out = rh.createReply();
  89. }
  90. else
  91. throw new BAD_OPERATION(method, Minor.Method,
  92. CompletionStatus.COMPLETED_MAYBE);
  93. return out;
  94. }
  95. /**
  96. * Get the CORBA object that delegates calls to this servant. The servant must
  97. * be already connected to an ORB.
  98. */
  99. public BindingIterator _this()
  100. {
  101. return BindingIteratorHelper.narrow(super._this_object());
  102. }
  103. /**
  104. * Get the CORBA object that delegates calls to this servant. Connect to the
  105. * given ORB, if needed.
  106. */
  107. public BindingIterator _this(org.omg.CORBA.ORB orb)
  108. {
  109. return BindingIteratorHelper.narrow(super._this_object(orb));
  110. }
  111. }