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

📄 onjava_com j2ee connector architecture.htm

📁 本人收集的关于Java Connector Architecture的资料
💻 HTM
📖 第 1 页 / 共 2 页
字号:
  EJB, and the data structures for the input argument and return type for the 
  interaction, using Attunity Connect Studio. The interaction is named 
  <CODE>STOCKQUOTE</CODE>. Its input argument is defined as a 
  <CODE>MappedRecord</CODE> (as defined in CCI) named <CODE>Record1</CODE>. Its 
  return type is defined as a <CODE>MappedRecord</CODE> named 
  <CODE>STOCKQUOTE_Response</CODE>.</P></LI></UL>
<P>First, define a <CODE>MappedRecord</CODE> called <CODE>Record1</CODE> for a 
new interaction, which contains a single field of type <CODE>String</CODE>. 
<CODE>Record1</CODE> is used as the input record for the interaction, as seen in 
Figure 2.</P>
<P><A href="http://www.onjava.com/onjava/2004/03/24/graphics/figure2.gif" 
target=_new><IMG height=307 alt="Click for larger view" 
src="ONJava_com J2EE Connector Architecture.files/figure2sm.gif" width=450 
border=0></A><BR><I>Figure 2. Defining <CODE>MappedRecord Record1</CODE> using 
Attunity Connect Studio. (You can click on the screenshot to open a full-size 
view.)</I></P>
<P>Next, define the <CODE>STOCKQUOTE_Response MappedRecord</CODE> as the output 
record of the new interaction. The <CODE>Record1</CODE> field within 
<CODE>STOCKQUOTE_Response</CODE> has the same structure as the 
<CODE>Record1</CODE> record defined earlier (see Figure 3.)</P>
<P><A href="http://www.onjava.com/onjava/2004/03/24/graphics/figure3.gif" 
target=_new><IMG height=307 alt="Click for larger view" 
src="ONJava_com J2EE Connector Architecture.files/figure3sm.gif" width=450 
border=0></A><BR><I>Figure 3. Defining the <CODE>STOCKQUOTE_Response 
MappedRecord</CODE>. (You can click on the screenshot to open a full-size 
view.)</I></P>
<P>Then define the new <CODE>STOCKQUOTE</CODE> interaction (see Figure 4.)</P>
<P><A href="http://www.onjava.com/onjava/2004/03/24/graphics/figure4.gif" 
target=_new><IMG height=307 alt="Click for larger view" 
src="ONJava_com J2EE Connector Architecture.files/figure4sm.gif" width=450 
border=0></A><BR><I>Figure 4. Defining the <CODE>STOCKQUOTE</CODE> Interaction. 
(You can click on the screenshot to open a full-size view.)</I></P>
<P>Finally, deploy the Attunity resource adapter into OC4J using OC4J's 
deployment tool, and configure the adapter to communicate with Tuxedo through 
Attunity Connect. Do this by setting properties in the OC4J resource 
adapter-specific <EM>oc4j-ra.xml</EM> configuration file. The following lists 
the properties you must set.</P>
<UL>
  <LI>
  <P><CODE>userName/password</CODE><BR>The username and password of the user who 
  started the Attunity Connect daemon process.</P>
  <LI>
  <P><CODE>eisName</CODE><BR>The name of the adapter as defined during design 
  time (in this example, <CODE>stockquote</CODE>).</P>
  <LI>
  <P><CODE>serverName</CODE><BR>The machine on which the integration server 
  runs.</P></LI></UL>
<P>The following code example outlines the resulting <CODE>oc4j-ra.xml</CODE> 
file. </P><PRE><CODE>&lt;connector-factory location="eis/attunityForTuxedo" 
   connector-name="Attunity Connect Legacy Adapter"&gt;
   &lt;config-property name="userName" 
       value="foo"/&gt;
   &lt;config-property name="password" 
       value="bar"/&gt;
   &lt;config-property name="eisName" 
       value="stockquote"/&gt;
   &lt;config-property name="serverName" 
       value="host1"/&gt;
   &lt;config-property name="workspace" 
       value="stockquoteEvent"/&gt;
   &lt;config-property name="portNumber" 
       value="2552"/&gt;
   &lt;config-property name="persistentConnection" 
       value="true"/&gt;
   &lt;config-property name="keepAlive" 
       value="true"/&gt;
   &lt;config-property name="firewallProtocol" 
       value=""/&gt;
   &lt;config-property name="connectTimeout" 
       value=""/&gt;
   &lt;config-property name="encryptionProtocol" 
       value=""/&gt;
   &lt;config-property name="encryptionKeyName" 
       value=""/&gt;
   &lt;config-property name="encryptionKeyValue" 
       value=""/&gt;
&lt;/connector-factory&gt;</CODE></PRE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <P class=secondary><!-- CS_PAGE_INDEX --></P></TD>
    <TD>
      <P class=secondary align=right><A 
      href="http://www.onjava.com/lpt/a/<!--CS_NEXT_REF-->"></A></P></TD></TR></TBODY></TABLE><!-- CS_PAGE_BREAK -->
<P><!-- CS_PAGE_INDEX --></P>
<H3>3. J2EE Demo Application</H3>
<P>Implement a stateless session bean that uses CCI to obtain connections and 
interact with Tuxedo through the Attunity resource adapter. </P>
<P>See the following code example. </P><PRE><CODE>// Do context lookup for Attunity Connection Factory
Context ic = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) 
    ic.lookup("java:comp/env/eis/attunityForTuxedo");

// Get a connection
Connection con = cf.getConnection();

// Create an interaction
Interaction ix = con.createInteraction();

// Add an interaction spec and set it with
// the Tuxedo service name
AttuInteractionSpec iSpec = new AttuInteractionSpec();
iSpec.setFunctionName("STOCKQUOTE");

// Ask Attunity's record factory to create an 
// input record with the proper format
RecordFactory rf = cf.getRecordFactory();
MappedRecord input = 
    rf.createMappedRecord("Record1");

// Add data, which is the stock quote request, 
// to input record
input.put("Record1_data", "&lt;stock_quote&gt;&lt;symbol&gt;" 
    + symbol + "&lt;/symbol&gt;&lt;/stock_quote&gt;");

// Execute interaction with input record and spec
MappedRecord output = 
    (MappedRecord) ix.execute(iSpec, input);

// Return output for further processing.
return output;</CODE></PRE>
<P>The connection factory, record factory, connection, and interaction classes 
used by the session bean come from the Attunity resource adapter and implement 
interfaces / APIs defined in CCI. The session bean interacts with the resource 
adapter by calling the methods of these classes.</P>
<P>When the session bean invokes the interaction, the Attunity resource adapter 
gathers the function name, <CODE>STOCKQUOTE</CODE>, from the interaction 
specification, and the argument, which is the stock quote request containing the 
stock symbol, from the input record. It then invokes the <CODE>STOCKQUOTE</CODE> 
service on the Tuxedo server with the request. Some resource adapters may invoke 
the Tuxedo service directly. In the case of the Attunity adapter, this call is 
performed through the Attunity Connect Engine. The Attunity resource adapter 
first sends the interaction call to the Attunity Connect Engine, which 
repackages the data into the appropriate Tuxedo format and then invokes the 
Tuxedo service, using Tuxedo's proprietary API.</P>
<P>Once the Attunity Connect Engine receives a response from Tuxedo, it 
reformats it into the return data structure type defined in Attunity Connect 
Studio. It then sends the response back to the EJB through the Attunity resource 
adapter. </P>
<H3>J2EE 1.4 and J2EE CA Version 1.5</H3>
<P>Now that we've introduced you to J2EE CA 1.0, let's discuss J2EE CA 1.5 (see 
<A href="http://www.jcp.org/en/jsr/detail?id=112">JSR-112</A>), which will be 
part of J2EE 1.4.</P>
<P>While J2EE CA 1.0 represents a major step forward for legacy system 
integration for Java and J2EE applications, certain aspects were not addressed 
in this release. Version 1.0 still treats the EIS as a data source to be 
queried, not as an active process that can produce events and initiate calls 
itself. J2EE CA 1.5 extends the capabilities of J2EE CA 1.0 by adding:</P><!--  sidebar begins  -->
<TABLE 
style="BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; MARGIN: 8px; BORDER-LEFT: #333333 1px solid; BORDER-BOTTOM: #333333 1px solid" 
cellSpacing=2 cellPadding=10 width=140 align=right border=1>
  <TBODY>
  <TR>
    <TD 
    style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" 
    vAlign=top width=140 bgColor=#ffffff>
      <P class=headline>Related Reading</P><A 
      href="http://www.oreilly.com/catalog/j2eedp/index.html?CMP=ILL-4GV796923290"><IMG 
      alt="J2EE Design Patterns" 
      src="ONJava_com J2EE Connector Architecture.files/j2eedp.s.gif" 
      border=0></A> 
      <P class=medlist><SPAN class=title><A 
      href="http://www.oreilly.com/catalog/j2eedp/index.html?CMP=ILL-4GV796923290">J2EE 
      Design Patterns</A></SPAN><STRONG><BR>By <A 
      href="http://www.oreillynet.com/cs/catalog/view/au/454?x-t=book.view&amp;CMP=IL7015">William&nbsp;Crawford</A>, 
      <A 
      href="http://www.oreillynet.com/cs/catalog/view/au/1176?x-t=book.view&amp;CMP=IL7015">Jonathan&nbsp;Kaplan</A></STRONG> 
      </P>
      <DIV class=secondary><!--  builds links to list in sidebar  --><A 
      href="http://www.oreilly.com/catalog/j2eedp/toc.html?CMP=ILL-4GV796923290">Table 
      of Contents</A><BR><A 
      href="http://www.oreilly.com/catalog/j2eedp/inx.html?CMP=ILL-4GV796923290">Index</A><BR><A 
      href="http://www.oreilly.com/catalog/j2eedp/chapter/index.html?CMP=ILL-4GV796923290">Sample 
      Chapter</A><BR><BR><B><A href="http://safari.oreilly.com/0596004273">Read 
      Online--Safari</A></B> <SPAN class=tiny>Search this book on Safari:</SPAN> 

      <FORM action=http://safari.oreilly.com/JVXSL.asp method=post><INPUT 
      type=hidden value=1 name=s><INPUT type=hidden value=1 name=b> <INPUT 
      type=hidden value=1 name=t><INPUT type=hidden value=1 name=f> <INPUT 
      type=hidden value=1 name=c><INPUT type=hidden value=1 name=l> <INPUT 
      type=hidden value=section name=view> <INPUT tabIndex=1 size=15 
      name=se_text>&nbsp;<INPUT title="Execute the search" type=image height=17 
      alt=Go width=23 
      src="ONJava_com J2EE Connector Architecture.files/safari_btn_go.gif" 
      align=absMiddle border=0 name=go><BR><SELECT name=se_isbn> <OPTION 
        value=0-596-00427-3 selected>Only This Book</OPTION> <OPTION 
        value="">All of Safari</OPTION></SELECT><BR><INPUT type=checkbox value=1 
      name=code><SPAN class=tiny>Code Fragments only</SPAN> 
  </FORM></DIV></TD></TR></TBODY></TABLE><!--  sidebar ends  -->
