SCEA Ch06 - Legacy Connectivity
在JCA還沒出現以前,各種不同平台實作的資訊系統若要在java中彼此互相傳遞資訊,透過的是JNI, RMI, CORBA( Common Object Request Broker) 等機制進行,像是可以藉此溝通c/c++ 之類的native method call。
截至目前為止( thus far),最經典的企業級資訊系統(EIS),當屬已client/server 架構,這種架構中,最知名的是透過提供程式介面呼叫(API),將實際的程式功能黑箱封裝起來,而前端的程式則透過此設計的API進行對後台資料的存取,這在前年我接觸到的死裡逃生的一個小型系統(NxA- 擴大xxx)就是這樣的東西(有夠難維護)。
像這樣的架構其實可以發現到一件事情,對於整個EIS的溝通,基本上就是透過提供的adapter 介面來做呼叫,中間可透過一些自訂特殊的protocol,提供支援交易及安全性保護,事實上大多數的api在設計時都會隱藏大量細節避免暴露於呼叫層面。
- Using a Simple EIS Java Adapter
最著名的就是JNI拉~~
早期的簡單作法當中,就是透過JNI來呼叫其他非以java實作的平台的程式,而EIS adapter 有可能是以C開發的。
[caption id="attachment_291" align="alignnone" width="512" caption="Java JNI application"]
[/caption]
[caption id="attachment_293" align="alignnone" width="583" caption="JCA"]
[/caption]
Deployable JCA 元件又稱之為「資源界接器-resource adapter」,
- System Contract
- JCA Contract
Life Cycle Management Contract The application server manages the
startup and shutdown of the resource adapter.
■ Work Management Contract Allows the resource adapter to do work by
submitting it to an application server for execution. Since the application
server does the work for the resource adapter, the resource adapter needn’t
worry about thread management. Instead, the application server manages this
aspect efficiently and can use thread pooling if necessary.
■ Transaction Inflow Contract This allows a resource adapter to propagate
an imported transaction to an application server, as well as flow-in transaction
completion and failure recovery initiated by an EIS.
■ Message Inflow Contract This allows the resource adapter to synchronously
or asynchronously deliver messages to end points in the application server,
irrespective of message style, semantics, and infrastructure. 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.
1. Resource Adapter
2. Data Mapping
3. Messaging brokers
一般來說大部分的EAI實做廠商都可支援同步與非同步的溝通模式
- Resource adapter and System Contract
To use JCA in a JEE container, you must have a JCA resource adapter, which
resembles a JDBC driver. A JCA adapter is specific to an EIS (for example, Tibco)
and is contained in a Resource Adapter Archive (RAR) file composed of the JAR
files and native libraries necessary to deploy the resource adapter on a JEE container.
A JCA adapter interacts with a JEE server via system contracts. They enable the JEE
server to propagate the context in which a JCA adapter is being called.
There are seven types of system contracts (three existed in JCA 1.0):
■ Connection management
■ Transaction management
■ Security
■ Life Cycle Management (JCA 1.5)
■ Work Management Contracts (JCA 1.5)
■ Message Inflow (JCA 1.5)
■ Transaction Inflow Contracts (JCA 1.5)
JCA resource adapters must supply two implementations with the adapter.
First, a ConnectionFactory provides a vehicle for creating connections. Second, the
Connection class represents this particular resource adapter's underlying connection.
Life Cycle Management Contracts The ResourceAdapter interface in the
javax.resource.spi package represents a resource adapter. There are two methods in
the ResourceAdapter interface that allow for life cycle management: start() and
stop(). The start() method is called when an application server wants to start a
resource adapter (for example, to deploy it). The stop() method is called when the
application server wants to release a resource adapter (for example, to undeploy it).
Work Management Contracts The Work Management contract allows the
resource adapter to submit work to the application server. It does this by creating an
object that extends the Work interface in the javax.resource.spi.work package. The
Work interface is an extension of the Runnable interface. In addition to the run()
method that it inherits from Runnable and which executes in its own thread, the
Work interface contains a release() method.
沒有留言:
張貼留言