Cloud Foundry Java Client 技术文档
1. 安装指南
Maven 依赖
要在 Maven 项目中使用 Cloud Foundry Java Client,需要在 pom.xml 文件中添加以下依赖:
<dependencies>
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-client-reactor</artifactId>
<version>latest.RELEASE</version>
</dependency>
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-operations</artifactId>
<version>latest.RELEASE</version>
</dependency>
</dependencies>
如果需要使用快照版本,还需要添加 Spring 快照仓库:
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Gradle 依赖
在 Gradle 项目中,依赖配置如下:
dependencies {
compile 'org.cloudfoundry:cloudfoundry-client-reactor:<latest>.RELEASE'
compile 'org.cloudfoundry:cloudfoundry-operations:<latest>.RELEASE'
}
同样,如果需要使用快照版本,需要添加 Spring 快照仓库:
repositories {
maven { url 'https://repo.spring.io/snapshot' }
}
2. 项目的使用说明
项目结构
Cloud Foundry Java Client 项目分为以下几个组件:
cloudfoundry-client:映射到 Cloud Foundry REST API 的接口、请求和响应对象。该项目没有实现,因此无法单独连接到 Cloud Foundry 实例。cloudfoundry-client-reactor:cloudfoundry-client项目的默认实现,基于 Reactor Netty 的HttpClient。cloudfoundry-operations:对应于 Cloud Foundry CLI 操作的 API 和实现。该项目构建在cloudfoundry-client之上,因此只有一个实现。
版本兼容性
5.x版本兼容 Spring Boot2.4.x - 2.6.x。4.x版本使用 Spring Boot2.3.x。
3. 项目API使用文档
CloudFoundryClient, DopplerClient, UaaClient 构建器
最低级别的 API 构建块是 ConnectionContext 和 TokenProvider。这些类型旨在在客户端实例之间共享,并带有开箱即用的实现。可以通过构建器来实例化它们:
DefaultConnectionContext.builder()
.apiHost(apiHost)
.build();
PasswordGrantTokenProvider.builder()
.password(password)
.username(username)
.build();
在 Spring 应用程序中,可以将它们封装在 bean 定义中:
@Bean
DefaultConnectionContext connectionContext(@Value("${cf.apiHost}") String apiHost) {
return DefaultConnectionContext.builder()
.apiHost(apiHost)
.build();
}
@Bean
PasswordGrantTokenProvider tokenProvider(@Value("${cf.username}") String username,
@Value("${cf.password}") String password) {
return PasswordGrantTokenProvider.builder()
.password(password)
.username(username)
.build();
}
CloudFoundryClient, DopplerClient, 和 UaaClient 是接口,每个接口都有一个基于 Reactor 的实现。可以通过构建器来实例化它们:
ReactorCloudFoundryClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
ReactorDopplerClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
ReactorUaaClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
在 Spring 应用程序中,可以将它们封装在 bean 定义中:
@Bean
ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
return ReactorCloudFoundryClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
}
@Bean
ReactorDopplerClient dopplerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
return ReactorDopplerClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
}
@Bean
ReactorUaaClient uaaClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
return ReactorUaaClient.builder()
.connectionContext(connectionContext)
.tokenProvider(tokenProvider)
.build();
}
CloudFoundryOperations 构建器
CloudFoundryOperations 层提供了更高级别的抽象,适合大多数用户使用。可以通过构建器来实例化 DefaultCloudFoundryOperations:
DefaultCloudFoundryOperations.builder()
.cloudFoundryClient(cloudFoundryClient)
.dopplerClient(dopplerClient)
.uaaClient(uaaClient)
.organization("example-organization")
.space("example-space")
.build();
在 Spring 应用程序中,可以将它封装在 bean 定义中:
@Bean
DefaultCloudFoundryOperations cloudFoundryOperations(CloudFoundryClient cloudFoundryClient,
DopplerClient dopplerClient,
UaaClient uaaClient,
@Value("${cf.organization}") String organization,
@Value("${cf.space}") String space) {
return DefaultCloudFoundryOperations.builder()
.cloudFoundryClient(cloudFoundryClient)
.dopplerClient(dopplerClient)
.uaaClient(uaaClient)
.organization(organization)
.space(space)
.build();
}
CloudFoundryOperations API
一旦获得了 CloudFoundryOperations 的引用,就可以开始调用 Cloud Foundry 实例的 API。以下是一个简单的示例,列出用户所属的所有组织:
cloudFoundryOperations.organizations()
.list()
.map(OrganizationSummary::getName)
.subscribe(System.out::println);
CloudFoundryClient API
cloudfoundry-operations 实现构建在 cloudfoundry-client API 之上。以下是 Organizations.list() 方法的实现示例:
cloudFoundryClient.organizations()
.list(ListOrganizationsRequest.builder()
.page(1)
.build())
.flatMapIterable(ListOrganizationsResponse::getResources)
.map(resource -> OrganizationSummary.builder()
.id(resource.getMetadata().getId())
.name(resource.getEntity().getName())
.build());
4. 项目安装方式
项目的安装方式主要是通过 Maven 或 Gradle 添加依赖来实现。具体步骤请参考 安装指南 部分。
Kimi-K2.5Kimi K2.5 是一款开源的原生多模态智能体模型,它在 Kimi-K2-Base 的基础上,通过对约 15 万亿混合视觉和文本 tokens 进行持续预训练构建而成。该模型将视觉与语言理解、高级智能体能力、即时模式与思考模式,以及对话式与智能体范式无缝融合。Python00
GLM-4.7-FlashGLM-4.7-Flash 是一款 30B-A3B MoE 模型。作为 30B 级别中的佼佼者,GLM-4.7-Flash 为追求性能与效率平衡的轻量化部署提供了全新选择。Jinja00
VLOOKVLOOK™ 是优雅好用的 Typora/Markdown 主题包和增强插件。 VLOOK™ is an elegant and practical THEME PACKAGE × ENHANCEMENT PLUGIN for Typora/Markdown.Less00
PaddleOCR-VL-1.5PaddleOCR-VL-1.5 是 PaddleOCR-VL 的新一代进阶模型,在 OmniDocBench v1.5 上实现了 94.5% 的全新 state-of-the-art 准确率。 为了严格评估模型在真实物理畸变下的鲁棒性——包括扫描伪影、倾斜、扭曲、屏幕拍摄和光照变化——我们提出了 Real5-OmniDocBench 基准测试集。实验结果表明,该增强模型在新构建的基准测试集上达到了 SOTA 性能。此外,我们通过整合印章识别和文本检测识别(text spotting)任务扩展了模型的能力,同时保持 0.9B 的超紧凑 VLM 规模,具备高效率特性。Python00
KuiklyUI基于KMP技术的高性能、全平台开发框架,具备统一代码库、极致易用性和动态灵活性。 Provide a high-performance, full-platform development framework with unified codebase, ultimate ease of use, and dynamic flexibility. 注意:本仓库为Github仓库镜像,PR或Issue请移步至Github发起,感谢支持!Kotlin07
compass-metrics-modelMetrics model project for the OSS CompassPython00