1. /*
  2. * @(#)Acceptor.java 1.21 04/06/21
  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.pept.transport;
  8. import com.sun.corba.se.pept.broker.Broker;
  9. import com.sun.corba.se.pept.protocol.MessageMediator;
  10. import com.sun.corba.se.pept.encoding.InputObject;
  11. import com.sun.corba.se.pept.encoding.OutputObject;
  12. import com.sun.corba.se.pept.transport.Connection;
  13. import com.sun.corba.se.pept.transport.EventHandler;
  14. /**
  15. * <p>The <b><em>primary</em></b> PEPt server-side plug-in point and enabler
  16. * for <b><em>altenate encodings, protocols and transports</em></b>.</p>
  17. *
  18. * <p><code>Acceptor</code> is a <em>factory</em> for client-side
  19. * artifacts used to receive a message (and possibly send a response).</p>
  20. *
  21. * @author Harold Carr
  22. */
  23. public interface Acceptor
  24. {
  25. /**
  26. * Used to initialize an <code>Acceptor</code>.
  27. *
  28. * For example, initialization may mean to create a
  29. * {@link java.nio.channels.ServerSocketChannel ServerSocketChannel}.
  30. *
  31. * Note: this must be prepared to be be called multiple times.
  32. *
  33. * @return <code>true</code> when it performs initializatin
  34. * actions (typically the first call.
  35. */
  36. public boolean initialize();
  37. /**
  38. * Used to determine if an <code>Acceptor</code> has been initialized.
  39. *
  40. * @return <code>true</code. if the <code>Acceptor</code> has been
  41. * initialized.
  42. */
  43. public boolean initialized();
  44. /**
  45. * PEPt uses separate caches for each type of <code>Acceptor</code>
  46. * as given by <code>getConnectionCacheType</code>.
  47. *
  48. * @return {@link java.lang.String}
  49. */
  50. public String getConnectionCacheType();
  51. /**
  52. * Set the
  53. * {@link com.sun.corba.se.pept.transport.Inbound.ConnectionCache InboundConnectionCache}
  54. * to be used by this <code>Acceptor</code>.
  55. *
  56. * PEPt uses separate caches for each type of <code>Acceptor</code>
  57. * as given by {@link #getConnectionCacheType}.
  58. * {@link #setConnectionCache} and {@link #getConnectionCache} support
  59. * an optimzation to avoid hashing to find that cache.
  60. *
  61. * @param connectionCache.
  62. */
  63. public void setConnectionCache(InboundConnectionCache connectionCache);
  64. /**
  65. * Get the
  66. * {@link com.sun.corba.se.pept.transport.Inbound.ConnectionCache InboundConnectionCache}
  67. * used by this <code>Acceptor</code>
  68. *
  69. * PEPt uses separate caches for each type of <code>Acceptor</code>
  70. * as given by {@link #getConnectionCacheType}.
  71. * {@link #setConnectionCache} and {@link #getConnectionCache} support
  72. * an optimzation to avoid hashing to find that cache.
  73. *
  74. * @return
  75. * {@link com.sun.corba.se.pept.transport.ConnectionCache ConnectionCache}
  76. */
  77. public InboundConnectionCache getConnectionCache();
  78. /**
  79. * Used to determine if the <code>Acceptor</code> should register
  80. * with
  81. * {@link com.sun.corba.se.pept.transport.Selector Selector}
  82. * to handle accept events.
  83. *
  84. * For example, this may be <em>false</em> in the case of Solaris Doors
  85. * which do not actively listen.
  86. *
  87. * @return <code>true</code> if the <code>Acceptor</code> should be
  88. * registered with
  89. * {@link com.sun.corba.se.pept.transport.Selector Selector}
  90. */
  91. public boolean shouldRegisterAcceptEvent();
  92. /**
  93. * Accept a connection request.
  94. *
  95. * This is called either when the selector gets an accept event
  96. * for this <code>Acceptor</code> or by a
  97. * {@link com.sun.corba.se.pept.transport.ListenerThread ListenerThread}.
  98. *
  99. * It results in a
  100. * {@link com.sun.corba.se.pept.transport.Connection Connection}
  101. * being created.
  102. */
  103. public void accept();
  104. /**
  105. * Close the <code>Acceptor</code>.
  106. */
  107. public void close();
  108. /**
  109. * Get the
  110. * {@link com.sun.corba.se.pept.transport.EventHandler EventHandler}
  111. * associated with this <code>Acceptor</code>.
  112. *
  113. * @return
  114. * {@link com.sun.corba.se.pept.transport.EventHandler EventHandler}
  115. */
  116. public EventHandler getEventHandler();
  117. //
  118. // Factory methods
  119. //
  120. // REVISIT: Identical to ContactInfo method. Refactor into base interface.
  121. /**
  122. * Used to get a
  123. * {@link com.sun.corba.se.pept.protocol.MessageMeidator MessageMediator}
  124. * to hold internal data for a message received using the specific
  125. * encoding, protocol, transport combination represented by this
  126. * <code>Acceptor</code>.
  127. *
  128. * @return
  129. * {@link com.sun.corba.se.pept.protocol.MessageMeidator MessageMediator}
  130. */
  131. public MessageMediator createMessageMediator(Broker xbroker,
  132. Connection xconnection);
  133. // REVISIT: Identical to ContactInfo method. Refactor into base interface.
  134. /**
  135. * Used to finish creating a
  136. * {@link com.sun.corba.se.pept.protocol.MessageMeidator MessageMediator}
  137. * to with internal data for a message received using the specific
  138. * encoding, protocol, transport combination represented by this
  139. * <code>Acceptor</code>.
  140. *
  141. * @return
  142. * {@link com.sun.corba.se.pept.protocol.MessageMediator MessageMediator}
  143. */
  144. public MessageMediator finishCreatingMessageMediator(Broker broker,
  145. Connection xconnection,
  146. MessageMediator messageMediator);
  147. /**
  148. * Used to get a
  149. * {@link com.sun.corba.se.pept.encoding.InputObject InputObject}
  150. * for the specific <em>encoding</em> represented by this
  151. * <code>Acceptor</code>.
  152. *
  153. * @return
  154. * {@link com.sun.corba.se.pept.encoding.InputObject InputObject}
  155. */
  156. public InputObject createInputObject(Broker broker,
  157. MessageMediator messageMediator);
  158. /**
  159. * Used to get a
  160. * {@link com.sun.corba.se.pept.encoding.OutputObject OutputObject}
  161. * for the specific <em>encoding</em> represented by this
  162. * <code>Acceptor</code>.
  163. *
  164. * @return
  165. * {@link com.sun.corba.se.pept.encoding.OutputObject OutputObject}
  166. */
  167. public OutputObject createOutputObject(Broker broker,
  168. MessageMediator messageMediator);
  169. //
  170. // Usage dictates implementation equals and hashCode.
  171. //
  172. }
  173. // End of file.