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.spi;
  6. import javax.security.auth.Subject;
  7. import java.util.Set;
  8. import javax.resource.ResourceException;
  9. /** ManagedConnectionFactory instance is a factory of both ManagedConnection
  10. * and EIS-specific connection factory instances. This interface supports
  11. * connection pooling by providing methods for matching and creation of
  12. * ManagedConnection instance.
  13. *
  14. * @version 0.6
  15. * @author Rahul Sharma
  16. *
  17. * @see javax.resource.spi.ManagedConnection
  18. **/
  19. public interface ManagedConnectionFactory
  20. extends java.io.Serializable {
  21. /** Creates a Connection Factory instance. The Connection Factory
  22. * instance gets initialized with the passed ConnectionManager. In
  23. * the managed scenario, ConnectionManager is provided by the
  24. * application server.
  25. *
  26. * @param cxManager ConnectionManager to be associated with
  27. * created EIS connection factory instance
  28. * @return EIS-specific Connection Factory instance or
  29. * javax.resource.cci.ConnectionFactory instance
  30. *
  31. * @throws ResourceException Generic exception
  32. * @throws ResourceAdapterInternalException
  33. * Resource adapter related error condition
  34. **/
  35. public
  36. Object createConnectionFactory(ConnectionManager cxManager)
  37. throws ResourceException;
  38. /** Creates a Connection Factory instance. The Connection Factory
  39. * instance gets initialized with a default ConnectionManager provided
  40. * by the resource adapter.
  41. *
  42. * @return EIS-specific Connection Factory instance or
  43. * javax.resource.cci.ConnectionFactory instance
  44. *
  45. * @throws ResourceException Generic exception
  46. * @throws ResourceAdapterInternalException
  47. * Resource adapter related error condition
  48. **/
  49. public
  50. Object createConnectionFactory() throws ResourceException;
  51. /** <p>Creates a new physical connection to the underlying EIS
  52. * resource manager,
  53. *
  54. * <p>ManagedConnectionFactory uses the security information (passed as
  55. * Subject) and additional ConnectionRequestInfo (which is specific to
  56. * ResourceAdapter and opaque to application server) to create this new
  57. * connection.
  58. *
  59. * @param Subject Caller's security information
  60. * @param cxRequestInfo Additional resource adapter specific connection
  61. * request information
  62. *
  63. * @throws ResourceException generic exception
  64. * @throws SecurityException security related error
  65. * @throws ResourceAllocationException
  66. * failed to allocate system resources for
  67. * connection request
  68. * @throws ResourceAdapterInternalException
  69. * resource adapter related error condition
  70. * @throws EISSystemException internal error condition in EIS instance
  71. *
  72. * @return ManagedConnection instance
  73. **/
  74. public
  75. ManagedConnection createManagedConnection(
  76. Subject subject,
  77. ConnectionRequestInfo cxRequestInfo)
  78. throws ResourceException;
  79. /** <p>Returns a matched connection from the candidate set of connections.
  80. * </p>
  81. *
  82. * <p>ManagedConnectionFactory uses the security info (as in Subject)
  83. * and information provided through ConnectionRequestInfo and additional
  84. * Resource Adapter specific criteria to do matching. Note that criteria
  85. * used for matching is specific to a resource adapter and is not
  86. * prescribed by the Connector specification.</p>
  87. *
  88. * <p>This method returns a ManagedConnection instance that is the best
  89. * match for handling the connection allocation request.</p>
  90. *
  91. * @param connectionSet candidate connection set
  92. * @param Subject caller's security information
  93. * @param cxRequestInfo additional resource adapter specific connection
  94. * request information
  95. *
  96. * @throws ResourceException generic exception
  97. * @throws SecurityException security related error
  98. * @throws ResourceAdapterInternalException
  99. * resource adapter related error condition
  100. * @throws NotSupportedException if operation is not supported
  101. *
  102. * @return ManagedConnection if resource adapter finds an
  103. * acceptable match otherwise null
  104. **/
  105. public
  106. ManagedConnection matchManagedConnections(
  107. Set connectionSet,
  108. Subject subject,
  109. ConnectionRequestInfo cxRequestInfo)
  110. throws ResourceException;
  111. /** <p>Set the log writer for this ManagedConnectionFactory instance.</p>
  112. *
  113. * <p>The log writer is a character output stream to which all logging and
  114. * tracing messages for this ManagedConnectionfactory instance will be
  115. * printed.</p>
  116. *
  117. * <p>ApplicationServer manages the association of output stream with the
  118. * ManagedConnectionFactory. When a ManagedConnectionFactory object is
  119. * created the log writer is initially null, in other words, logging is
  120. * disabled. Once a log writer is associated with a ManagedConnectionFactory,
  121. * logging and tracing for ManagedConnectionFactory instance is enabled.
  122. *
  123. * <p>The ManagedConnection instances created by ManagedConnectionFactory
  124. * "inherits" the log writer, which can be overridden by ApplicationServer
  125. * using ManagedConnection.setLogWriter to set ManagedConnection specific
  126. * logging and tracing.
  127. *
  128. * @param out PrintWriter - an out stream for
  129. * error logging and tracing
  130. * @throws ResourceException generic exception
  131. * @throws ResourceAdapterInternalException
  132. * resource adapter related error condition
  133. **/
  134. public
  135. void setLogWriter(java.io.PrintWriter out) throws ResourceException;
  136. /** Get the log writer for this ManagedConnectionFactory instance.
  137. *
  138. * <p>The log writer is a character output stream to which all logging and
  139. * tracing messages for this ManagedConnectionFactory instance will be
  140. * printed
  141. *
  142. * <p>ApplicationServer manages the association of output stream with the
  143. * ManagedConnectionFactory. When a ManagedConnectionFactory object is
  144. * created the log writer is initially null, in other words, logging is
  145. * disabled.
  146. *
  147. * @return PrintWriter
  148. * @throws ResourceException generic exception
  149. **/
  150. public
  151. java.io.PrintWriter getLogWriter() throws ResourceException;
  152. /** Returns the hash code for the ManagedConnectionFactory
  153. *
  154. * @return hash code for the ManagedConnectionFactory
  155. **/
  156. public
  157. int hashCode();
  158. /** Check if this ManagedConnectionFactory is equal to another
  159. * ManagedConnectionFactory.
  160. *
  161. * @return true if two instances are equal
  162. **/
  163. public
  164. boolean equals(Object other);
  165. }