ConnectionFactory (Java EE 5)

Java EE API


javax.resource.cci Interface ConnectionFactory

All Superinterfaces:
Referenceable, Serializable

public interface ConnectionFactory
extends Serializable, Referenceable

Implements: java.io.Serializable, Referenceable

ConnectionFactory 提供一个接口,用于获取对 EIS 实例的连接。ConnectionFactory 接口的实现由资源适配器提供。

应用程序代码从 JNDI 名称空间中查找 ConnectionFactory 实例,并使用该实例获取 EIS 连接。

需要使用 ConnectionFactory 的实现类来实现 java.io.Serializablejavax.resource.Referenceable 接口,以支持 JNDI 注册。

英文文档:

ConnectionFactory provides an interface for getting connection to an EIS instance. An implementation of ConnectionFactory interface is provided by a resource adapter.

Application code looks up a ConnectionFactory instance from JNDI namespace and uses it to get EIS connections.

An implementation class for ConnectionFactory is required to implement java.io.Serializable and javax.resource.Referenceableinterfaces to support JNDI registration.

Version:
0.8
Author:
Rahul Sharma
See Also:
Connection, Referenceable

Method Summary
 Connection
 Connection
 ResourceAdapterMetaData
 RecordFactory
 
Methods inherited from interface javax.resource.Referenceable
 
Methods inherited from interface javax.naming.Referenceable
 

Method Detail

public Connection getConnection() throws ResourceException
获取对 EIS 实例的连接。当组件希望容器管理 EIS 登录时,应该使用此 getConnection 变体。这种情况称为容器管理的登录。该组件不传递任何安全信息。
return Connection 实例
ThrowsResourceException: 无法获取对 EIS 实例的连接。错误情况的示例有:
  • 无效的 ManagedConnectionFactory 配置—示例:无效的服务器名称
  • 应用服务器内部错误—示例:与连接池有关的错误
  • 通信错误
  • 特定于 EIS 的错误—示例:EIS 未激活
  • 资源适配器内部错误
  • 与安全相关的错误;示例:无效用户
  • 无法分配系统资源
英文文档:

getConnection

Connection getConnection()
                         throws ResourceException
Gets a connection to an EIS instance. This getConnection variant should be used when a component wants the container to manage EIS sign-on. This case is termed container-managed sign-on. The component does not pass any security information.

Returns:
Connection instance
Throws:
ResourceException - Failed to get a connection to the EIS instance. Examples of error cases are:
  • Invalid configuration of ManagedConnectionFactory-- example: invalid server name
  • Application server-internal error--example: connection pool related error
  • Communication error
  • EIS-specific error--example: EIS not active
  • Resource adapter-internal error
  • Security related error; example: invalid user
  • Failure to allocate system resources

public Connection getConnection(ConnectionSpec properties) throws ResourceException
获取对 EIS 实例的连接。如果组件需要传递任何特定于资源适配器的安全信息和连接参数,则应该使用带 javax.resource.cci.ConnectionSpec 参数的 getConnection 变体。在组件管理的登录情况下,应用程序组件通过 ConnectionSpec 实例传递安全信息(例如:用户名、密码)。

记住,传递给 getConnection 方法的属性应该特定于客户端(例如:用户名、密码、语言),与目标 EIS 实例的配置(例如:端口号、服务器名称)无关,这一点非常重要。使用创建对 EIS 实例的连接所需的完整属性集配置 ManagedConnectionFactory 实例。

properties 指定为 ConnectionSpec 实例的 Connection 参数和安全信息
return Connection 实例
ThrowsResourceException: 无法获取对 EIS 实例的连接。错误情况的示例有:
  • 无效的输入参数规范
  • 无效的 ManagedConnectionFactory 配置—示例:无效的服务器名称
  • 应用服务器内部错误—示例:与连接池有关的错误
  • 通信错误
  • 特定于 EIS 的错误—示例:EIS 未激活
  • 资源适配器内部错误
  • 与安全相关的错误;示例:无效用户
  • 无法分配系统资源
See also javax.resource.cci.ConnectionSpec

英文文档:

getConnection

Connection getConnection(ConnectionSpec properties)
                         throws ResourceException
Gets a connection to an EIS instance. A component should use the getConnection variant with javax.resource.cci.ConnectionSpec parameter, if it needs to pass any resource adapter specific security information and connection parameters. In the component- managed sign-on case, an application component passes security information (example: username, password) through the ConnectionSpec instance.

It is important to note that the properties passed through the getConnection method should be client-specific (example: username, password, language) and not related to the configuration of a target EIS instance (example: port number, server name). The ManagedConnectionFactory instance is configured with complete set of properties required for the creation of a connection to an EIS instance.

Parameters:
properties - Connection parameters and security information specified as ConnectionSpec instance
Returns:
Connection instance
Throws:
ResourceException - Failed to get a connection to the EIS instance. Examples of error cases are:
  • Invalid specification of input parameters
  • Invalid configuration of ManagedConnectionFactory-- example: invalid server name
  • Application server-internal error--example: connection pool related error
  • Communication error
  • EIS-specific error--example: EIS not active
  • Resource adapter-internal error
  • Security related error; example: invalid user
  • Failure to allocate system resources
See Also:
ConnectionSpec

public RecordFactory getRecordFactory() throws ResourceException
获取 RecordFactory 实例。RecordFactory 用于创建一般 Record 实例。
return RecordFactory RecordFactory 实例
ThrowsResourceException: 无法创建 RecordFactory
ThrowsNotSupportedException: 不支持该操作
英文文档:

getRecordFactory

RecordFactory getRecordFactory()
                               throws ResourceException
Gets a RecordFactory instance. The RecordFactory is used for the creation of generic Record instances.

Returns:
RecordFactory RecordFactory instance
Throws:
ResourceException - Failed to create a RecordFactory
NotSupportedException - Operation not supported

public ResourceAdapterMetaData getMetaData() throws ResourceException
获取资源适配器的元数据。注意,该元数据信息是关于 ResourceAdapter 的,不是关于 EIS 实例的。调用此方法不要求建立对 EIS 实例的活动连接。
return ResourceAdapterMetaData 实例
ThrowsResourceException: 无法获取有关资源适配器的元数据信息
英文文档:

getMetaData

ResourceAdapterMetaData getMetaData()
                                    throws ResourceException
Gets metadata for the Resource Adapter. Note that the metadata information is about the ResourceAdapter and not the EIS instance. An invocation of this method does not require that an active connection to an EIS instance should have been established.

Returns:
ResourceAdapterMetaData instance
Throws:
ResourceException - Failed to get metadata information about the resource adapter


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!