openadaptor 3.2白皮书
什么是openadaptor?
Openadaptor 是一款用于企业应用集成(Enterprise Application Integration)的Java软件工具。Openadaptor用来帮助大型金融组织用MOM(Message Oriented Middleware)集成其应用.这款工具提供了框架和组件,用于构建多系统和各种各样的中间件解决方案间的连接,我们可以称之为适配器。
Openadaptor提供了用于连接多种系统(transports)的软件组件(例如:JMS, Tibco, RDBMS, SOAP, HTTP, SMTP, Files)。它提供多种组件来处理不同的数据形式(representation)(例如:XML, JDBC result sets, fixed width and delimited string records),但并不绑定到任何具体的数据形式。
框架包括了对事物(本地或Java事务API(JTA))的支持,有捕获和管理process中的异常的能力,远程管理(JMX or HTPP)的能力。各种组件可以快速的连接,能让开发者非常迅速的交付高质量的产品适配器。
框架的设计尽可能的轻量级,除了JRE不需要依赖其他的基础结构。框架可以用来独立运行适配器,可以嵌入到其他软件或发布到应用容器中。组件可以单独使用,也可以与框架共同使用,编写自定义组件不需要对框架有更广泛的了解。
所有的openadaptor组件都是Java Bean,可以与spring框架(http://www.springframework.org)共同使用,这就意味着适配器(运行)进程 (adaptor processes)可以使用XML配置文件开进行开发,而不需要编写和编译Java代码。
给出一个实例
Openadaptor的应用范围非常广泛,它可以将多个企业系统连接到核心中间件解决方案;也可以将不同的系统直接相连;它也可以只作为简单的文件转换工具来使用。它的灵活性体现在它可以应用在技术多样的大型企业当中。
例如,你需要为一些事件(event)调查(poll)一个应用数据库,导出与这些事件关联的数据,将这些数据转换为XML文档,然后发布到JMS。 Openadaptor提供的组件可以实现这些需求,这个简单的适配器可以通过配置组件并将它们连接成一个简单的"管道线(Pipeline)"。
所有这些都可以通过一个短小的XML配置文件完成,我们提供了一套标准程序将配置作为一个独立的进程运行。你也可以使用几行Java代码来连接组件,或将 XML配置文件嵌入到任何使用spring框架的process。
Functionality can be added to the adaptor by inserting additional components in the “pipeline”. For instance you may want to filter out certain data, transform it into your company’s enterprise business model and perhaps validate it before publishing it.
The adaptor can easily be system tested, by swapping out the transport specific connectors with file based connectors. When the components are used with the framework you automatically receive the benefits of the framework, for example standardized process management and remote administration.
设计思想
以下是openadaptor的3个基础组件:
Read Connector
These connect to an external resource and receive / poll data
Processor
These operate on data, either by transforming it in someway or discarding it
Write Connector
These connect to an external resource and send / publish data.
每个适配器至少包含一个read connector和一个write
connector,包含0个或多个processor。它们被连接成一个"管道线",管道线间传递的数据是一个POJO数组。
对于简单的适配器,开发人员只需要处理Connectors,Processors和它们之间如何关联。标准框架适配器和管道线组件会将Connectors和Processors自动封装成合适的适配器框架组件。
本节的其余部分提供了有关适配器框架的更多细节。
Within the adaptor framework the Connectors and Processors are wrapped inside Node components. These provide the lifecycle management, exception capture, transaction management and data batching capabilities of openadaptor. There are specific subclasses of Node for the different fundamental components.
…封装…
Read Node
Read Connector (and optionally a
Processor)
Processor Node
Processor
Write Node
Write Connector (and
optionally a Processor)
Where as the fundamental components
(Connectors and processors) are data agnostic, the adaptor components expect to
receive data wrapped in a Message object and respond with a Response object.
These are used to propagate context information such as the transaction and the
actual data, discarded data and processing exceptions.
Nodes are
typically managed by an Adaptor component. This co-ordinates the lifecycle and
allows Adaptor Read Nodes to initiate the processing of messages. The following
diagram illustrates a typical adaptor configuration.
A Pipeline /
Router is a component that “knows” how the Nodes are chained together. A
Pipeline is actually a simple case of a Router. It can be used when the linkage
between the adaptor components is a non-branching chain and there are no complex
exception capture and routing requirements. The advantage of using a Pipeline is
that it requires less code (or configuration if you are using the spring
framework) to assemble. The Router allows more sophisticated routing and
exception management.
The Adaptor delegates the message routing to a
Pipeline or Router. But it is worth noting that all the adaptor components (Node
subclasses, Adaptor, Router and Pipeline) actually implement the same interface
(IMessageProcessor). So it is perfectly legitimate to couple Nodes together
directly or for an Adaptor to delegate directly to a Node. You are also free to
develop complimentary frameworks which use Nodes, Connectors, Processors,
Routers and Pipelines.
核心接口和类
The components described in the previous section are illustrated in the following class diagram.
分发包结构与代码结构
openadaptor分发包包含jar文件,示例代码和文档。
openadaptor.jar The
openadaptor code
openadaptor-depends.jar The single jar of the core
third-party code upon which the openadaptor code depends
openadaptor-spring.jar The openadaptor code that is complimentary to the
spring framework
The example code area contains readme files that describe
how to correctly setup the java classpath.
The package structure of
openadaptor is split as follows:
org.openadaptor.core Contains core interfaces and implementations
org.openadaptor.auxil Contains connectors and processors that rely on the core java and javax packages.
Processors that convert between data representations are referred to as convertors.
org.openadaptor.thirdparty Contains connectors and processors that rely on third-party software
org.openadaptor.spring Contains components that directly use the spring framework
Why the re-write?
Openadaptor was originally developed in 1997, this predated the popularity of XML and integral to openadaptor was a canonical data representation called DataObjects. DataObjects have long been regarded as non-strategic.
Certain standards and technologies have evolved that we wish to accommodate.
Using components of openadaptor outside the adaptor paradigm is difficult as is extending it to provide more sophisticated functionality such as workflow.
Like allot of software that has been incrementally developed, some of the design and implementation was sub-optimal but retained because we didn’t want to break interfaces. The latest version of the openadaptor.jar is 400K compared to the previous release which was over 2Mb, this reflects how we have attempted to “boil down” openadaptor to what we feel is original and worthwhile.