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 java.io.PrintWriter;
  7. import javax.resource.ResourceException;
  8. import javax.resource.NotSupportedException;
  9. /** <code>ConnectionFactory</code> provides an interface for getting
  10. * connection to an EIS instance. An implementation of ConnectionFactory
  11. * interface is provided by a resource adapter.
  12. *
  13. * <p>Application code looks up a ConnectionFactory instance from JNDI
  14. * namespace and uses it to get EIS connections.
  15. *
  16. * <p>An implementation class for ConnectionFactory is required to
  17. * implement <code>java.io.Serializable</code> and
  18. * <code>javax.resource.Referenceable</code>interfaces to support
  19. * JNDI registration.
  20. *
  21. * @author Rahul Sharma
  22. * @version 0.8
  23. * @see javax.resource.cci.Connection
  24. * @see javax.resource.Referenceable
  25. **/
  26. public interface ConnectionFactory
  27. extends java.io.Serializable,
  28. javax.resource.Referenceable {
  29. /** Gets a connection to an EIS instance. This getConnection variant
  30. * should be used when a component wants the container to manage EIS
  31. * sign-on. This case is termed container-managed sign-on. The
  32. * component does not pass any security information.
  33. *
  34. *
  35. * @return Connection instance
  36. * @throws ResourceException Failed to get a connection to
  37. * the EIS instance. Examples of
  38. * error cases are:
  39. * <UL>
  40. * <LI> Invalid configuration of ManagedConnectionFactory--
  41. * example: invalid server name
  42. * <LI> Application server-internal error--example:
  43. * connection pool related error
  44. * <LI> Communication error
  45. * <LI> EIS-specific error--example: EIS not active
  46. * <LI> Resource adapter-internal error
  47. * <LI> Security related error; example: invalid user
  48. * <LI> Failure to allocate system resources
  49. * </UL>
  50. **/
  51. public
  52. Connection getConnection() throws ResourceException;
  53. /** Gets a connection to an EIS instance. A component should use
  54. * the getConnection variant with javax.resource.cci.ConnectionSpec
  55. * parameter, if it needs to pass any resource adapter specific
  56. * security information and connection parameters. In the component-
  57. * managed sign-on case, an application component passes security
  58. * information (example: username, password) through the
  59. * ConnectionSpec instance.
  60. *
  61. * <p>It is important to note that the properties passed through
  62. * the getConnection method should be client-specific (example:
  63. * username, password, language) and not related to the
  64. * configuration of a target EIS instance (example: port number,
  65. * server name). The ManagedConnectionFactory instance is configured
  66. * with complete set of properties required for the creation of a
  67. * connection to an EIS instance.
  68. *
  69. * @param properties Connection parameters and security
  70. * information specified as
  71. * ConnectionSpec instance
  72. * @return Connection instance
  73. *
  74. * @throws ResourceException Failed to get a connection to
  75. * the EIS instance. Examples of
  76. * error cases are:
  77. * <UL>
  78. * <LI> Invalid specification of input parameters
  79. * <LI> Invalid configuration of ManagedConnectionFactory--
  80. * example: invalid server name
  81. * <LI> Application server-internal error--example:
  82. * connection pool related error
  83. * <LI> Communication error
  84. * <LI> EIS-specific error--example: EIS not active
  85. * <LI> Resource adapter-internal error
  86. * <LI> Security related error; example: invalid user
  87. * <LI> Failure to allocate system resources
  88. * </UL>
  89. * @see javax.resource.cci.ConnectionSpec
  90. **/
  91. public
  92. Connection getConnection(ConnectionSpec properties)
  93. throws ResourceException;
  94. /** Gets a RecordFactory instance. The RecordFactory is used for
  95. * the creation of generic Record instances.
  96. *
  97. * @return RecordFactory RecordFactory instance
  98. *
  99. * @throws ResourceException Failed to create a RecordFactory
  100. * @throws NotSupportedException Operation not supported
  101. **/
  102. public
  103. RecordFactory getRecordFactory() throws ResourceException;
  104. /** Gets metadata for the Resource Adapter. Note that the metadata
  105. * information is about the ResourceAdapter and not the EIS instance.
  106. * An invocation of this method does not require that an active
  107. * connection to an EIS instance should have been established.
  108. *
  109. * @returns ResourceAdapterMetaData instance
  110. * @throws ResourceException Failed to get metadata information
  111. * about the resource adapter
  112. **/
  113. public
  114. ResourceAdapterMetaData getMetaData() throws ResourceException;
  115. }