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. /** A Connection represents an application-level handle that is used
  9. * by a client to access the underlying physical connection. The actual
  10. * physical connection associated with a Connection instance is
  11. * represented by a ManagedConnection instance.
  12. *
  13. * <p>A client gets a Connection instance by using the
  14. * <code>getConnection</code> method on a <code>ConnectionFactory</code>
  15. * instance. A connection can be associated with zero or more Interaction
  16. * instances.
  17. *
  18. * @author Rahul Sharma
  19. * @version 0.8
  20. * @see javax.resource.cci.ConnectionFactory
  21. * @see javax.resource.cci.Interaction
  22. **/
  23. public interface Connection {
  24. /** Creates an Interaction associated with this Connection. An
  25. * Interaction enables an application to execute EIS functions.
  26. *
  27. * @return Interaction instance
  28. * @throws ResourceException Failed to create an Interaction
  29. **/
  30. public
  31. Interaction createInteraction()
  32. throws ResourceException;
  33. /** Returns an LocalTransaction instance that enables a component to
  34. * demarcate resource manager local transactions on the Connection.
  35. * If a resource adapter does not allow a component to demarcate
  36. * local transactions on an Connection using LocalTransaction
  37. * interface, then the method getLocalTransaction should throw a
  38. * NotSupportedException.
  39. *
  40. * @return LocalTransaction instance
  41. *
  42. * @throws ResourceException Failed to return a LocalTransaction
  43. * instance because of a resource
  44. * adapter error
  45. * @throws NotSupportedException Demarcation of Resource manager
  46. * local transactions is not supported
  47. * on this Connection
  48. * @see javax.resource.cci.LocalTransaction
  49. **/
  50. public
  51. LocalTransaction getLocalTransaction() throws ResourceException;
  52. /** Gets the information on the underlying EIS instance represented
  53. * through an active connection.
  54. *
  55. * @return ConnectionMetaData instance representing information
  56. * about the EIS instance
  57. * @throws ResourceException
  58. * Failed to get information about the
  59. * connected EIS instance. Error can be
  60. * resource adapter-internal, EIS-specific
  61. * or communication related.
  62. **/
  63. public
  64. ConnectionMetaData getMetaData() throws ResourceException;
  65. /** Gets the information on the ResultSet functionality supported by
  66. * a connected EIS instance.
  67. *
  68. * @return ResultSetInfo instance
  69. * @throws ResourceException Failed to get ResultSet related
  70. * information
  71. * @throws NotSupportedException ResultSet functionality is not
  72. * supported
  73. **/
  74. public
  75. ResultSetInfo getResultSetInfo() throws ResourceException;
  76. /** Initiates close of the connection handle at the application level.
  77. * A client should not use a closed connection to interact with
  78. * an EIS.
  79. *
  80. * @throws ResourceException Exception thrown if close
  81. * on a connection handle fails.
  82. * <p>Any invalid connection close invocation--example,
  83. * calling close on a connection handle that is
  84. * already closed--should also throw this exception.
  85. *
  86. **/
  87. public
  88. void close() throws ResourceException;
  89. }