ballerina 学习二十三 扩展ballerina

扩展ballerina 目前有三种方式:

  • 扩展client connector的包 (数据库访问,基础设施,api)
  • 扩展server listenner 绑定为不同的协议
  • 添加新的注解到ballerina 源码进行编译并修改运行软件包

创建client connector

client connector 由开发人员在创建endpoint 时进行初始化,你自己可以开发自己的connector 并发布到私服,或者照中央仓库

  • 创建 client connector 的步骤

参考例子 https://github.com/muthulee/package-twilio-super-simple/blob/master/twilio/twilio_endpoint.bal
https://github.com/muthulee/package-client-endpoint-guide/tree/master/clientendpointsample

a.  创建包
b.  创建一个对象(object) 包含init()  && getClient() function
c.  实现init() function  ,这个方法是在用户(开发人员)初始化endpoint 的时候被调用的
d.  实现getClient()  function ,这个方法是在connection 被返回的时候调用
e.  构建包&&push 到仓库

创建自定义注解&& builder extension

  • 注解说明:
 注解实际上就是一段代码片段,可以附加到ballerina 代中,其中包含了一些关联的元数据信息,
 注解不可以执行,只是可以用来修改执行代码的一些行为
 注解可以被附加到 Services Resources Functions Connectors Actions (of Connectors) TypeMappers Structs Constants Annotations Object Record Enum Transformer Endpoint
java 代码,在ballerina 的编译阶段进行执行

参考资料

https://github.com/muthulee/package-twilio-super-simple/blob/master/twilio/twilio_endpoint.bal
https://github.com/muthulee/package-client-endpoint-guide/tree/master/clientendpointsample
https://github.com/ballerinax/hello

原文地址:https://www.cnblogs.com/rongfengliang/p/9126896.html

时间: 2024-07-31 07:19:21

ballerina 学习二十三 扩展ballerina的相关文章

ballerina 学习二十五 项目docker 部署&& 运行

ballerina 官方提供了docker 的runtime,还是比较方便的 基本项目创建 使用cli创建项目 按照提示操作就行 ballerina init -i 项目结构 添加了dockerfile 以及docker-compose 简单http 服务 ├── Ballerina.toml ├── Dockerfile ├── README.md ├── docker-compose.yml ├── hello_service.bal ├── target │ └── hello_servi

ballerina 学习二十一 http2

ballerina 支持http2 协议,包含server push http2 协议 参考代码 import ballerina/http; import ballerina/log;endpoint http:Client http2serviceClientEP { url: "http://localhost:7090", httpVersion: "2.0"};@http:ServiceConfig { basePath: "/http11Ser

android学习二十三(解析json格式数据)

前面我们已经掌握了xml格式数据的解析方式,那么接下来我们学习下如何解析json格式的数据.比起xml,json的主要优势在于它体积更小,在网络上传输的时候可以更省流量.但缺点在于,它的语义性差,看起来不如xml直观. 开始之前,先在自己的电脑apache-tomcat-6.0.39\webapps\ROOT路径目录下新建一个get_data.json的文件,然后编辑这个文件,并加入如下json格式的内容: [{"id":"5","version"

winform学习日志(二十三)---------------socket(TCP)发送文件

一:由于在上一个随笔的基础之上拓展的所以直接上代码,客户端: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net.Sockets; using Sys

全栈JavaScript之路( 二十三 )DOM2、DOM3, 涉及XML命名空间的扩展(一)

<!DOCTYPE html> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"> <head> <title>Example XHTML page</title> </head> <body> <s:svg xmlns:s="http://www.w3.org/2000/svg" version="1.1&

DuiLib学习笔记(二) 扩展CScrollbar属性

DuiLib学习笔记(二) 扩展CScrollbar属性 Duilib的滚动条滑块默认最小值为滚动条的高度(HScrollbar)或者宽度(VScrollbar).并且这个值默认为16.当采用系统样式的滚动条,或者 Troy的源码(https://github.com/qdtroy/DuiLib_Ultimate)自带的样式时,是没有问题的,因为这两种样式默认高(宽)度都是16,当滑块最小时,也有16*16,背景图片(九宫格式)不会出拉伸BUG.但是,当自定义背景图片时,如果图片本身大小超过16

angular学习笔记(二十三)-$http(1)-api

之前说到的$http.get和$http.post,都是基于$http的快捷方式.下面来说说完整的$http: $http(config) $http接受一个json格式的参数config: config的格式如下: { method:字符串 , url:字符串, params:json对象, data:请求数据, headers:请求头, transformRequest:函数,转换post请求的数据的格式, transformResponse:函数,转换响应到的数据的格式, cache:布尔

Android学习路线(二十三)运用Fragment构建动态UI——Fragment间通讯

先占个位置,下次翻译 :p In order to reuse the Fragment UI components, you should build each as a completely self-contained, modular component that defines its own layout and behavior. Once you have defined these reusable Fragments, you can associate them with

java之jvm学习笔记十三(jvm基本结构)

java之jvm学习笔记十三(jvm基本结构) 这一节,主要来学习jvm的基本结构,也就是概述.说是概述,内容很多,而且概念量也很大,不过关于概念方面,你不用担心,我完全有信心,让概念在你的脑子里变成图形,所以只要你有耐心,仔细,认真,并发挥你的想象力,这一章之后你会充满自信.当然,不是说看完本章,就对jvm了解了,jvm要学习的知识实在是非常的多.在你看完本节之后,后续我们还会来学jvm的细节,但是如果你在学习完本节的前提下去学习,再学习其他jvm的细节会事半功倍. 为了让你每一个知识点都有迹