📄 onjava_com j2ee connector architecture.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0032)http://www.onjava.com/lpt/a/4645 -->
<HTML><HEAD><TITLE>ONJava.com: J2EE Connector Architecture</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<SCRIPT language=javascript
src="ONJava_com J2EE Connector Architecture.files/common.js"></SCRIPT>
<META content=NOARCHIVE name=GOOGLEBOT>
<META content="NOINDEX, NOFOLLOW" name=ROBOTS>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff><A href="http://www.onjava.com/"><IMG
height=82 alt=ONJava.com
src="ONJava_com J2EE Connector Architecture.files/onjava_logo.jpg" width=294
align=left border=0></A> <DUMMY> </DUMMY> <BR
clear=all> <FONT face=verdana,arial,helvetica size=1>Published on <B><A
href="http://www.onjava.com/">ONJava.com</A></B> (<A
href="http://www.onjava.com/">http://www.onjava.com/</A>)<BR><!-- ---------- End of PERL --------------------- --> http://www.onjava.com/pub/a/onjava/2004/03/24/j2eeca.html<BR> <A
href="http://www.onjava.com/pub/a/general/print_code.html">See this</A> if
you're having trouble printing code examples</FONT><BR><BR clear=all><!-- CS_PAGE_BREAK -->
<H2>J2EE Connector Architecture</H2>by <A
href="http://www.onjava.com/pub/au/1768">Anthony Lai</A>, <A
href="http://www.onjava.com/pub/au/1769">Jyotsna Laxminarayanan</A> and <A
href="http://www.onjava.com/pub/au/1770">Lars Ewe</A><BR>03/24/2004 <!-- sidebar begins --><!-- don't move sidebars --><!-- sidebar ends -->
<P>Have you ever found yourself in a position where you had to integrate legacy
data, data sources, or functionality with your new application? If so, rest
assured that you are in good company. Many development organizations find
themselves in the same situation.</P>
<P>This article discusses some of the challenges of legacy system integration,
then introduces the <A href="http://java.sun.com/j2ee/connector/index.jsp">J2EE
Connector Architecture</A> (J2EE CA) and explains how it can significantly
reduce the problems of integrating your legacy system. It also offers a
comprehensive example of how to use the current version of J2EE CA, version 1.0,
to access a common transaction-processing platform from a <A
href="http://java.sun.com/j2ee/">Java 2 Enterprise Edition (J2EE) platform</A>
application. This article concludes with an overview of the upcoming new release
of J2EE CA, version 1.5, and explains some of the additional features and
benefits introduced in this new version. This article assumes that you have a
working knowledge of Java and J2EE.</P>
<H3>Introduction</H3>
<P>If you've ever had to integrate legacy data, data sources, or functionality
with a new application, you've no doubt faced a number of challenges: for
instance, figuring out how to connect to legacy systems, manage connections, and
convert different data types between the systems. Most likely, you either
implemented your own mechanisms to address these issues -- that is, if you had
the time and knowledge -- or you licensed proprietary third-party technology to
do so. And chances are, the final solutions cost a significant amount of time
and money -- and most of it was spent solving the underlying infrastructure
challenges, not the real business problem at hand.</P>
<P>Without an easy standards-based solution, you didn't have much of a
choice.</P>
<P>Fortunately, J2EE Connector Architecture (J2EE CA) has changed this. J2EE CA
is a standards-based mechanism of accessing legacy systems from Java / J2EE
applications that significantly reduces the challenges of legacy system
integration.</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/hardcorejv/index.html?CMP=ILL-4GV796923290"><IMG
alt="Hardcore Java"
src="ONJava_com J2EE Connector Architecture.files/hardcorejv.s.gif"
border=0></A>
<P class=medlist><SPAN class=title><A
href="http://www.oreilly.com/catalog/hardcorejv/index.html?CMP=ILL-4GV796923290">Hardcore
Java</A></SPAN><STRONG><BR>By <A
href="http://www.oreillynet.com/cs/catalog/view/au/1756?x-t=book.view&CMP=IL7015">Robert Simmons,
Jr.</A></STRONG> </P>
<DIV class=secondary><!-- builds links to list in sidebar --><A
href="http://www.oreilly.com/catalog/hardcorejv/toc.html?CMP=ILL-4GV796923290">Table
of Contents</A><BR><A
href="http://www.oreilly.com/catalog/hardcorejv/inx.html?CMP=ILL-4GV796923290">Index</A><BR><A
href="http://www.oreilly.com/catalog/hardcorejv/chapter/index.html?CMP=ILL-4GV796923290">Sample
Chapter</A><BR><BR><B><A href="http://safari.oreilly.com/0596005687">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> <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-00568-7 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 -->
<P>J2EE CA is best explained with a simple analogy. Most developers are familiar
with the Java Database Connectivity (JDBC) API, which lets Java programs access
relational databases in an easy, standardized way. Before JDBC came along, it
was much more difficult for programs to access and interact with databases.</P>
<P>Programs used data source-specific mechanisms and features, as well as
different data conversions, so unless you had specialized domain expertise, you
were faced with substantial project delays, project quality issues, database
implementation lock-in, and other problems.</P>
<P>J2EE CA is to legacy data and application integration as JDBC is to database
interaction. It provides a standardized, easy-to-use, legacy system-independent
way to communicate with the different backend systems that your project must
integrate with. By doing so, it lets you reuse technology as well as domain
expertise. J2EE CA is more generic in its approach than JDBC, however, providing
connectivity to a broader spectrum of backend systems. JDBC assumes that data
will be of a relational nature; J2EE CA does not.</P>
<P>Once JDBC was introduced, did you ever consider not using it, or JDBC-based
technologies (such as TopLink), to access different data sources from Java or
J2EE applications? Probably not. We're convinced the same will be true for J2EE
CA. Once you learn how to use it and you start enjoying its benefits, you won't
want to use any other method to integrate applications with legacy systems.</P>
<P>Let's take a look at J2EE CA 1.0, its functionality, and an overview of its
high-level architecture.</P>
<P>At the heart of J2EE CA 1.0 are several standardized contracts and interfaces
between different parties. The parties are the backend enterprise information
system (EIS), the different application components, the application server, and
the resource adapter. Let's look at each one:</P>
<UL>
<LI>
<P><EM>EIS</EM>: This is the backend legacy system that the application
components must integrate with.</P>
<LI>
<P><EM>Application components</EM>: These are Java or J2EE application
components (for example, Enterprise JavaBeans) that must integrate with the
EIS.</P>
<LI>
<P><EM>Application server</EM>: The application server (for instance, Oracle
Application Server 10g) provides the runtime environment (container) in which
the application components and the resource adapter execute. It also furnishes
system-level services such as connection, transaction, and security
management.</P>
<LI>
<P><EM>Resource adapter</EM>: This connects application components with the
EIS by implementing system-level services specific to the EIS, thereby
shielding the application components from the EIS-specific system-level
services. It plugs into the application server by using standardized system
contracts.</P></LI></UL>
<P>The standardized contracts and interfaces between the different parties are
the container-component contracts, the system contracts, and the optional common
client interface (CCI). The resource adapter uses EIS-specific contracts to
communicate with the EIS. Here's some more information on the different
contracts and interfaces.</P>
<UL>
<LI>
<P>Container-component contract: J2EE component contracts standardize the
interaction between the application components and the application server. For
example, in the case of EJBs, the contract is the Enterprise JavaBeans
specification and its different guarantees and interfaces between the EJB
container and the hosted EJBs running inside the container. Transactional
attributes, security attributes, other common J2EE component attributes,
interfaces, and services are well integrated with the J2EE CA system contracts
(mentioned below). This is because J2EE CA functions as a bridge between the
resource adapter and the remainder of the J2EE application server, its
services, containers, and any components running in those containers.</P>
<LI>
<P>System contracts: J2EE CA contracts between the application server and the
resource adapter to standardize things such as security management and
transaction management.</P>
<LI>
<P>CCI: This J2EE CA client interface standardizes the interaction API between
the application components and the resource adapter. Although CCI is a great
feature, it's optional, so not all J2EE CA-compliant resource adapters provide
one. Some resource adapter providers offer EIS-specific client interaction
interfaces instead.</P></LI></UL>
<P>By defining the above contracts and interfaces J2EE CA helps developers, as
well as resource adapter providers.</P>
<P>It offers developers standardized ways to connect to the EIS, managing
security credentials and transactional boundaries. For most resource adapters,
developers can also use the CCI to interact with the EIS. To revisit the JDBC
analogy, CCI offers a standardized interaction interface to the EIS, similar to
what's provided to database developers with ANSI SQL.</P>
<P>Resource adapter providers can write adapters that can be deployed and used
across different J2EE application servers. They can rely on a set of system
contracts that lets them implement adapters that are tightly integrated with
application server functionality, such as security and transaction management,
without having to implement any application server vendor-specific
interfaces.</P>
<H3>J2EE CA 1.0 in Action</H3>
<P>After all this theory, let's take a look at a real-life example. Let's see
how you can leverage J2EE CA 1.0 to connect a simple Enterprise JavaBean to a
common transaction-processing platform, in this case BEA Tuxedo.</P>
<P>Our example uses a J2EE application that runs on Oracle Containers for J2EE
(OC4J) 9.0.4 -- a J2EE-compliant application server with full support for J2EE
Connector Architecture 1.0 -- and interacts with BEA Tuxedo 8.1 transaction
server. The example also uses Attunity Connect 4.x, which provides standard
integration between resource adapters and enterprise data sources, as well as
legacy applications. The solution includes a resource adapter deployed in OC4J,
and the Attunity Connect Engine configured on the target system. Attunity
Connect can be used to access a wide variety of systems, including CICS, IMS,
VSAM, Adabas, Tuxedo, RMS, and Enscribe. </P>
<P>To follow along with this article, please download the example files in <A
href="http://www.onjava.com/onjava/2004/03/24/examples/oc4j-jca-tux.zip">oc4j-jca-tux.zip</A>.
Figure 1 shows the architecture of the sample application.</P>
<P><IMG height=346 alt="Figure 1"
src="ONJava_com J2EE Connector Architecture.files/figure1.gif"
width=550><BR><I>Figure 1. Architecture of the stockquote sample
application.</I></P>
<P>Here are the high-level steps necessary to reproduce the example:</P>
<OL>
<LI>Set up and configure the backend EIS (in this case, Tuxedo).
<LI>Set up and configure the J2EE CA resource adapter and deploy it to the
J2EE application server (in this case, Attunity's J2EE CA Tuxedo adapter).
<LI>Implement and deploy the J2EE application that interacts with the EIS by
using the J2EE CA resource adapter. </LI></OL>
<P>Let's take a closer look at these steps:</P>
<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>1. Tuxedo</H3>
<P>Set up Tuxedo 8.1 on a Solaris system, and start the stock quote example
(under the <CODE>samples/atmi/xmlstockquote</CODE> directory of the Tuxedo
installation). The instructions are included in the same directory. Then,
configure the Tuxedo Work Station Listener to listen on port <CODE>8090</CODE>.
</P>
<P>Here's an outline of the relevant part of the <CODE>ubbconfig</CODE>
configuration file.</P><PRE><CODE>*SERVERS
"stockxml" SRVGRP="GROUP1" SRVID=30
CLOPT="-A -p 1,5:2,5 -o stock.out
-e stock.err -r"
RQADDR="stockxml"
RQPERM=0666 REPLYQ=Y RPPERM=0666
MIN=1 MAX=5 CONV=N
SYSTEM_ACCESS=FASTPATH
MAXGEN=1 GRACE=86400 RESTART=N
MINDISPATCHTHREADS=0 MAXDISPATCHTHREADS=1
THREADSTACKSIZE=0
"WSL" SRVGRP="GROUP2" SRVID=20
CLOPT="-A -- -n //host1:8090"
RQPERM=0660 REPLYQ=Y RPPERM=0660
MIN=1 MAX=1 CONV=N
SYSTEM_ACCESS=FASTPATH
MAXGEN=5 GRACE=86400 RESTART=Y
MINDISPATCHTHREADS=0 MAXDISPATCHTHREADS=1
THREADSTACKSIZE=0
SICACHEENTRIESMAX="500"
*SERVICES
"STOCKQUOTE"
LOAD=50 PRIO=50
BUFTYPE="ALL"
TRANTIME=30
AUTOTRAN=N</CODE></PRE>
<H3>2. Attunity Tuxedo J2EE CA Resource Adapter</H3>
<P>The Attunity Connect solution consists of a J2EE CA resource adapter, an
integration engine (Attunity Connect Engine), and a design time environment
(Attunity Connect Studio). To set up the adapter, follow these steps:</P>
<UL>
<LI>
<P>Configure the integration engine to communicate with the Tuxedo
installation by modifying the <CODE>nav_login</CODE> script. In this example,
the <CODE>WSNADDR</CODE> is set to point to: <CODE>//localhost:8090</CODE></P>
<LI>
<P>Define the interaction for invoking the stock quote Tuxedo service from the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -