1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.resource.cci;
  6. import javax.resource.ResourceException;
  7. import javax.resource.NotSupportedException;
  8. /** The <code>javax.resource.cci.Interaction</code> enables a component to
  9. * execute EIS functions. An Interaction instance supports the following ways
  10. * of interacting with an EIS instance:
  11. * <UL>
  12. * <LI><code>execute</code> method that takes an input Record, output
  13. * Record and an InteractionSpec. This method executes the EIS
  14. * function represented by the InteractionSpec and updates the
  15. * output Record
  16. * <LI><code>execute</code> method that takes an input Record and an
  17. * InteractionSpec. This method implementation executes the EIS
  18. * function represented by the InteractionSpec and produces the
  19. * output Record as a return value.
  20. * </UL>
  21. * <p>An Interaction instance is created from a Connection and is required
  22. * to maintain its association with the Connection instance. The close method
  23. * releases all resources maintained by the resource adapter for the
  24. * Interaction. The close of an Interaction instance should not close the
  25. * associated Connection instance.
  26. *
  27. * @author Rahul Sharma
  28. * @version 0.8
  29. * @since 0.8
  30. * @see java.sql.ResultSet
  31. **/
  32. public interface Interaction {
  33. /** Closes the current Interaction and release all the resources
  34. * held for this instance by the resource adapter. The close of an
  35. * Interaction instance does not close the associated Connection
  36. * instance. It is recommended that Interaction instances be
  37. * closed explicitly to free any held resources.
  38. *
  39. * @throws ResourceException Failed to close the Interaction
  40. * instance. Invoking close on an
  41. * already closed Interaction should
  42. * also throw this exception.
  43. **/
  44. public
  45. void close() throws ResourceException;
  46. /** Gets the Connection associated with the Interaction.
  47. *
  48. * @return Connection instance associated with the Interaction
  49. **/
  50. public
  51. Connection getConnection();
  52. /** Executes an interaction represented by the InteractionSpec.
  53. * This form of invocation takes an input Record and updates
  54. * the output Record.
  55. *
  56. * @param ispec InteractionSpec representing a target EIS
  57. * data/function module
  58. * @param input Input Record
  59. * @param output Output Record
  60. *
  61. * @return true if execution of the EIS function has been
  62. * successful and output Record has been updated; false
  63. * otherwise
  64. *
  65. * @throws ResourceException Exception if execute operation
  66. * fails. Examples of error cases
  67. * are:
  68. * <UL>
  69. * <LI> Resource adapter internal, EIS-specific or
  70. * communication error
  71. * <LI> Invalid specification of an InteractionSpec,
  72. * input or output record structure
  73. * <LI> Errors in use of input or output Record
  74. * <LI> Invalid connection associated with this
  75. * Interaction
  76. * </UL>
  77. * @throws NotSupportedException Operation not supported
  78. *
  79. **/
  80. public
  81. boolean execute(InteractionSpec ispec,
  82. Record input,
  83. Record output) throws ResourceException;
  84. /** Executes an interaction represented by the InteractionSpec.
  85. * This form of invocation takes an input Record and returns an
  86. * output Record if the execution of the Interaction has been
  87. * successfull.
  88. *
  89. * @param ispec InteractionSpec representing a target EIS
  90. * data/function module
  91. * @param input Input Record
  92. * @return output Record if execution of the EIS function has been
  93. * successful; null otherwise
  94. *
  95. * @throws ResourceException Exception if execute operation
  96. * fails. Examples of error cases
  97. * are:
  98. * <UL>
  99. * <LI> Resource adapter internal, EIS-specific or
  100. * communication error
  101. * <LI> Invalid specification of an InteractionSpec
  102. * or input record structure
  103. * <LI> Errors in use of input Record or creation
  104. * of an output Record
  105. * <LI> Invalid connection associated with this
  106. * Interaction
  107. * </UL>
  108. * @throws NotSupportedException Operation not supported
  109. **/
  110. public
  111. Record execute(InteractionSpec ispec,
  112. Record input) throws ResourceException;
  113. /** Gets the first ResourceWarning from the chain of warnings
  114. * associated with this Interaction instance.
  115. *
  116. * @return ResourceWarning at top of the warning chain
  117. * @throws ResourceException Failed to get ResourceWarnings
  118. * associated with Interaction
  119. **/
  120. public
  121. ResourceWarning getWarnings() throws ResourceException;
  122. /** Clears all the warning reported by this Interaction instance. After
  123. * a call to this method, the method getWarnings will return null
  124. * until a new warning is reported for this Interaction.
  125. *
  126. * @throws ResourceException Failed to clear ResourceWarnings
  127. * associated with Interaction
  128. **/
  129. public
  130. void clearWarnings() throws ResourceException;
  131. }