<UL>
  <LI>
  <P><EM>Lifecycle management</EM>: A new contract between an application server 
  and a resource adapter lets the application server manage the resource adapter 
  lifecycle (deployment/undeployment, adapter startup/shutdown).</P>
  <LI>
  <P><EM>Work management</EM>: A new contract between an application server and 
  a resource adapter standardizes the management of work between both parties by 
  letting the resource adapter submit work requests to the application server. 
  It also lets the application server control thread management and pooling 
  associated with work requests submitted by the resource adapter. In addition, 
  the new contract lets the adapter create and schedule tasks to be executed 
  within specific transaction contexts. Task scheduling is extremely flexible, 
  allowing for blocking calls as well as asynchronous calls.</P>
  <LI>
  <P><EM>Transaction inflow</EM>: A new contract between an application server 
  and a resource adapter lets the resource adapter propagate transactions 
  initiated by the EIS to the application server. It also allows for Quality of 
  Service, such as crash recovery.</P>
  <LI>
  <P><EM>Message inflow</EM>: A new contract between an application server and a 
  resource adapter supports generic asynchronous message delivery from the EIS 
  to different message endpoints located in the applications server through the 
  resource adapter. In this way, different message providers, such as the Java 
  Message Service (JMS) and Java API for XML Messaging (JAXM), can be plugged 
  into J2EE application servers. This contract allows the EIS to be an active 
  process, generating its own events and messages rather than a passive data 
  source. Resource adapters will be able to leverage this to eliminate mid-tier 
  polling, a traditional but poor use of mid-tier resources.</P></LI></UL>
<P>So, how would our example above benefit from J2EE CA 1.5? Using J2EE CA 1.5 
would strengthen the integration between the J2EE platform and the Attunity 
Tuxedo adapter in the following key areas:</P>
<UL>
  <LI>
  <P>Improved resource usage and quality of service. This is a result of the 
  addition of well-defined lifecycle management and work management 
  contracts.</P>
  <LI>
  <P>Bi-directional integration with legacy systems based on inbound message and 
  transaction inflow capabilities. This lets systems such as Tuxedo send XML 
  messages into the J2EE platform and initiate transactions that will be 
  propagated to the J2EE application server.</P>
  <LI>
  <P>Enhanced performance, failure resilience, and scalability, by introducing 
  asynchronous integration.</P></LI></UL>
<P>After learning about all the new and exciting features provided with J2EE CA 
1.5, you probably can't wait to start experiencing it first hand.</P>
<P>Fortunately, Oracle provides the <A 
href="http://otn.oracle.com/tech/java/oc4j/1003/content_preview.html">OC4J 10g 
(10.0.3) Developer Preview 2</A> that has passed the J2EE 1.4 compatibility test 
suite and is officially J2EE 1.4 compatible.</P>
<H3>Conclusions</H3>
<P>This article discussed the challenges historically associated with legacy 
system integration and introduced the J2EE Connector Architecture as a standard 
way of solving these problems. J2EE CA can significantly help you with any 
legacy system integration. It's available today and will become even more 
powerful in the future through new releases. Start using it today.</P>
<P><I><A href="http://www.onjava.com/pub/au/1768">Anthony Lai</A> is a principal 
member of the Oracle technical staff and a developer in the J2EE Connector 
Architecture area of Oracle Application Server Containers of J2EE. </I></P>
<P><I><A href="http://www.onjava.com/pub/au/1769">Jyotsna Laxminarayanan</A> is 
a principal member of the Oracle technical staff and contributes to the J2EE 
Connector Architecture implementation, which is part of Oracle Application 
Server.</I></P>
<P><I><A href="http://www.onjava.com/pub/au/1770">Lars Ewe</A> is a senior 
principal product manager for Oracle System Management Products. </I></P>
<HR noShade SIZE=1>

<P>Return to <A href="http://www.onjava.com/">ONJava.com</A>.</P>
<P><FONT face=verdana,arial,helvetica size=1>Copyright 

⌨️ 快捷键说明

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