⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connector2.html

📁 j2eePDF格式的电子书
💻 HTML
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>About Resource Adapters</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="Connector.html" />    <link rel="Next" href="Connector3.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="Connector.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="Connector3.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp79707"> </a><h2 class="pHeading1">About Resource Adapters</h2><a name="wp79708"> </a><p class="pBody">A <span style="font-style: italic">resource adapter</span> is a J2EE component that implements the J2EE Connector architecture for a specific EIS. It is through the resource adapter that a J2EE application and an EIS communicate with each other (see <a  href="Connector2.html#wp79727">Figure 28-1</a>).</p><a name="wp79714"> </a><p class="pBody">Stored in a Resource Adapter Archive (RAR) file, a resource adapter may be deployed on any J2EE server, much like the EAR file of a J2EE application. A RAR file may be contained in an EAR file or it may exist as a separate file.</p><a name="wp79715"> </a><p class="pBody">A resource adapter is analogous to a JDBC driver. Both provide a standard API through which an application can access a resource that is outside the J2EE server. For a resource adapter, the outside resource is an EIS; for a JDBC driver, it is a DBMS. Resource adapters and JDBC drivers are rarely created by application developers. In most cases, both types of software are built by vendors who sell products such as tools, servers, or integration software.</p><a name="wp79716"> </a><h3 class="pHeading2">Resource Adapter Contracts</h3><a name="wp79720"> </a><p class="pBody"><a  href="Connector2.html#wp79727">Figure 28-1</a> shows the application and system contracts, the two principal contracts implemented by a resource adapter. The application contract defines the API through which a J2EE component such as an enterprise bean accesses the EIS. This API is the only view that the component has of the EIS. The resource adapter itself and its system contracts are transparent to the J2EE component.</p><a name="wp79721"> </a><p class="pBody">The system contracts link the resource adapter to important services--connection, transaction, and security--that are managed by the J2EE server.</p><a name="wp79725"> </a><p class="pBody"></p><div align="left"><img src="images/Fig36.gif" height="328" width="446" alt="Accessing an EIS through a Resource Adapter" border="0" hspace="0" vspace="0"/></div><p class="pBody"></p><p>  <a name="79727"> </a><strong><font >Figure 28-1   Accessing an EIS Through a Resource Adapter</font></strong></p><a name="wp79728"> </a><p class="pBody">The connection management contract supports connection pooling, a technique that enhances application performance and scalability. Connection pooling is transparent to the application, which simply obtains a connection to the EIS.</p><a name="wp79730"> </a><p class="pBody">Because of the transaction management contract, a call to the EIS may be enclosed in an XA transaction. XA transactions are global--they may contain calls to multiple EISs, databases, and enterprise bean business methods. Although often appropriate, XA transactions are not mandatory. Instead, an application may use local transactions, which are managed by the individual EIS, or it may use no transactions at all.</p><a name="wp79732"> </a><p class="pBody">To protect the information in an EIS, the security management contract provides these mechanisms: authentication, authorization, and secure communication between the J2EE server and the EIS.</p><a name="wp80443"> </a><h3 class="pHeading2">Connector 1.5 Resource Adapters </h3><a name="wp80444"> </a><p class="pBody">With the latest release of the Connector architecture (Connector 1.5), EISs and external systems can supply resource adapters for connecting from an EIS to a J2EE application server. The architecture specifies additional contracts, including a lifecycle management contract, a work management contract, and pluggability contracts for message providers and for importing transactions. By following the specification, a resource adapter provider has the flexibility to implement those services that it desires or needs. </p><a name="wp80523"> </a><h4 class="pHeading3">Extending Messaging Capabilities</h4><a name="wp80522"> </a><p class="pBody">To enable external systems to connect to a J2EE application server, the Connector architecture has extended the capabilities of message-driven beans to handle messages from any message provider. That is, message-driven beans are no longer limited to handling JMS messages. Instead, EISs and message providers can plug any message provider, including their own custom or proprietary message providers, into a J2EE container. </p><a name="wp80724"> </a><p class="pBody">To use this feature, a message provider or an EIS provides a resource adapter according to the Connector 1.5-specified contract. The contract details APIs for message handling and message delivery. A conforming resource adapter is assured of the ability to send messages from any provider to a message-driven bean, plus it can be plugged into a J2EE container in a standard manner.</p><a name="wp80569"> </a><h4 class="pHeading3">Work Management Contract</h4><a name="wp80570"> </a><p class="pBody">The Connector 1.5 work management contract ensures that resource adapters use threads in the proper, recommended manner. It also enables the J2EE application server to manage threads for resource adapters. </p><a name="wp80571"> </a><p class="pBody">Resource adapters that improperly use threads can create problems for the entire application server environment. For example, a resource adapter might create too many threads or it might not properly release threads it has created. Poor thread handling inhibits application server shutdown. It also impacts the application server's performance because creating and destroying threads are expensive operations.</p><a name="wp80742"> </a><p class="pBody">The work management contract establishes a means for the application server to pool and reuse threads, similar to pooling and reusing connections. By adhering to this contract, the resource adapter does not have to manage threads itself. Instead, the resource adapter has the application server create and provide needed threads. When the resource adapter is finished with a given thread, it returns the thread to the application server. The application server manages the thread: it can return the thread to a pool and reuse it later, or it may destroy the thread. Handling threads in this manner results in increased application server performance and more efficient use of resources.</p><a name="wp80573"> </a><p class="pBody">In addition to moving thread management to the application server, the Connector 1.5 architecture also provides a flexible model for a resource adapter that uses threads: </p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp80574"> </a><div class="pSmartList1"><li>The requesting thread can choose to block--stop its own execution--until the work thread completes. </li></div><a name="wp80575"> </a><div class="pSmartList1"><li>Or, the requesting thread can block while it waits to get the thread. When the application server provides a work thread, then the requesting thread and the work thread execute in parallel. </li></div><a name="wp80576"> </a><div class="pSmartList1"><li>The resource adapter can opt to submit the work for the thread to a queue. The thread executes the work from the queue at some later point. The resource adapter continues its own execution from the point it submitted the work to the queue, regardless of when the thread executes it. </li></div></ul></div><a name="wp80577"> </a><p class="pBody">With the latter two approaches, the resource adapter and the thread may execute simultaneously or independently from each other. For these approaches, the contract specifies a listener mechanism to notify the resource adapter that the thread has completed its operation. The resource adapter can also specify the execution context for the thread and the work management contract controls the context in which the thread executes. </p><a name="wp80579"> </a><h4 class="pHeading3">Transaction Inflow</h4><a name="wp80580"> </a><p class="pBody">The Connector 1.5 architecture also expands the transaction support for resource adapters. Previously, transaction flow went from the J2EE application server to an EIS. That is, the transaction started from an enterprise bean on the J2EE application server, and the same transaction remained in force during operations on the EIS.</p><a name="wp80581"> </a><p class="pBody">Now, transactions can be imported from an EIS to the J2EE application server. The architecture specifies how to propagate the transaction context from the EIS. For example, a transaction can be started by the EIS, such as a CICs system. Within the same CICs transaction, a connection can be made through a resource adapter to an enterprise bean on the application server. The enterprise bean does its work under the CICs transaction context and commits within that transaction context. </p><a name="wp80671"> </a><p class="pBody">The Connector 1.5 architecture also specifies how the container participates in transaction completion and how it handles crash recovery to ensure that data integrity is not lost.</p><a name="wp80785"> </a><h4 class="pHeading3">Lifecycle Management</h4><a name="wp80789"> </a><p class="pBody">The Connector 1.5 architecture specifies a lifecycle management contract that allows an application server to manage the lifecycle of a resource adapter. This contract provides a mechanism for the application server to bootstrap a resource adapter instance during the instance's deployment or application server startup. It also provides a means for the application server to notify the resource adapter instance when it is undeployed or when an orderly shutdown of the application server takes place.</p>    </blockquote>   <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="Connector.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="Connector3.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -