[读书笔记]INTRODUCING SCA摘记

本文深入探讨了Service Component Architecture (SCA)的基本概念,包括组件与复合体的定义及配置方式。介绍了如何通过Service Component Definition Language (SCDL)进行配置,并详细解释了服务、引用、属性和绑定等核心概念。同时,还提供了Java组件模型下的具体实施案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

作者:DAVID CHAPPELL

SCA FUNDAMENTALS

COMPONENTS AND COMPOSITES(由component组成)

There must be a way to define components and to describe how they interact.

an SCA application can be accessed by software from the non-SCA world(如Servlet,JSP Service Data Objects)

An SCA composite is typically described in an associated configuration file

This file uses an XML-based format called the Service Component Definition Language (SCDL)

DOMAINS

an SCA runtime can allow a third party to create a container that plugs into that runtime to support a particular technology, such as BPEL.

A domain can contain one or more composites, each of which has components implemented in one or more processes running on one or more machines.

UNDERSTANDING COMPONENTS

a component is an instance of an implementation that has been appropriately configured.

The configuration, expressed in SCDL, defines how that component interacts with the outside world.

every component relies on a common set of abstractions, including services, references, properties, and bindings, to specify its interactions with the world outside itself。

SERVICES, REFERENCES, AND PROPERTIES

a component implemented in BPEL would likely describe its services using the Web Services Description Language (WSDL).

Each property contains a value that can be read by that component from the SCDL configuration file when it’s instantiated.

BINDINGS

A binding specifies exactly how communication should be done between an SCA component and something else.

in the same domain,the runtime determines what bindings to use

To communicate outside its domain,must specify one or more bindings for this communication

Each binding defines a particular protocol that can be used to communicate with this service or reference

AN EXAMPLE: SCA’S JAVA COMPONENT MODEL

the Spring Framework provides explicit support for services, references, and properties, and so mapping these into SCA’s similar concepts is straightforward

new component model for Java:Java component model.One important motivation was the need for an explicitly service-oriented approach.

Defining Services

SCA’s Java programming model relies on annotations rather than API calls。

Defining References

In SCA’s Java programming model, references are specified using the @Reference annotation

服务的具体实现是有runtime自动找的(dependency injection或inversion of control)

Defining Properties

@Property protected String region;

it indicates that a value should be read from the SCDL configuration file of the composite to which this component belongs

the goal is : providing a way to configure a component via values that are read at runtime.

Defining Bindings

bindings determine how a component communicates with the world outside its domain

SCA allows each remotable service and each reference to specify the protocols it supports using bindings

SOAP over HTTP-〉Web Services binding,queued messaging protocol-〉JMS binding

Internet Inter-ORB Protocol (IIOP)-〉EJB session bean binding

binary protocol->SCA binding

the bindings a service or reference relies on are either chosen by the runtime, for intra-domain communication, or set explicitly in a component’s SCDL configuration file

Defining Other Aspects of a Component

@OneWay 非阻塞 ,@Scope 控制构件生命期,@Callback 允许定义回调接口

CONFIGURING A COMPONENT

every SCA component relies on information in the SCDL configuration file

UNDERSTANDING COMPOSITES

If components are the atoms of SCA, then composites are the molecules.

WIRES AND PROMOTION

A wire is an abstract representation of the relationship between a reference and some service that meets the needs of that reference.

Exactly what kind of communication a wire provides can vary—it depends on the specific runtime that’s used, what bindings are specified (if any), and other things.

a composite can also expose one or more services。These services are actually implemented by components within the composite。提升后的构件服务,能够作为composite外界可见的接口。

CONFIGURING A COMPOSITE

All of the relationships in a composite are expressed in the SCDL configuration file.

USING POLICY

let developers use policies to specify their intent—what they want to happen—then let something else figure out how to achieve this intent

Interaction policies:Modify how a component interacts with other components.指定安全,可靠性需求。一般是被应用到binding上的。

Implementation policies:Modify how a component behaves locally.指定构件必须运行在一个事务中。

policies can be declared in a SCDL configuration file

For Java SCA components, policies can also be defined using annotations assigned to interfaces,methods. @Confidentiality  @Authentication

To define policies, SCA posits a policy administrator role in each domain.This administrator specifies what a particular policy means in her domain by specifying intents and policySets

PUTTING THE PIECES TOGETHER: ILLUSTRATING AN SCA APPLICATION

IMPLEMENTING SCA

The SCA specs say essentially nothing about how this technology should be implemented.

SCA runtime might provide a number of containers, one for each component technology it supports(Java component model, BPEL, and Spring).The SCA runtime provides all bindings,The runtime also defines all communication between components, regardless of how those components are implemented.

It’s also possible for the creator of an SCA runtime to use OSGi. OSGi defines how to package code into bundles, and while it’s also Java-only, some creators of SCA runtimes might allow extensions such as a new binding to be added as an OSGi bundle.

SOA Tools Platform Project, one of its goals is to create SCA-based development tools for Eclipse.

CONCLUSION

Spring XD 是一个开源的分布式数据处理平台,主要用于构建数据管道和集成任务。它提供了一种简单而高效的方式来处理实时数据流和批量数据。 ### 主要特点: 1. **模块化设计**:Spring XD 采用模块化架构,支持多种数据源、处理器和存储系统,使得用户可以灵活地组合不同的模块来满足特定的需求。 2. **分布式处理**:通过使用Apache ZooKeeper进行协调,Spring XD 能够在多个节点上分布式运行任务,从而提高系统的可扩展性和可靠性。 3. **丰富的模块库**:Spring XD 提供了大量的预定义模块,包括数据源(如Kafka、RabbitMQ)、处理器(如转换、过滤)和存储系统(如HDFS、HBase)。用户也可以自定义模块来扩展功能。 4. **脚本支持**:支持使用JavaScript、Python等脚本语言编写处理器逻辑,使得开发更加灵活和快速。 5. **易于部署和管理**:Spring XD 提供了命令行工具和Web界面,方便用户进行部署、监控和管理。 6. **与Spring生态系统集成**:作为Spring家族的一部分,Spring XD 可以无缝集成到现有的Spring应用程序中,利用Spring框架的强大功能。 ### 应用场景: - **实时数据处理**:适用于需要对流式数据进行实时处理的场景,如日志分析、事件驱动的应用等。 - **ETL流程**:用于提取、转换和加载数据,特别适合大数据环境下的数据集成任务。 - **微服务架构**:在微服务架构中,Spring XD 可以用来处理服务间的消息传递和数据流。 ### 安装步骤: 1. **下载并解压安装包**。 2. **配置环境变量**,确保Java和Maven已正确安装。 3. **启动ZooKeeper**,因为Spring XD依赖于ZooKeeper进行集群管理。 4. **运行Spring XD单节点模式**,可以使用`xd-singlenode`脚本启动。 5. **访问Web界面**,通常位于`http://localhost:8080/`,在这里可以进行模块的创建和管理。 ### 示例代码: 以下是一个简单的例子,展示了如何使用Spring XD创建一个数据管道,该管道从Kafka读取消息,将其转换为大写,然后输出到控制台。 ```shell # 创建Kafka源模块 module create --name kafka-source --type source --definition "kafka --brokers=localhost:9092 --topic=input" # 创建转换模块 module create --name uppercase-transform --type processor --definition "log --expression='payload.toUpperCase()'" # 创建控制台输出模块 module create --name console-sink --type sink --definition "log" # 创建数据管道 stream create --name uppercase-pipeline --definition "kafka-source > uppercase-transform > console-sink" # 启动数据管道 stream deploy --name uppercase-pipeline ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值